added clearer error messages for unsupported modifier keywords (artf724039)
authorBotond Baranyi <botond.baranyi@ericsson.com>
Tue, 26 Jul 2016 15:41:23 +0000 (17:41 +0200)
committerBotond Baranyi <botond.baranyi@ericsson.com>
Tue, 26 Jul 2016 15:41:23 +0000 (17:41 +0200)
Change-Id: I2d4e8e3beb6ac165944162b72247766b1bbb8b8f
Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com>
compiler2/ttcn3/compiler.l
compiler2/ttcn3/compiler.y

index 8ef00263a7a2c959aaa8aca27eab21acca01ba5f..8f321140f545e4ef82bd056072efbdc3fd2f8fc6 100644 (file)
@@ -519,8 +519,12 @@ xor4b              RETURN(Xor4bKeyword);
 
   /* modifier keywords */
 
-"@nocase" RETURN(NocaseKeyword);
-"@lazy"   RETURN(LazyKeyword);
+"@nocase"        RETURN(NocaseKeyword);
+"@lazy"          RETURN(LazyKeyword);
+"@decoded"       RETURN(DecodedKeyword);
+"@deterministic" RETURN(DeterministicKeyword);
+"@fuzzy"         RETURN(FuzzyKeyword);
+"@index"         RETURN(IndexKeyword);
 
   /* special TITAN specific keywords */
 
index c34e8f520732fb67ce25b7bb7800bb224bf6e7ba..d40f250716191aa45cc4021a7fec8f08f31a6680 100644 (file)
@@ -739,6 +739,10 @@ static const string anyname("anytype");
 /* modifier keywords */
 %token NocaseKeyword
 %token LazyKeyword
+%token DecodedKeyword
+%token DeterministicKeyword
+%token FuzzyKeyword
+%token IndexKeyword
 
 /* TITAN specific keywords */
 %token TitanSpecificTryKeyword
@@ -864,7 +868,7 @@ static const string anyname("anytype");
  *********************************************************************/
 
 %type <bool_val> optAliveKeyword optOptionalKeyword optOverrideKeyword
-  optErrValueRaw optAllKeyword optLazyEval
+  optErrValueRaw optAllKeyword optLazyOrFuzzyModifier
 %type <str> FreeText optLanguageSpec PatternChunk PatternChunkList
 %type <uchar_val> Group Plane Row Cell
 %type <id> FieldIdentifier FieldReference GlobalModuleId
@@ -3108,10 +3112,10 @@ TestcaseTypeDef:
 /* A.1.6.1.3 Template definitions */
 
 TemplateDef: // 93
-  TemplateKeyword optTemplateRestriction BaseTemplate
+  TemplateKeyword optTemplateRestriction optLazyOrFuzzyModifier BaseTemplate
   optDerivedDef AssignmentChar TemplateBody
   {
-    $$ = new Def_Template($2, $3.name, $3.type, $3.fp_list, $4, $6);
+    $$ = new Def_Template($2, $4.name, $4.type, $4.fp_list, $5, $7);
     $$->set_location(infile, @$);
   }
 ;
@@ -3829,16 +3833,25 @@ ValueofOp: // 162
 /* A.1.6.1.4 Function definitions */
 
 FunctionDef: // 164
-  FunctionKeyword IDentifier '(' optFunctionFormalParList ')'
+  FunctionKeyword optDeterministicModifier IDentifier '(' optFunctionFormalParList ')'
   optRunsOnSpec optReturnType optError StatementBlock
   {
-    $4->set_location(infile, @3, @5);
-    $$ = new Def_Function($2, $4, $6, $7.type, $7.returns_template,
-                          $7.template_restriction, $9);
+    $5->set_location(infile, @4, @6);
+    $$ = new Def_Function($3, $5, $7, $8.type, $8.returns_template,
+                          $8.template_restriction, $10);
     $$->set_location(infile, @$);
   }
 ;
 
+optDeterministicModifier:
+  /* empty */
+| DeterministicKeyword
+  {
+    Location loc(infile, @1);
+    loc.error("Modifier '@deterministic' is not currently supported.");
+  }
+;
+
 optFunctionFormalParList: // [167]
   /* empty */ { $$ = new FormalParList; }
 | FunctionFormalParList { $$ = $1; }
@@ -4916,12 +4929,12 @@ GroupIdentifier: // 274 (followed by) 275.
 /* A.1.6.1.10 External function definitions */
 
 ExtFunctionDef: // 276
-  ExtKeyword FunctionKeyword IDentifier
+  ExtKeyword FunctionKeyword optDeterministicModifier IDentifier
   '(' optFunctionFormalParList ')' optReturnType
   {
-    $5->set_location(infile, @4, @6);
-    $$ = new Def_ExtFunction($3, $5, $7.type, $7.returns_template,
-                             $7.template_restriction);
+    $6->set_location(infile, @5, @7);
+    $$ = new Def_ExtFunction($4, $6, $8.type, $8.returns_template,
+                             $8.template_restriction);
     $$->set_location(infile, @$);
   }
 ;
@@ -5178,58 +5191,58 @@ ControlStatement: /* Statement *stmt */ // 295
 /* A.1.6.2.1 Variable instantiation */
 
 VarInstance: // 296
-  VarKeyword Type VarList
+  VarKeyword optLazyOrFuzzyModifier Type VarList
   {
-    $$.nElements = $3.nElements;
+    $$.nElements = $4.nElements;
     $$.elements = (Ttcn::Definition**)
       Malloc($$.nElements*sizeof(*$$.elements));
     for (size_t i = 0; i < $$.nElements; i++) {
       Type *type;
       if (i > 0) {
-       type = new Type(Type::T_REFDSPEC, $2);
-       type->set_location(*$2);
-      } else type = $2;
+       type = new Type(Type::T_REFDSPEC, $3);
+       type->set_location(*$3);
+      } else type = $3;
       /* creation of array type(s) if necessary (from right to left) */
-      for (size_t j = $3.elements[i].arrays.nElements; j > 0; j--) {
+      for (size_t j = $4.elements[i].arrays.nElements; j > 0; j--) {
         type = new Type(Type::T_ARRAY, type,
-         $3.elements[i].arrays.elements[j - 1], false);
-        type->set_location(*$2);
+         $4.elements[i].arrays.elements[j - 1], false);
+        type->set_location(*$3);
       }
-      Free($3.elements[i].arrays.elements);
+      Free($4.elements[i].arrays.elements);
 
       /* Create the definition */
-      $$.elements[i] = new Def_Var($3.elements[i].id,
-                                   type, $3.elements[i].initial_value);
-      $$.elements[i]->set_location(infile, $3.elements[i].yyloc);
+      $$.elements[i] = new Def_Var($4.elements[i].id,
+                                   type, $4.elements[i].initial_value);
+      $$.elements[i]->set_location(infile, $4.elements[i].yyloc);
     }
-    Free($3.elements);
+    Free($4.elements);
   }
-| VarKeyword TemplateOptRestricted Type TempVarList
+| VarKeyword TemplateOptRestricted optLazyOrFuzzyModifier Type TempVarList
   {
-    $$.nElements = $4.nElements;
+    $$.nElements = $5.nElements;
     $$.elements = (Ttcn::Definition**)
       Malloc($$.nElements * sizeof(*$$.elements));
     for (size_t i = 0; i < $$.nElements; i++) {
       Type *type;
       if (i > 0) {
-       type = new Type(Type::T_REFDSPEC, $3);
-       type->set_location(*$3);
-      } else type = $3;
+       type = new Type(Type::T_REFDSPEC, $4);
+       type->set_location(*$4);
+      } else type = $4;
       /* creation of array type(s) if necessary (from right to left) */
-      for (size_t j = $4.elements[i].arrays.nElements; j > 0; j--) {
+      for (size_t j = $5.elements[i].arrays.nElements; j > 0; j--) {
         type = new Type(Type::T_ARRAY, type,
-         $4.elements[i].arrays.elements[j - 1], false);
-        type->set_location(*$3);
+         $5.elements[i].arrays.elements[j - 1], false);
+        type->set_location(*$4);
       }
-      Free($4.elements[i].arrays.elements);
+      Free($5.elements[i].arrays.elements);
 
       /* Create the definition */
-      $$.elements[i] = new Def_Var_Template($4.elements[i].id, type,
-                                            $4.elements[i].initial_value, $2);
-      $$.elements[i]->set_location(infile, $4.elements[i].yyloc);
+      $$.elements[i] = new Def_Var_Template($5.elements[i].id, type,
+                                            $5.elements[i].initial_value, $2);
+      $$.elements[i]->set_location(infile, $5.elements[i].yyloc);
     }
 
-    Free($4.elements);
+    Free($5.elements);
 }
 ;
 
@@ -5477,11 +5490,21 @@ optDoneParameter:
     $$.donematch = $1;
     $$.redirect = 0;
   }
+| optReceiveParameter PortRedirectSymbol IndexSpec
+  {
+    $$.donematch = $1;
+    $$.redirect = 0;
+  }
 | optReceiveParameter PortRedirectSymbol ValueSpec
   {
     $$.donematch = $1;
     $$.redirect = $3;
   }
+| optReceiveParameter PortRedirectSymbol ValueSpec IndexSpec
+  {
+    $$.donematch = $1;
+    $$.redirect = $3;
+  }
 ;
 
 KilledStatement: // 320
@@ -6146,11 +6169,31 @@ optPortRedirect: // [387]
     $$.redirectval=0;
     $$.redirectsender=$2;
   }
+| PortRedirectSymbol IndexSpec
+  {
+    $$.redirectval=0;
+    $$.redirectsender=0;
+  }
 | PortRedirectSymbol ValueSpec SenderSpec
   {
     $$.redirectval=$2;
     $$.redirectsender=$3;
   }
+| PortRedirectSymbol ValueSpec IndexSpec
+  {
+    $$.redirectval=$2;
+    $$.redirectsender=0;
+  }
+| PortRedirectSymbol SenderSpec IndexSpec
+  {
+    $$.redirectval=0;
+    $$.redirectsender=$2;
+  }
+| PortRedirectSymbol ValueSpec SenderSpec IndexSpec
+  {
+    $$.redirectval=$2;
+    $$.redirectsender=$3;
+  }
 | PortRedirectSymbol error
   {
     $$.redirectval=0;
@@ -6168,6 +6211,15 @@ SenderSpec: // 391
 | SenderKeyword error { $$ = 0; }
 ;
 
+IndexSpec:
+  IndexKeyword ValueSpec
+  {
+    Location loc(infile, @1);
+    loc.error("Modifier '@index' is not currently supported.");
+    delete $2;
+  }
+;
+
 TriggerStatement: // 393
   PortOrAny DotTriggerOpKeyword PortTriggerOp
   {
@@ -6217,16 +6269,36 @@ optPortRedirectWithParam: // [399]
     $$.redirectparam=$2;
     $$.redirectsender=0;
   }
+| PortRedirectSymbol SenderSpec
+  {
+    $$.redirectparam=0;
+    $$.redirectsender=$2;
+  }
+| PortRedirectSymbol IndexSpec
+  {
+    $$.redirectparam=0;
+    $$.redirectsender=0;
+  }
 | PortRedirectSymbol ParamSpec SenderSpec
   {
     $$.redirectparam=$2;
     $$.redirectsender=$3;
   }
-| PortRedirectSymbol SenderSpec
+| PortRedirectSymbol ParamSpec IndexSpec
+  {
+    $$.redirectparam=$2;
+    $$.redirectsender=0;
+  }
+| PortRedirectSymbol SenderSpec IndexSpec
   {
     $$.redirectparam=0;
     $$.redirectsender=$2;
   }
+| PortRedirectSymbol ParamSpec SenderSpec IndexSpec
+  {
+    $$.redirectparam=$2;
+    $$.redirectsender=$3;
+  }
 | PortRedirectSymbol error
   {
     $$.redirectparam=0;
@@ -6277,13 +6349,28 @@ AssignmentList: // 404
 ;
 
 VariableAssignment: // 405
-  VariableRef AssignmentChar IDentifier
+  VariableRef AssignmentChar optDecodedModifier IDentifier
   {
-    $$ = new ParamAssignment($3, $1);
+    $$ = new ParamAssignment($4, $1);
     $$->set_location(infile, @$);
   }
 ;
 
+optDecodedModifier:
+  /* empty */
+| DecodedKeyword
+  {
+    Location loc(infile, @1);
+    loc.error("Modifier '@decoded' is not currently supported.");
+  }
+| DecodedKeyword '(' SingleExpression ')'
+  {
+    Location loc(infile, @1);
+    loc.error("Modifier '@decoded' is not currently supported.");
+    delete $3;
+  }
+;
+
 VariableList: // 407
   VariableEntry
   {
@@ -6351,6 +6438,24 @@ optPortRedirectWithValueAndParam: // [411]
     $$.redirectparam=0;
     $$.redirectsender=0;
   }
+| PortRedirectSymbol ParamSpec
+  {
+    $$.redirectval=0;
+    $$.redirectparam=$2;
+    $$.redirectsender=0;
+  }
+| PortRedirectSymbol SenderSpec
+  {
+    $$.redirectval=0;
+    $$.redirectparam=0;
+    $$.redirectsender=$2;
+  }
+| PortRedirectSymbol IndexSpec
+  {
+    $$.redirectval=0;
+    $$.redirectparam=0;
+    $$.redirectsender=0;
+  }
 | PortRedirectSymbol ValueSpec ParamSpec
   {
     $$.redirectval=$2;
@@ -6363,30 +6468,60 @@ optPortRedirectWithValueAndParam: // [411]
     $$.redirectparam=0;
     $$.redirectsender=$3;
   }
-| PortRedirectSymbol ValueSpec ParamSpec SenderSpec
+| PortRedirectSymbol ValueSpec IndexSpec
   {
     $$.redirectval=$2;
-    $$.redirectparam=$3;
-    $$.redirectsender=$4;
+    $$.redirectparam=0;
+    $$.redirectsender=0;
   }
-| PortRedirectSymbol ParamSpec
+| PortRedirectSymbol ParamSpec SenderSpec
+  {
+    $$.redirectval=0;
+    $$.redirectparam=$2;
+    $$.redirectsender=$3;
+  }
+| PortRedirectSymbol ParamSpec IndexSpec
   {
     $$.redirectval=0;
     $$.redirectparam=$2;
     $$.redirectsender=0;
   }
-| PortRedirectSymbol SenderSpec
+| PortRedirectSymbol SenderSpec IndexSpec
   {
     $$.redirectval=0;
     $$.redirectparam=0;
     $$.redirectsender=$2;
   }
-| PortRedirectSymbol ParamSpec SenderSpec
+| PortRedirectSymbol ValueSpec ParamSpec SenderSpec
+  {
+    $$.redirectval=$2;
+    $$.redirectparam=$3;
+    $$.redirectsender=$4;
+  }
+| PortRedirectSymbol ValueSpec ParamSpec IndexSpec
+  {
+    $$.redirectval=$2;
+    $$.redirectparam=$3;
+    $$.redirectsender=0;
+  }
+| PortRedirectSymbol ValueSpec SenderSpec IndexSpec
+  {
+    $$.redirectval=$2;
+    $$.redirectparam=0;
+    $$.redirectsender=$3;
+  }
+| PortRedirectSymbol ParamSpec SenderSpec IndexSpec
   {
     $$.redirectval=0;
     $$.redirectparam=$2;
     $$.redirectsender=$3;
   }
+| PortRedirectSymbol ValueSpec ParamSpec SenderSpec IndexSpec
+  {
+    $$.redirectval=$2;
+    $$.redirectparam=$3;
+    $$.redirectsender=$4;
+  }
 | PortRedirectSymbol error
   {
     $$.redirectval=0;
@@ -6506,6 +6641,18 @@ FromClausePresent: // 419
     $$.redirectparam = 0;
     $$.redirectsender = 0;
   }
+| FromClause PortRedirectSymbol IndexSpec
+  {
+    $$.statementtype = Statement::S_CHECK;
+    $$.signature = 0;
+    $$.templ_inst = $1;
+    $$.valuematch = 0;
+    $$.timeout = false;
+    $$.fromclause = 0;
+    $$.redirectval = 0;
+    $$.redirectparam = 0;
+    $$.redirectsender = 0;
+  }
 | FromClause PortRedirectSymbol SenderSpec
   {
     $$.statementtype = Statement::S_CHECK;
@@ -6518,6 +6665,18 @@ FromClausePresent: // 419
     $$.redirectparam = 0;
     $$.redirectsender = $3;
   }
+| FromClause PortRedirectSymbol SenderSpec IndexSpec
+  {
+    $$.statementtype = Statement::S_CHECK;
+    $$.signature = 0;
+    $$.templ_inst = $1;
+    $$.valuematch = 0;
+    $$.timeout = false;
+    $$.fromclause = 0;
+    $$.redirectval = 0;
+    $$.redirectparam = 0;
+    $$.redirectsender = $3;
+  }
 ;
 
 RedirectPresent: // 420
@@ -6533,6 +6692,30 @@ RedirectPresent: // 420
     $$.redirectparam = 0;
     $$.redirectsender = $2;
   }
+| PortRedirectSymbol IndexSpec
+  {
+    $$.statementtype = Statement::S_CHECK;
+    $$.signature = 0;
+    $$.templ_inst = 0;
+    $$.valuematch = 0;
+    $$.timeout = false;
+    $$.fromclause = 0;
+    $$.redirectval = 0;
+    $$.redirectparam = 0;
+    $$.redirectsender = 0;
+  }
+| PortRedirectSymbol SenderSpec IndexSpec
+  {
+    $$.statementtype = Statement::S_CHECK;
+    $$.signature = 0;
+    $$.templ_inst = 0;
+    $$.valuematch = 0;
+    $$.timeout = false;
+    $$.fromclause = 0;
+    $$.redirectval = 0;
+    $$.redirectparam = 0;
+    $$.redirectsender = $2;
+  }
 ;
 
 CheckPortOpsPresent: // 421
@@ -7252,18 +7435,24 @@ Reference: // 490 ValueReference
 
 /* A.1.6.5 Parameterization */
 
-optLazyEval:
+optLazyOrFuzzyModifier:
   /* empty */ { $$ = false; }
 | LazyKeyword { $$ = true; }
+| FuzzyKeyword
+  {
+    $$ = false;
+    Location loc(infile, @1);
+    loc.error("Modifier '@fuzzy' is not currently supported.");
+  }
 ;
 
 FormalValuePar: // 516
-  optLazyEval Type IDentifier optParDefaultValue
+  optLazyOrFuzzyModifier Type IDentifier optParDefaultValue
   {
     $$ = new FormalPar(Common::Assignment::A_PAR_VAL, $2, $3, $4, $1);
     $$->set_location(infile, @$);
   }
-| InParKeyword optLazyEval Type IDentifier optParDefaultValue
+| InParKeyword optLazyOrFuzzyModifier Type IDentifier optParDefaultValue
   {
     $$ = new FormalPar(Common::Assignment::A_PAR_VAL_IN, $3, $4, $5, $2);
     $$->set_location(infile, @$);
@@ -7301,12 +7490,12 @@ FormalTimerPar: // 520
 ;
 
 FormalTemplatePar: // 522
-  TemplateOptRestricted optLazyEval Type IDentifier optParDefaultValue
+  TemplateOptRestricted optLazyOrFuzzyModifier Type IDentifier optParDefaultValue
   {
     $$ = new FormalPar(Common::Assignment::A_PAR_TEMPL_IN, $1, $3, $4, $5, $2);
     $$->set_location(infile, @$);
   }
-| InParKeyword TemplateOptRestricted optLazyEval Type IDentifier optParDefaultValue
+| InParKeyword TemplateOptRestricted optLazyOrFuzzyModifier Type IDentifier optParDefaultValue
   {
     $$ = new FormalPar(Common::Assignment::A_PAR_TEMPL_IN, $2, $4, $5, $6, $3);
     $$->set_location(infile, @$);
This page took 0.033658 seconds and 5 git commands to generate.