Last sync 2016.04.01
[deliverable/titan.core.git] / compiler2 / ttcn3 / rawAST.l
index 84e3017f8803120e3b0ba43c77808df218b4ed92..00a714172433670ee2db19055a66d3fd3849f8de 100644 (file)
@@ -1,9 +1,21 @@
 /******************************************************************************
- * Copyright (c) 2000-2014 Ericsson Telecom AB
+ * Copyright (c) 2000-2016 Ericsson Telecom AB
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Balasko, Jeno
+ *   Baranyi, Botond
+ *   Delic, Adam
+ *   Forstner, Matyas
+ *   Raduly, Csaba
+ *   Szabados, Kristof
+ *   Szabo, Janos Zoltan – initial implementation
+ *   Szalai, Gabor
+ *   Zalanyi, Balazs Andor
+ *
  ******************************************************************************/
 %option noyywrap
 %option never-interactive
@@ -172,7 +184,7 @@ omit        RETURN(XOmitKeyword);
   current_column += 2;
   bool backslash_flag = false;
   yylval.str = memptystr();
-  for (int i = 2; i < yyleng - 2; ) {
+  for (size_t i = 2; i < yyleng - 2; ) {
     if (!backslash_flag && (yytext[i] == '\\' || yytext[i] == '"') &&
        yytext[i + 1] == '"' &&
        (yytext[i + 2] == '\\' || yytext[i + 2] == '"') &&
@@ -284,6 +296,9 @@ BITORDERINFIELD    { BEGIN(rawcodec); RETURN(XBitOrderInFieldKeyword); }
 BITORDERINOCTET    { BEGIN(rawcodec); RETURN(XBitOrderInOctetKeyword); }
 HEXORDER    { BEGIN(rawcodec); RETURN(XHexOrderKeyword); }
 TOPLEVEL    { BEGIN(rawcodec); RETURN(XToplevelKeyword); }
+IntX        { RETURN(XIntXKeyword); }
+bit         { RETURN(XBitKeyword); }
+unsigned    { RETURN(XUnsignedKeyword); }
 
 <rawcodec>{
 yes         { yylval.enumval = XDEFYES; RETURN(XYes); }
@@ -330,10 +345,12 @@ TEXT_CODING { BEGIN(textcodec);RETURN(XCodingKeyword); }
          * when to return to INITIAL) */
 
        /* First, the "starter" attributes */
+abstract RETURN(XKWabstract);
 anyAttributes  RETURN(XKWanyAttributes);
 anyElement     RETURN(XKWanyElement);
 attribute      RETURN(XKWattribute);
 attributeFormQualified RETURN(XKWattributeFormQualified);
+block RETURN(XKWblock);
 controlNamespace RETURN(XKWcontrolNamespace);
 defaultForEmpty        RETURN(XKWdefaultForEmpty);
 element        RETURN(XKWelement);
@@ -434,16 +451,24 @@ null          RETURN(XKWnull);
 name          RETURN(XKWname);
 value         RETURN(XKWvalue);
 default       RETURN(XKWdefault);
+extend        RETURN(XKWextend);
+metainfo      RETURN(XKWmetainfo);
+for           RETURN(XKWfor);
+unbound       RETURN(XKWunbound);
 [(]           { BEGIN(jsonvalue); RETURN(XJsonValueStart); }
 {IDENTIFIER}  { yylval.str = mcopystr(yytext); RETURN(XAliasToken); }
 [^: \t]       { rawAST_error("invalid JSON token"); }
 }
 
 <jsonvalue>{
-[\\]. {
+[\\][\\][)] { /* \\) -> \) would not work with the other rules */
+  yylval.str = mcopystr("\\)");
+  RETURN(XJsonValueSegment);
+}
+[\\]. { /* \) -> ), all others are treated literally */
   if (yytext[1] == ')') yylval.str = mcopystr(")");
   else yylval.str = mcopystr(yytext);
-  RETURN(XJsonValueSegment); 
+  RETURN(XJsonValueSegment);
 }
 [)]           { BEGIN(jsoncodec); RETURN(XJsonValueEnd); }
 [\"][\"]      { yylval.str = mcopystr("\\\""); RETURN(XJsonValueSegment); }
@@ -466,7 +491,7 @@ definite   RETURN(XKWdefinite);
   current_column++;
   bool backslash_flag = false;
   yylval.str = memptystr();
-  for (int i = 1; i < yyleng - 1; ) {
+  for (size_t i = 1; i < yyleng - 1; ) {
     if (!backslash_flag && (yytext[i] == '\'' || yytext[i] == '"') &&
         yytext[i + 1] == yytext[i]) {
       /* transform '' -> \' and "" -> \" */
@@ -667,10 +692,18 @@ void rawAST_error(const char *str)
   Location loc(infile, yylloc);
   if (*yytext) {
     // the most recently parsed token is known
-    loc.error("in variant attribute, at or before token `%s': %s", yytext, str);
+    if (warnings_for_bad_variants) {
+      loc.warning("in variant attribute, at or before token `%s': %s", yytext, str);
+    } else {
+      loc.error("in variant attribute, at or before token `%s': %s", yytext, str);
+    }
   } else {
     // the most recently parsed token is unknown
-    loc.error("in variant attribute: %s", str);
+    if (warnings_for_bad_variants) {
+      loc.warning("in variant attribute: %s", str);
+    } else {
+      loc.error("in variant attribute: %s", str);
+    }
   }
 }
 
This page took 0.024994 seconds and 5 git commands to generate.