Changeset 6918
- Timestamp:
- 2010-11-09T09:15:14+01:00 (14 years ago)
- Location:
- branches/sjoelund-functiontree
- Files:
-
- 2 added
- 4 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/sjoelund-functiontree
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/sjoelund-functiontree/Compiler/Error.mo
r6542 r6918 283 283 public constant ErrorID META_STRICT_RML_MATCH_IN_OUT=5016; 284 284 public constant ErrorID META_NONE_CREF=5017; 285 public constant ErrorID META_INVALID_PATTERN_NAMED_FIELD=5018; 285 286 286 287 protected constant list<tuple<Integer, MessageType, Severity, String>> errorTable= … … 638 639 (LOOKUP_FUNCTION_GOT_CLASS,TRANSLATION(),ERROR(),"Looking for a function %s but found a %s."), 639 640 (META_STRICT_RML_MATCH_IN_OUT,TRANSLATION(),ERROR(),"%s. Strict RML enforces match expression input and output to be the same as the function's."), 640 (META_NONE_CREF,TRANSLATION(),ERROR(),"NONE is not acceptable syntax. Use NONE() instead.") 641 (META_NONE_CREF,TRANSLATION(),ERROR(),"NONE is not acceptable syntax. Use NONE() instead."), 642 (META_INVALID_PATTERN_NAMED_FIELD,TRANSLATION(),ERROR(),"Invalid named fields: %s") 641 643 }; 642 644 -
branches/sjoelund-functiontree/Compiler/Patternm.mo
r6760 r6918 486 486 RenamedPat pat,first2,second2; 487 487 Integer constTag,i,numPosArgs; 488 list<Absyn.NamedArg> namedArgList ;488 list<Absyn.NamedArg> namedArgList,invalidArgs; 489 489 Absyn.Path recName,pathName; 490 490 SCode.Class sClass; … … 611 611 612 612 // CALL EXPRESSION - translates pos/named args into only pos ones 613 case (Absyn.CALL(compRef,Absyn.FUNCTIONARGS(funcArgs,namedArgList)), 614 localVar,localAsBinds,localCache,localEnv,localConstTagEnv,info) 613 case (Absyn.CALL(compRef,Absyn.FUNCTIONARGS(funcArgs,namedArgList)),localVar,localAsBinds,localCache,localEnv,localConstTagEnv,info) 615 614 equation 616 615 recName = Absyn.crefToPath(compRef); … … 628 627 629 628 //Sorting of named arguments 630 funcArgsNamedFixed= generatePositionalArgs(fieldNamesNamed,namedArgList,{});629 (funcArgsNamedFixed,invalidArgs) = generatePositionalArgs(fieldNamesNamed,namedArgList,{}); 631 630 funcArgs = listAppend(funcArgs,funcArgsNamedFixed); 632 631 633 (localCache,renamedPatList,localAsBinds2,localConstTagEnv,status) = renamePatList(funcArgs 634 ,localVar2,1,{},{},localCache,localEnv,localConstTagEnv,info); 632 (localCache,renamedPatList,localAsBinds2,localConstTagEnv,status) = renamePatList(funcArgs,localVar2,1,{},{},localCache,localEnv,localConstTagEnv,info); 635 633 pat = DFA.RP_CALL(localVar,compRef,renamedPatList); 636 634 status = checkInvalidPatternNamedArgs(invalidArgs,status,info); 637 635 then (localCache,pat,listAppend(localAsBinds,localAsBinds2),localConstTagEnv,status); 638 636 // EMPTY LIST EXPRESSION … … 2001 1999 input list<Absyn.Exp> accList; 2002 2000 output list<Absyn.Exp> outList; 2003 algorithm 2004 outList := 2005 matchcontinue (fieldNameList,namedArgList,accList)2001 output list<Absyn.NamedArg> outInvalidNames; 2002 algorithm 2003 (outList,outInvalidNames) := matchcontinue (fieldNameList,namedArgList,accList) 2006 2004 local 2007 2005 list<Absyn.Exp> localAccList; 2008 2006 list<Absyn.Ident> restFieldNames; 2009 2007 Absyn.Ident firstFieldName; 2010 list<Absyn.Exp> expL;2008 Absyn.Exp exp; 2011 2009 list<Absyn.NamedArg> localNamedArgList; 2012 case ({}, _,localAccList) then localAccList;2010 case ({},namedArgList,localAccList) then (listReverse(localAccList),namedArgList); 2013 2011 case (firstFieldName :: restFieldNames,localNamedArgList,localAccList) 2014 2012 equation 2015 expL = Util.listCreate(findFieldExpInList(firstFieldName,localNamedArgList)); 2016 localAccList = listAppend(localAccList,expL); 2017 localAccList = generatePositionalArgs(restFieldNames,localNamedArgList,localAccList); 2018 then localAccList; 2013 (exp,localNamedArgList) = findFieldExpInList(firstFieldName,localNamedArgList); 2014 (localAccList,localNamedArgList) = generatePositionalArgs(restFieldNames,localNamedArgList,exp::localAccList); 2015 then (localAccList,localNamedArgList); 2019 2016 end matchcontinue; 2020 2017 end generatePositionalArgs; … … 2027 2024 input list<Absyn.NamedArg> namedArgList; 2028 2025 output Absyn.Exp outExp; 2029 algorithm 2030 outExp := 2031 matchcontinue (firstFieldName,namedArgList)2026 output list<Absyn.NamedArg> outNamedArgList; 2027 algorithm 2028 (outExp,outNamedArgList) := matchcontinue (firstFieldName,namedArgList) 2032 2029 local 2033 2030 Absyn.Exp e; 2034 2031 Absyn.Ident localFieldName,aName; 2035 list<Absyn.NamedArg> restNamedArgList; 2036 case (_,{}) then Absyn.CREF(Absyn.WILD()); 2037 case (localFieldName,Absyn.NAMEDARG(aName,e) :: _) 2032 list<Absyn.NamedArg> rest; 2033 Absyn.NamedArg first; 2034 case (_,{}) then (Absyn.CREF(Absyn.WILD()),{}); 2035 case (localFieldName,Absyn.NAMEDARG(aName,e) :: rest) 2038 2036 equation 2039 2037 true = stringEq(localFieldName,aName); 2040 then e;2041 case (localFieldName, _ :: restNamedArgList)2042 equation 2043 e = findFieldExpInList(localFieldName,restNamedArgList);2044 then e;2038 then (e,rest); 2039 case (localFieldName,first::rest) 2040 equation 2041 (e,rest) = findFieldExpInList(localFieldName,rest); 2042 then (e,first::rest); 2045 2043 end matchcontinue; 2046 2044 end findFieldExpInList; … … 2631 2629 end getCaseDecls; 2632 2630 2631 protected function checkInvalidPatternNamedArgs 2632 "Checks that there are no invalid named arguments in the pattern" 2633 input list<Absyn.NamedArg> args; 2634 input Util.Status status; 2635 input Absyn.Info info; 2636 output Util.Status outStatus; 2637 algorithm 2638 outStatus := match (args,status,info) 2639 local 2640 list<String> argsNames; 2641 String str1; 2642 case ({},status,_) then status; 2643 case (args,status,info) 2644 equation 2645 (argsNames,_) = Absyn.getNamedFuncArgNamesAndValues(args); 2646 str1 = Util.stringDelimitList(argsNames, ","); 2647 Error.addSourceMessage(Error.META_INVALID_PATTERN_NAMED_FIELD, {str1}, info); 2648 then Util.FAILURE(); 2649 end match; 2650 end checkInvalidPatternNamedArgs; 2651 2633 2652 end Patternm; -
branches/sjoelund-functiontree/testsuite/meta/ErrorInvalidPattern1.mo
r6917 r6918 1 // name: ErrorInvalidPattern 1 // name: ErrorInvalidPattern1 2 2 // cflags: +g=MetaModelica 3 3 // status: incorrect 4 package ErrorInvalidPattern 4 5 package ErrorInvalidPattern1 5 6 6 7 function fn … … 15 16 constant String str = fn(""); 16 17 17 end ErrorInvalidPattern; 18 end ErrorInvalidPattern1; 19 18 20 // Result: 19 // Error processing file: ErrorInvalidPattern .mo20 // [ErrorInvalidPattern .mo:11:10-11:19:writable] Error: Invalid pattern: str + ""21 // Error processing file: ErrorInvalidPattern1.mo 22 // [ErrorInvalidPattern1.mo:12:10-12:19:writable] Error: Invalid pattern: str + "" 21 23 // 22 24 // # Error encountered! Exiting... -
branches/sjoelund-functiontree/testsuite/meta/Makefile
r6532 r6918 16 16 EqPatternm.mos \ 17 17 ErrorInteractiveCallFunctionPtr.mos \ 18 ErrorInvalidPattern.mo \ 18 ErrorInvalidPattern1.mo \ 19 ErrorInvalidPattern2.mo \ 20 ErrorInvalidPattern3.mo \ 19 21 ErrorMatchInOut1.mo \ 20 22 ErrorMatchInOut2.mo \
Note: See TracChangeset
for help on using the changeset viewer.