]> granicus.if.org Git - re2c/commitdiff
Pass context as parameter to 'yyparse' instead of a bunch of static variables.
authorUlya Trofimovich <skvadrik@gmail.com>
Thu, 22 Dec 2016 17:36:15 +0000 (17:36 +0000)
committerUlya Trofimovich <skvadrik@gmail.com>
Thu, 22 Dec 2016 17:38:38 +0000 (17:38 +0000)
As a side effect of this commit a long-standing bug with setup rules
has been fixed: re2c forgot to clean up the list of setup rules together
with other data, which resulted in false errors about duplicate setup code.

re2c/bootstrap/src/parse/lex.cc
re2c/bootstrap/src/parse/parser.cc
re2c/src/parse/parser.h
re2c/src/parse/parser.ypp
re2c/test/reuse_conds_setup_0.cgir.c
re2c/test/reuse_conds_setup_0.cgir.re
re2c/test/reuse_conds_setup_1.cgir.c
re2c/test/reuse_conds_setup_1.cgir.re

index 7f41cc589887056661f848130e5d498bccb6b41c..ff40d2b1f63383766825509dcb559a6bee339115 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.16 on Thu Dec 22 16:22:48 2016 */
+/* Generated by re2c 0.16 on Thu Dec 22 17:23:18 2016 */
 #line 1 "../src/parse/lex.re"
 #include "src/util/c99_stdint.h"
 #include <stddef.h>
index 3eb034cbeda22ca7663dbdf6ac9e8c3bda7f3ffe..c63ae9c97358a1bb29726563544aae53b2c840a6 100644 (file)
@@ -101,16 +101,11 @@ using namespace re2c;
 
 extern "C" {
 
-int yylex(Scanner &in);
-void yyerror(Scanner &in, const char*);
+int yylex(Scanner &in, context_t&);
+void yyerror(Scanner &in, context_t&, const char*);
 
 } // extern "C"
 
-static std::vector<std::string> condnames;
-static re2c::SpecMap  specMap;
-static SetupMap            ruleSetupMap;
-static symbol_table_t symbol_table;
-
 /* Bison version 1.875 emits a definition that is not working
  * with several g++ version. Hence we disable it here.
  */
@@ -118,6 +113,14 @@ static symbol_table_t symbol_table;
 #define __attribute__(x)
 #endif
 
+static void parse_cleanup(re2c::context_t &context)
+{
+       RegExp::flist.clear();
+       Range::vFreeList.clear();
+       RangeSuffix::freeList.clear();
+       context.clear();
+}
+
 static void check(const Spec &spec, const std::string &cond)
 {
        Spec::const_iterator b = spec.begin(), e = spec.end(), i, j;
@@ -165,8 +168,8 @@ static void context_check(Scanner &in, CondList *clist)
        }
 }
 
-static void make_rule(Scanner &in, CondList *clist, RegExpRule *rule,
-       Code *code, const std::string *newcond)
+static void make_rule(Scanner &in, context_t &context, CondList *clist,
+       RegExpRule *rule, Code *code, const std::string *newcond)
 {
        if (!clist) {
                clist = new CondList;
@@ -190,15 +193,16 @@ static void make_rule(Scanner &in, CondList *clist, RegExpRule *rule,
 
        for(CondList::const_iterator i = clist->begin(); i != clist->end(); ++i) {
                const std::string &cond = *i;
-               if (cond != "" && cond != "*" && specMap.find(cond) == specMap.end()) {
-                       condnames.push_back(cond);
+               if (cond != "" && cond != "*" && context.specMap.find(cond) == context.specMap.end()) {
+                       context.condnames.push_back(cond);
                }
-               specMap[cond].push_back(rule);
+               context.specMap[cond].push_back(rule);
        }
        delete clist;
 }
 
-static void make_setup(Scanner &in, CondList *clist, const Code *code)
+static void make_setup(Scanner &in, SetupMap &ruleSetupMap,
+       CondList *clist, const Code *code)
 {
        assert(clist);
        assert(code);
@@ -592,11 +596,11 @@ static const yytype_int8 yyrhs[] =
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
 static const yytype_uint16 yyrline[] =
 {
-       0,   198,   198,   200,   201,   202,   206,   213,   218,   221,
-     225,   225,   228,   232,   236,   240,   244,   248,   252,   256,
-     261,   267,   274,   275,   279,   283,   288,   293,   297,   304,
-     308,   315,   319,   326,   330,   347,   366,   370,   374,   378,
-     385,   395,   399
+       0,   204,   204,   206,   207,   208,   212,   219,   224,   227,
+     231,   231,   234,   238,   242,   246,   250,   254,   258,   262,
+     267,   273,   280,   281,   285,   289,   294,   299,   303,   310,
+     314,   321,   325,   332,   336,   353,   372,   376,   380,   384,
+     391,   401,   405
 };
 #endif
 
@@ -771,7 +775,7 @@ do                                                          \
     }                                                          \
   else                                                         \
     {                                                          \
-      yyerror (in, YY_("syntax error: cannot back up")); \
+      yyerror (in, context, YY_("syntax error: cannot back up")); \
       YYERROR;                                                 \
     }                                                          \
 while (YYID (0))
@@ -828,7 +832,7 @@ while (YYID (0))
 #ifdef YYLEX_PARAM
 # define YYLEX yylex (YYLEX_PARAM)
 #else
-# define YYLEX yylex (in)
+# define YYLEX yylex (in, context)
 #endif
 
 /* Enable debugging if requested.  */
@@ -851,7 +855,7 @@ do {                                                                          \
     {                                                                    \
       YYFPRINTF (stderr, "%s ", Title);                                          \
       yy_symbol_print (stderr,                                           \
-                 Type, Value, in); \
+                 Type, Value, in, context); \
       YYFPRINTF (stderr, "\n");                                                  \
     }                                                                    \
 } while (YYID (0))
@@ -865,19 +869,21 @@ do {                                                                        \
 #if (defined __STDC__ || defined __C99__FUNC__ \
      || defined __cplusplus || defined _MSC_VER)
 static void
-yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Scanner &in)
+yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Scanner &in, context_t &context)
 #else
 static void
-yy_symbol_value_print (yyoutput, yytype, yyvaluep, in)
+yy_symbol_value_print (yyoutput, yytype, yyvaluep, in, context)
     FILE *yyoutput;
     int yytype;
     YYSTYPE const * const yyvaluep;
     Scanner &in;
+    context_t &context;
 #endif
 {
   if (!yyvaluep)
     return;
   YYUSE (in);
+  YYUSE (context);
 # ifdef YYPRINT
   if (yytype < YYNTOKENS)
     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
@@ -899,14 +905,15 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, in)
 #if (defined __STDC__ || defined __C99__FUNC__ \
      || defined __cplusplus || defined _MSC_VER)
 static void
-yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Scanner &in)
+yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Scanner &in, context_t &context)
 #else
 static void
-yy_symbol_print (yyoutput, yytype, yyvaluep, in)
+yy_symbol_print (yyoutput, yytype, yyvaluep, in, context)
     FILE *yyoutput;
     int yytype;
     YYSTYPE const * const yyvaluep;
     Scanner &in;
+    context_t &context;
 #endif
 {
   if (yytype < YYNTOKENS)
@@ -914,7 +921,7 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, in)
   else
     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
 
-  yy_symbol_value_print (yyoutput, yytype, yyvaluep, in);
+  yy_symbol_value_print (yyoutput, yytype, yyvaluep, in, context);
   YYFPRINTF (yyoutput, ")");
 }
 
@@ -957,13 +964,14 @@ do {                                                              \
 #if (defined __STDC__ || defined __C99__FUNC__ \
      || defined __cplusplus || defined _MSC_VER)
 static void
-yy_reduce_print (YYSTYPE *yyvsp, int yyrule, Scanner &in)
+yy_reduce_print (YYSTYPE *yyvsp, int yyrule, Scanner &in, context_t &context)
 #else
 static void
-yy_reduce_print (yyvsp, yyrule, in)
+yy_reduce_print (yyvsp, yyrule, in, context)
     YYSTYPE *yyvsp;
     int yyrule;
     Scanner &in;
+    context_t &context;
 #endif
 {
   int yynrhs = yyr2[yyrule];
@@ -977,7 +985,7 @@ yy_reduce_print (yyvsp, yyrule, in)
       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
       yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
                       &(yyvsp[(yyi + 1) - (yynrhs)])
-                                      , in);
+                                      , in, context);
       YYFPRINTF (stderr, "\n");
     }
 }
@@ -985,7 +993,7 @@ yy_reduce_print (yyvsp, yyrule, in)
 # define YY_REDUCE_PRINT(Rule)         \
 do {                                   \
   if (yydebug)                         \
-    yy_reduce_print (yyvsp, Rule, in); \
+    yy_reduce_print (yyvsp, Rule, in, context); \
 } while (YYID (0))
 
 /* Nonzero means print parse trace.  It is left uninitialized so that
@@ -1236,18 +1244,20 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
 #if (defined __STDC__ || defined __C99__FUNC__ \
      || defined __cplusplus || defined _MSC_VER)
 static void
-yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, Scanner &in)
+yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, Scanner &in, context_t &context)
 #else
 static void
-yydestruct (yymsg, yytype, yyvaluep, in)
+yydestruct (yymsg, yytype, yyvaluep, in, context)
     const char *yymsg;
     int yytype;
     YYSTYPE *yyvaluep;
     Scanner &in;
+    context_t &context;
 #endif
 {
   YYUSE (yyvaluep);
   YYUSE (in);
+  YYUSE (context);
 
   if (!yymsg)
     yymsg = "Deleting";
@@ -1270,7 +1280,7 @@ int yyparse ();
 #endif
 #else /* ! YYPARSE_PARAM */
 #if defined __STDC__ || defined __cplusplus
-int yyparse (Scanner &in);
+int yyparse (Scanner &in, context_t &context);
 #else
 int yyparse ();
 #endif
@@ -1306,11 +1316,12 @@ yyparse (YYPARSE_PARAM)
 #if (defined __STDC__ || defined __C99__FUNC__ \
      || defined __cplusplus || defined _MSC_VER)
 int
-yyparse (Scanner &in)
+yyparse (Scanner &in, context_t &context)
 #else
 int
-yyparse (in)
+yyparse (in, context)
     Scanner &in;
+    context_t &context;
 #endif
 #endif
 {
@@ -1558,7 +1569,7 @@ yyreduce:
         case 6:
 
     {
-               if (!symbol_table.insert(std::make_pair(*(yyvsp[(1) - (3)].str), (yyvsp[(2) - (3)].regexp))).second) {
+               if (!context.symbol_table.insert(std::make_pair(*(yyvsp[(1) - (3)].str), (yyvsp[(2) - (3)].regexp))).second) {
                        in.fatal("sym already defined");
                }
                delete (yyvsp[(1) - (3)].str);
@@ -1589,56 +1600,56 @@ yyreduce:
   case 12:
 
     {
-               make_rule(in, NULL, (yyvsp[(1) - (2)].rule), (yyvsp[(2) - (2)].code), NULL);
+               make_rule(in, context, NULL, (yyvsp[(1) - (2)].rule), (yyvsp[(2) - (2)].code), NULL);
        ;}
     break;
 
   case 13:
 
     {
-               make_rule(in, (yyvsp[(2) - (5)].clist), (yyvsp[(4) - (5)].rule), (yyvsp[(5) - (5)].code), NULL);
+               make_rule(in, context, (yyvsp[(2) - (5)].clist), (yyvsp[(4) - (5)].rule), (yyvsp[(5) - (5)].code), NULL);
        ;}
     break;
 
   case 14:
 
     {
-               make_rule(in, (yyvsp[(2) - (8)].clist), (yyvsp[(4) - (8)].rule), (yyvsp[(8) - (8)].code), (yyvsp[(7) - (8)].str));
+               make_rule(in, context, (yyvsp[(2) - (8)].clist), (yyvsp[(4) - (8)].rule), (yyvsp[(8) - (8)].code), (yyvsp[(7) - (8)].str));
        ;}
     break;
 
   case 15:
 
     {
-               make_rule(in, (yyvsp[(2) - (8)].clist), (yyvsp[(4) - (8)].rule), NULL, (yyvsp[(8) - (8)].str));
+               make_rule(in, context, (yyvsp[(2) - (8)].clist), (yyvsp[(4) - (8)].rule), NULL, (yyvsp[(8) - (8)].str));
        ;}
     break;
 
   case 16:
 
     {
-               make_rule(in, NULL, NULL, (yyvsp[(3) - (3)].code), NULL);
+               make_rule(in, context, NULL, NULL, (yyvsp[(3) - (3)].code), NULL);
        ;}
     break;
 
   case 17:
 
     {
-               make_rule(in, NULL, NULL, (yyvsp[(6) - (6)].code), (yyvsp[(5) - (6)].str));
+               make_rule(in, context, NULL, NULL, (yyvsp[(6) - (6)].code), (yyvsp[(5) - (6)].str));
        ;}
     break;
 
   case 18:
 
     {
-               make_rule(in, NULL, NULL, NULL, (yyvsp[(6) - (6)].str));
+               make_rule(in, context, NULL, NULL, NULL, (yyvsp[(6) - (6)].str));
        ;}
     break;
 
   case 19:
 
     {
-               make_setup(in, (yyvsp[(3) - (5)].clist), (yyvsp[(5) - (5)].code));
+               make_setup(in, context.ruleSetupMap, (yyvsp[(3) - (5)].clist), (yyvsp[(5) - (5)].code));
        ;}
     break;
 
@@ -1806,9 +1817,9 @@ yyreduce:
   case 40:
 
     {
-                       symbol_table_t::iterator i = symbol_table.find (* (yyvsp[(1) - (1)].str));
+                       symbol_table_t::iterator i = context.symbol_table.find (* (yyvsp[(1) - (1)].str));
                        delete (yyvsp[(1) - (1)].str);
-                       if (i == symbol_table.end ())
+                       if (i == context.symbol_table.end ())
                        {
                                in.fatal("can't find symbol");
                        }
@@ -1866,7 +1877,7 @@ yyerrlab:
     {
       ++yynerrs;
 #if ! YYERROR_VERBOSE
-      yyerror (in, YY_("syntax error"));
+      yyerror (in, context, YY_("syntax error"));
 #else
       {
        YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
@@ -1890,11 +1901,11 @@ yyerrlab:
        if (0 < yysize && yysize <= yymsg_alloc)
          {
            (void) yysyntax_error (yymsg, yystate, yychar);
-           yyerror (in, yymsg);
+           yyerror (in, context, yymsg);
          }
        else
          {
-           yyerror (in, YY_("syntax error"));
+           yyerror (in, context, YY_("syntax error"));
            if (yysize != 0)
              goto yyexhaustedlab;
          }
@@ -1918,7 +1929,7 @@ yyerrlab:
       else
        {
          yydestruct ("Error: discarding",
-                     yytoken, &yylval, in);
+                     yytoken, &yylval, in, context);
          yychar = YYEMPTY;
        }
     }
@@ -1974,7 +1985,7 @@ yyerrlab1:
 
 
       yydestruct ("Error: popping",
-                 yystos[yystate], yyvsp, in);
+                 yystos[yystate], yyvsp, in, context);
       YYPOPSTACK (1);
       yystate = *yyssp;
       YY_STACK_PRINT (yyss, yyssp);
@@ -2009,7 +2020,7 @@ yyabortlab:
 | yyexhaustedlab -- memory exhaustion comes here.  |
 `-------------------------------------------------*/
 yyexhaustedlab:
-  yyerror (in, YY_("memory exhausted"));
+  yyerror (in, context, YY_("memory exhausted"));
   yyresult = 2;
   /* Fall through.  */
 #endif
@@ -2017,7 +2028,7 @@ yyexhaustedlab:
 yyreturn:
   if (yychar != YYEMPTY)
      yydestruct ("Cleanup: discarding lookahead",
-                yytoken, &yylval, in);
+                yytoken, &yylval, in, context);
   /* Do not reclaim the symbols of the rule which action triggered
      this YYABORT or YYACCEPT.  */
   YYPOPSTACK (yylen);
@@ -2025,7 +2036,7 @@ yyreturn:
   while (yyssp != yyss)
     {
       yydestruct ("Cleanup: popping",
-                 yystos[*yyssp], yyvsp, in);
+                 yystos[*yyssp], yyvsp, in, context);
       YYPOPSTACK (1);
     }
 #ifndef yyoverflow
@@ -2046,12 +2057,12 @@ yyreturn:
 
 extern "C" {
 
-void yyerror(Scanner &in, const char* s)
+void yyerror(Scanner &in, context_t&, const char* s)
 {
        in.fatal(s);
 }
 
-int yylex(Scanner &in)
+int yylex(Scanner &in, context_t&)
 {
        return in.scan();
 }
@@ -2064,6 +2075,7 @@ namespace re2c
 void parse(Scanner &in, Output & o)
 {
        dfa_map_t dfa_map;
+       context_t context;
        ScannerState rules_state, curr_state;
        Opt &opts = in.opts;
 
@@ -2099,51 +2111,51 @@ void parse(Scanner &in, Output & o)
                {
                        dfa_map.clear();
                }
-               specMap.clear();
-               yyparse(in);
+               context.specMap.clear();
+               yyparse(in, context);
                if (opts->rFlag && mode == Scanner::Reuse) {
-                       if (!specMap.empty() || opts->encoding != encodingOld) {
+                       if (!context.specMap.empty() || opts->encoding != encodingOld) {
                                // Re-parse rules
                                mode = Scanner::Parse;
                                in.restore_state(rules_state);
                                in.reuse();
                                dfa_map.clear();
-                               parse_cleanup();
-                               specMap.clear();
-                               yyparse(in);
+                               parse_cleanup(context);
+                               context.specMap.clear();
+                               yyparse(in, context);
 
                                // Now append potential new rules
                                in.restore_state(curr_state);
                                mode = Scanner::Parse;
-                               yyparse(in);
+                               yyparse(in, context);
                        }
                        encodingOld = opts->encoding;
                }
 
                o.source.block().line = in.get_cline();
-               o.source.block().types = condnames;
+               o.source.block().types = context.condnames;
 
                // compile regular expressions to automata
                if (mode != Scanner::Reuse) {
                        SpecMap::iterator it;
-                       for (it = specMap.begin(); it != specMap.end(); ++it) {
+                       for (it = context.specMap.begin(); it != context.specMap.end(); ++it) {
                                check(it->second, it->first);
                        }
 
                        // merge <*> rules to all conditions except "0" with lowest priority
                        Spec star;
-                       if ((it = specMap.find("*")) != specMap.end()) {
+                       if ((it = context.specMap.find("*")) != context.specMap.end()) {
                                star = it->second;
-                               specMap.erase(it);
+                               context.specMap.erase(it);
                        }
-                       for (it = specMap.begin(); it != specMap.end(); ++it) {
+                       for (it = context.specMap.begin(); it != context.specMap.end(); ++it) {
                                if (it->first == "0") continue;
                                for (size_t j = 0; j < star.size(); ++j) {
                                        it->second.push_back(star[j]);
                                }
                        }
 
-                       for (it = specMap.begin(); it != specMap.end(); ++it) {
+                       for (it = context.specMap.begin(); it != context.specMap.end(); ++it) {
                                delay_default(it->second);
                                dfa_map[it->first] = compile(it->second, o, it->first, opts->encoding.nCodeUnits ());
                        }
@@ -2154,7 +2166,7 @@ void parse(Scanner &in, Output & o)
                        uint32_t ind = opts->topIndent;
                        size_t nCount = dfa_map.size();
                        for (dfa_map_t::const_iterator i = dfa_map.begin(); i != dfa_map.end(); ++i) {
-                               o.source.block().setup_rule = find_setup_rule(ruleSetupMap, i->first);
+                               o.source.block().setup_rule = find_setup_rule(context.ruleSetupMap, i->first);
                                i->second->emit(o, ind, !--nCount, bPrologBrace);
                        }
                }
@@ -2165,15 +2177,15 @@ void parse(Scanner &in, Output & o)
        }
 
        SetupMap::const_iterator itRuleSetup;
-       for (itRuleSetup = ruleSetupMap.begin(); itRuleSetup != ruleSetupMap.end(); ++itRuleSetup) {
-               if (itRuleSetup->first != "*" && specMap.find(itRuleSetup->first) == specMap.end()) {
+       for (itRuleSetup = context.ruleSetupMap.begin(); itRuleSetup != context.ruleSetupMap.end(); ++itRuleSetup) {
+               if (itRuleSetup->first != "*" && context.specMap.find(itRuleSetup->first) == context.specMap.end()) {
                        in.fatalf_at(itRuleSetup->second.first, "setup for non existing rule '%s' found", itRuleSetup->first.c_str());
                }
        }
-       if (specMap.size() < ruleSetupMap.size()) {
+       if (context.specMap.size() < context.ruleSetupMap.size()) {
                uint32_t line = in.get_cline();
-               itRuleSetup = ruleSetupMap.find("*");
-               if (itRuleSetup != ruleSetupMap.end()) {
+               itRuleSetup = context.ruleSetupMap.find("*");
+               if (itRuleSetup != context.ruleSetupMap.end()) {
                        line = itRuleSetup->second.first;
                }
                in.fatalf_at(line, "setup for all rules with '*' not possible when all rules are setup explicitly");
@@ -2184,17 +2196,7 @@ void parse(Scanner &in, Output & o)
                emit_epilog (o.source, o.skeletons);
        }
 
-       parse_cleanup();
-}
-
-void parse_cleanup()
-{
-       RegExp::flist.clear();
-       Range::vFreeList.clear();
-       RangeSuffix::freeList.clear();
-       symbol_table.clear ();
-       condnames.clear ();
-       specMap.clear();
+       parse_cleanup(context);
 }
 
 } // end namespace re2c
index 23d4fbf646c2303eb59e751abb3804c4f73e9272..cf17d6267ae6ca7038ce6ac66ab92eb3661db6a4 100644 (file)
@@ -14,8 +14,7 @@ namespace re2c
 
 struct DFA;
 
-extern void parse(Scanner &, Output &);
-extern void parse_cleanup();
+void parse(Scanner &, Output &);
 
 typedef std::set<std::string> CondList;
 typedef std::vector<const RegExpRule*> Spec;
@@ -24,6 +23,28 @@ typedef std::map<std::string, std::pair<uint32_t, std::string> > SetupMap;
 typedef std::map<std::string, const RegExp *> symbol_table_t;
 typedef std::map<std::string, smart_ptr<DFA> > dfa_map_t;
 
+struct context_t
+{
+       std::vector<std::string> condnames;
+       SpecMap specMap;
+       SetupMap ruleSetupMap;
+       symbol_table_t symbol_table;
+
+       context_t()
+               : condnames()
+               , specMap()
+               , ruleSetupMap()
+               , symbol_table()
+       {}
+       void clear()
+       {
+               condnames.clear();
+               specMap.clear();
+               ruleSetupMap.clear();
+               symbol_table.clear();
+       }
+};
+
 } // namespace re2c
 
 #endif // _RE2C_PARSE_PARSER_
index 35375adafe64d4d196d8680d1cbfe083466884fc..de836f2a4e3e2d115141a0ff6504adbaa5851ffa 100644 (file)
@@ -33,16 +33,11 @@ using namespace re2c;
 
 extern "C" {
 
-int yylex(Scanner &in);
-void yyerror(Scanner &in, const char*);
+int yylex(Scanner &in, context_t&);
+void yyerror(Scanner &in, context_t&, const char*);
 
 } // extern "C"
 
-static std::vector<std::string> condnames;
-static re2c::SpecMap  specMap;
-static SetupMap            ruleSetupMap;
-static symbol_table_t symbol_table;
-
 /* Bison version 1.875 emits a definition that is not working
  * with several g++ version. Hence we disable it here.
  */
@@ -50,6 +45,14 @@ static symbol_table_t symbol_table;
 #define __attribute__(x)
 #endif
 
+static void parse_cleanup(re2c::context_t &context)
+{
+       RegExp::flist.clear();
+       Range::vFreeList.clear();
+       RangeSuffix::freeList.clear();
+       context.clear();
+}
+
 static void check(const Spec &spec, const std::string &cond)
 {
        Spec::const_iterator b = spec.begin(), e = spec.end(), i, j;
@@ -97,8 +100,8 @@ static void context_check(Scanner &in, CondList *clist)
        }
 }
 
-static void make_rule(Scanner &in, CondList *clist, RegExpRule *rule,
-       Code *code, const std::string *newcond)
+static void make_rule(Scanner &in, context_t &context, CondList *clist,
+       RegExpRule *rule, Code *code, const std::string *newcond)
 {
        if (!clist) {
                clist = new CondList;
@@ -122,15 +125,16 @@ static void make_rule(Scanner &in, CondList *clist, RegExpRule *rule,
 
        for(CondList::const_iterator i = clist->begin(); i != clist->end(); ++i) {
                const std::string &cond = *i;
-               if (cond != "" && cond != "*" && specMap.find(cond) == specMap.end()) {
-                       condnames.push_back(cond);
+               if (cond != "" && cond != "*" && context.specMap.find(cond) == context.specMap.end()) {
+                       context.condnames.push_back(cond);
                }
-               specMap[cond].push_back(rule);
+               context.specMap[cond].push_back(rule);
        }
        delete clist;
 }
 
-static void make_setup(Scanner &in, CondList *clist, const Code *code)
+static void make_setup(Scanner &in, SetupMap &ruleSetupMap,
+       CondList *clist, const Code *code)
 {
        assert(clist);
        assert(code);
@@ -164,6 +168,8 @@ static std::string find_setup_rule(const SetupMap &map, const std::string &key)
 
 %lex-param   {Scanner &in}
 %parse-param {Scanner &in}
+%lex-param   {context_t &context}
+%parse-param {context_t &context}
 
 %union {
        const re2c::RegExp * regexp;
@@ -204,7 +210,7 @@ spec
 
 def
        : name expr enddef {
-               if (!symbol_table.insert(std::make_pair(*$1, $2)).second) {
+               if (!context.symbol_table.insert(std::make_pair(*$1, $2)).second) {
                        in.fatal("sym already defined");
                }
                delete $1;
@@ -226,35 +232,35 @@ enddef: ';' | TOKEN_FID_END;
 
 rule
        : trailexpr TOKEN_CODE {
-               make_rule(in, NULL, $1, $2, NULL);
+               make_rule(in, context, NULL, $1, $2, NULL);
        }
 
        | '<' clist '>' trailexpr TOKEN_CODE {
-               make_rule(in, $2, $4, $5, NULL);
+               make_rule(in, context, $2, $4, $5, NULL);
        }
 
        | '<' clist '>' trailexpr '=' '>' TOKEN_ID TOKEN_CODE {
-               make_rule(in, $2, $4, $8, $7);
+               make_rule(in, context, $2, $4, $8, $7);
        }
 
        | '<' clist '>' trailexpr ':' '=' '>' TOKEN_ID {
-               make_rule(in, $2, $4, NULL, $8);
+               make_rule(in, context, $2, $4, NULL, $8);
        }
 
        | '<' '>' TOKEN_CODE {
-               make_rule(in, NULL, NULL, $3, NULL);
+               make_rule(in, context, NULL, NULL, $3, NULL);
        }
 
        | '<' '>' '=' '>' TOKEN_ID TOKEN_CODE {
-               make_rule(in, NULL, NULL, $6, $5);
+               make_rule(in, context, NULL, NULL, $6, $5);
        }
 
        | '<' '>' ':' '=' '>' TOKEN_ID {
-               make_rule(in, NULL, NULL, NULL, $6);
+               make_rule(in, context, NULL, NULL, NULL, $6);
        }
 
        | '<' '!' clist '>' TOKEN_CODE {
-               make_setup(in, $3, $5);
+               make_setup(in, context.ruleSetupMap, $3, $5);
        };
 
 clist
@@ -384,9 +390,9 @@ close:
 primary:
                TOKEN_ID
                {
-                       symbol_table_t::iterator i = symbol_table.find (* $1);
+                       symbol_table_t::iterator i = context.symbol_table.find (* $1);
                        delete $1;
-                       if (i == symbol_table.end ())
+                       if (i == context.symbol_table.end ())
                        {
                                in.fatal("can't find symbol");
                        }
@@ -406,12 +412,12 @@ primary:
 
 extern "C" {
 
-void yyerror(Scanner &in, const char* s)
+void yyerror(Scanner &in, context_t&, const char* s)
 {
        in.fatal(s);
 }
 
-int yylex(Scanner &in)
+int yylex(Scanner &in, context_t&)
 {
        return in.scan();
 }
@@ -424,6 +430,7 @@ namespace re2c
 void parse(Scanner &in, Output & o)
 {
        dfa_map_t dfa_map;
+       context_t context;
        ScannerState rules_state, curr_state;
        Opt &opts = in.opts;
 
@@ -459,51 +466,51 @@ void parse(Scanner &in, Output & o)
                {
                        dfa_map.clear();
                }
-               specMap.clear();
-               yyparse(in);
+               context.specMap.clear();
+               yyparse(in, context);
                if (opts->rFlag && mode == Scanner::Reuse) {
-                       if (!specMap.empty() || opts->encoding != encodingOld) {
+                       if (!context.specMap.empty() || opts->encoding != encodingOld) {
                                // Re-parse rules
                                mode = Scanner::Parse;
                                in.restore_state(rules_state);
                                in.reuse();
                                dfa_map.clear();
-                               parse_cleanup();
-                               specMap.clear();
-                               yyparse(in);
+                               parse_cleanup(context);
+                               context.specMap.clear();
+                               yyparse(in, context);
 
                                // Now append potential new rules
                                in.restore_state(curr_state);
                                mode = Scanner::Parse;
-                               yyparse(in);
+                               yyparse(in, context);
                        }
                        encodingOld = opts->encoding;
                }
 
                o.source.block().line = in.get_cline();
-               o.source.block().types = condnames;
+               o.source.block().types = context.condnames;
 
                // compile regular expressions to automata
                if (mode != Scanner::Reuse) {
                        SpecMap::iterator it;
-                       for (it = specMap.begin(); it != specMap.end(); ++it) {
+                       for (it = context.specMap.begin(); it != context.specMap.end(); ++it) {
                                check(it->second, it->first);
                        }
 
                        // merge <*> rules to all conditions except "0" with lowest priority
                        Spec star;
-                       if ((it = specMap.find("*")) != specMap.end()) {
+                       if ((it = context.specMap.find("*")) != context.specMap.end()) {
                                star = it->second;
-                               specMap.erase(it);
+                               context.specMap.erase(it);
                        }
-                       for (it = specMap.begin(); it != specMap.end(); ++it) {
+                       for (it = context.specMap.begin(); it != context.specMap.end(); ++it) {
                                if (it->first == "0") continue;
                                for (size_t j = 0; j < star.size(); ++j) {
                                        it->second.push_back(star[j]);
                                }
                        }
 
-                       for (it = specMap.begin(); it != specMap.end(); ++it) {
+                       for (it = context.specMap.begin(); it != context.specMap.end(); ++it) {
                                delay_default(it->second);
                                dfa_map[it->first] = compile(it->second, o, it->first, opts->encoding.nCodeUnits ());
                        }
@@ -514,7 +521,7 @@ void parse(Scanner &in, Output & o)
                        uint32_t ind = opts->topIndent;
                        size_t nCount = dfa_map.size();
                        for (dfa_map_t::const_iterator i = dfa_map.begin(); i != dfa_map.end(); ++i) {
-                               o.source.block().setup_rule = find_setup_rule(ruleSetupMap, i->first);
+                               o.source.block().setup_rule = find_setup_rule(context.ruleSetupMap, i->first);
                                i->second->emit(o, ind, !--nCount, bPrologBrace);
                        }
                }
@@ -525,15 +532,15 @@ void parse(Scanner &in, Output & o)
        }
 
        SetupMap::const_iterator itRuleSetup;
-       for (itRuleSetup = ruleSetupMap.begin(); itRuleSetup != ruleSetupMap.end(); ++itRuleSetup) {
-               if (itRuleSetup->first != "*" && specMap.find(itRuleSetup->first) == specMap.end()) {
+       for (itRuleSetup = context.ruleSetupMap.begin(); itRuleSetup != context.ruleSetupMap.end(); ++itRuleSetup) {
+               if (itRuleSetup->first != "*" && context.specMap.find(itRuleSetup->first) == context.specMap.end()) {
                        in.fatalf_at(itRuleSetup->second.first, "setup for non existing rule '%s' found", itRuleSetup->first.c_str());
                }
        }
-       if (specMap.size() < ruleSetupMap.size()) {
+       if (context.specMap.size() < context.ruleSetupMap.size()) {
                uint32_t line = in.get_cline();
-               itRuleSetup = ruleSetupMap.find("*");
-               if (itRuleSetup != ruleSetupMap.end()) {
+               itRuleSetup = context.ruleSetupMap.find("*");
+               if (itRuleSetup != context.ruleSetupMap.end()) {
                        line = itRuleSetup->second.first;
                }
                in.fatalf_at(line, "setup for all rules with '*' not possible when all rules are setup explicitly");
@@ -544,17 +551,7 @@ void parse(Scanner &in, Output & o)
                emit_epilog (o.source, o.skeletons);
        }
 
-       parse_cleanup();
-}
-
-void parse_cleanup()
-{
-       RegExp::flist.clear();
-       Range::vFreeList.clear();
-       RangeSuffix::freeList.clear();
-       symbol_table.clear ();
-       condnames.clear ();
-       specMap.clear();
+       parse_cleanup(context);
 }
 
 } // end namespace re2c
index 47807d229a73dd38f12995bd9b8b619f5f88b162..987e6f27e8341a8d8ee6d1dd6be59d8ac9062c03 100644 (file)
@@ -1,3 +1,195 @@
-re2c: warning: line 10: control flow in condition 'r1' is undefined for strings that match '\xA', use default rule '*' [-Wundefined-control-flow]
-re2c: warning: line 10: control flow in condition 'r2' is undefined for strings that match '\xA', use default rule '*' [-Wundefined-control-flow]
-re2c: error: line 13, column 9: code to setup rule 'r1' is already defined
+/* Generated by re2c */
+
+
+
+
+{
+       YYCTYPE yych;
+       static void *yyctable[2] = {
+               &&yyc_r1,
+               &&yyc_r2,
+       };
+       goto *yyctable[YYGETCONDITION()];
+/* *********************************** */
+yyc_r1:
+       if (YYLIMIT <= YYCURSOR) YYFILL(1);
+       yych = *YYCURSOR;
+       {
+               static void *yytarget[256] = {
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy3,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy6,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy8,  &&yy10, &&yy12, &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4
+               };
+               goto *yytarget[yych];
+       }
+yy3:
+yy4:
+       ++YYCURSOR;
+       { return "SETUP - r1"; }
+       { return "."; }
+yy6:
+       ++YYCURSOR;
+       { return "SETUP - r1"; }
+       { return "1"; }
+yy8:
+       ++YYCURSOR;
+       { return "SETUP - r1"; }
+       { return "a"; }
+yy10:
+       ++YYCURSOR;
+       { return "SETUP - r1"; }
+       { return "b"; }
+yy12:
+       ++YYCURSOR;
+       { return "SETUP - r1"; }
+       { return "c"; }
+/* *********************************** */
+yyc_r2:
+       if (YYLIMIT <= YYCURSOR) YYFILL(1);
+       yych = *YYCURSOR;
+       if (yych <= '`') {
+               if (yych != '\n') goto yy17;
+       } else {
+               if (yych <= 'a') goto yy19;
+               if (yych == 'c') goto yy21;
+               goto yy17;
+       }
+yy17:
+       ++YYCURSOR;
+       { return "."; }
+yy19:
+       ++YYCURSOR;
+       { return "a"; }
+yy21:
+       ++YYCURSOR;
+       { return "c"; }
+}
+
+
+
+{
+       YYCTYPE yych;
+       static void *yyctable[2] = {
+               &&yyc_r1,
+               &&yyc_r2,
+       };
+       goto *yyctable[YYGETCONDITION()];
+/* *********************************** */
+yyc_r1:
+       if (YYLIMIT <= YYCURSOR) YYFILL(1);
+       yych = *YYCURSOR;
+       {
+               static void *yytarget[256] = {
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy3,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy6,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy8,  &&yy10, &&yy12, &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4
+               };
+               goto *yytarget[yych];
+       }
+yy3:
+yy4:
+       ++YYCURSOR;
+       { return "."; }
+yy6:
+       ++YYCURSOR;
+       { return "2"; }
+yy8:
+       ++YYCURSOR;
+       { return "a"; }
+yy10:
+       ++YYCURSOR;
+       { return "b"; }
+yy12:
+       ++YYCURSOR;
+       { return "c"; }
+/* *********************************** */
+yyc_r2:
+       if (YYLIMIT <= YYCURSOR) YYFILL(1);
+       yych = *YYCURSOR;
+       if (yych <= '`') {
+               if (yych != '\n') goto yy17;
+       } else {
+               if (yych <= 'a') goto yy19;
+               if (yych == 'c') goto yy21;
+               goto yy17;
+       }
+yy17:
+       ++YYCURSOR;
+       { return "SETUP - r2"; }
+       { return "."; }
+yy19:
+       ++YYCURSOR;
+       { return "SETUP - r2"; }
+       { return "a"; }
+yy21:
+       ++YYCURSOR;
+       { return "SETUP - r2"; }
+       { return "c"; }
+}
+
+re2c: warning: line 7: control flow in condition 'r1' is undefined for strings that match '\xA', use default rule '*' [-Wundefined-control-flow]
+re2c: warning: line 7: control flow in condition 'r2' is undefined for strings that match '\xA', use default rule '*' [-Wundefined-control-flow]
+re2c: warning: line 12: control flow in condition 'r1' is undefined for strings that match '\xA', use default rule '*' [-Wundefined-control-flow]
+re2c: warning: line 12: control flow in condition 'r2' is undefined for strings that match '\xA', use default rule '*' [-Wundefined-control-flow]
+re2c: warning: line 17: control flow in condition 'r1' is undefined for strings that match '\xA', use default rule '*' [-Wundefined-control-flow]
+re2c: warning: line 17: control flow in condition 'r2' is undefined for strings that match '\xA', use default rule '*' [-Wundefined-control-flow]
+re2c: warning: line 12: looks like you use hardcoded numbers instead of autogenerated condition names: better add '/*!types:re2c*/' directive or '-t, --type-header' option and don't rely on fixed condition order. [-Wcondition-order]
+re2c: warning: line 17: looks like you use hardcoded numbers instead of autogenerated condition names: better add '/*!types:re2c*/' directive or '-t, --type-header' option and don't rely on fixed condition order. [-Wcondition-order]
index a52b7e839e05c3a806c504f80f9ad6bef994da8c..21be4db4e1b6c747061663136df922dd1ff22e69 100644 (file)
@@ -1,6 +1,3 @@
-// This test currently fails with error
-// 're2c: error: line 13, column 9: code to setup rule 'r1' is already defined'
-// This must be fixed later
 
 /*!rules:re2c
        <*>     "a"     { return "a"; }
@@ -14,7 +11,7 @@
        <r1>    "1"     { return "1"; }
 */
 
-/* !use:re2c
+/*!use:re2c
        <!r2>           { return "SETUP - r2"; }
        <r1>    "2"     { return "2"; }
 */
index f39bb25e6033d3df614f15dbab2e2763ab9018a2..d6c7a4dfb19d3161e2ae675e8c410da10df926c5 100644 (file)
@@ -1,3 +1,209 @@
-re2c: warning: line 17: control flow in condition 'r1' is undefined for strings that match '\xA', use default rule '*' [-Wundefined-control-flow]
-re2c: warning: line 17: control flow in condition 'r2' is undefined for strings that match '\xA', use default rule '*' [-Wundefined-control-flow]
-re2c: error: line 11, column 9: code to setup rule 'r1' is already defined
+/* Generated by re2c */
+
+enum YYCONDTYPE {
+       yycr1,
+       yycr2,
+};
+
+
+void scan(unsigned char* in)
+{
+
+{
+       YYCTYPE yych;
+       static void *yyctable[2] = {
+               &&yyc_r1,
+               &&yyc_r2,
+       };
+       goto *yyctable[YYGETCONDITION()];
+/* *********************************** */
+yyc_r1:
+       if (YYLIMIT <= YYCURSOR) YYFILL(1);
+       yych = *YYCURSOR;
+       {
+               static void *yytarget[256] = {
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy3,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy6,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy8,  &&yy10, &&yy12, &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4
+               };
+               goto *yytarget[yych];
+       }
+yy3:
+yy4:
+       ++YYCURSOR;
+       { return "SETUP-r1"; }
+       { return "."; }
+yy6:
+       ++YYCURSOR;
+       { return "SETUP-r1"; }
+       { return "1"; }
+yy8:
+       ++YYCURSOR;
+       { return "SETUP-r1"; }
+       { return "a"; }
+yy10:
+       ++YYCURSOR;
+       { return "SETUP-r1"; }
+       { return "b"; }
+yy12:
+       ++YYCURSOR;
+       { return "SETUP-r1"; }
+       { return "c"; }
+/* *********************************** */
+yyc_r2:
+       if (YYLIMIT <= YYCURSOR) YYFILL(1);
+       yych = *YYCURSOR;
+       if (yych <= '`') {
+               if (yych != '\n') goto yy17;
+       } else {
+               if (yych <= 'a') goto yy19;
+               if (yych == 'c') goto yy21;
+               goto yy17;
+       }
+yy17:
+       ++YYCURSOR;
+       { return "SETUP-r2"; }
+       { return "."; }
+yy19:
+       ++YYCURSOR;
+       { return "SETUP-r2"; }
+       { return "a"; }
+yy21:
+       ++YYCURSOR;
+       { return "SETUP-r2"; }
+       { return "c"; }
+}
+
+
+}
+
+void scan(unsigned short* in)
+{
+
+{
+       YYCTYPE yych;
+       static void *yyctable[2] = {
+               &&yyc_r1,
+               &&yyc_r2,
+       };
+       goto *yyctable[YYGETCONDITION()];
+/* *********************************** */
+yyc_r1:
+       if (YYLIMIT <= YYCURSOR) YYFILL(1);
+       yych = *YYCURSOR;
+       {
+               static void *yytarget[256] = {
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy3,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy6,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy8,  &&yy10, &&yy12, &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,
+                       &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4,  &&yy4
+               };
+               goto *yytarget[yych];
+       }
+yy3:
+yy4:
+       ++YYCURSOR;
+       { return "SETUP-r1"; }
+       { return "."; }
+yy6:
+       ++YYCURSOR;
+       { return "SETUP-r1"; }
+       { return "2"; }
+yy8:
+       ++YYCURSOR;
+       { return "SETUP-r1"; }
+       { return "a"; }
+yy10:
+       ++YYCURSOR;
+       { return "SETUP-r1"; }
+       { return "b"; }
+yy12:
+       ++YYCURSOR;
+       { return "SETUP-r1"; }
+       { return "c"; }
+/* *********************************** */
+yyc_r2:
+       if (YYLIMIT <= YYCURSOR) YYFILL(1);
+       yych = *YYCURSOR;
+       if (yych <= '`') {
+               if (yych != '\n') goto yy17;
+       } else {
+               if (yych <= 'a') goto yy19;
+               if (yych == 'c') goto yy21;
+               goto yy17;
+       }
+yy17:
+       ++YYCURSOR;
+       { return "."; }
+yy19:
+       ++YYCURSOR;
+       { return "a"; }
+yy21:
+       ++YYCURSOR;
+       { return "c"; }
+}
+
+}
+re2c: warning: line 14: control flow in condition 'r1' is undefined for strings that match '\xA', use default rule '*' [-Wundefined-control-flow]
+re2c: warning: line 14: control flow in condition 'r2' is undefined for strings that match '\xA', use default rule '*' [-Wundefined-control-flow]
+re2c: warning: line 19: control flow in condition 'r1' is undefined for strings that match '\xA', use default rule '*' [-Wundefined-control-flow]
+re2c: warning: line 19: control flow in condition 'r2' is undefined for strings that match '\xA', use default rule '*' [-Wundefined-control-flow]
+re2c: warning: line 29: control flow in condition 'r1' is undefined for strings that match '\xA', use default rule '*' [-Wundefined-control-flow]
+re2c: warning: line 29: control flow in condition 'r2' is undefined for strings that match '\xA', use default rule '*' [-Wundefined-control-flow]
index 148a518724c3c43810da75b7dbba5b0af54d47a0..44e918ddee0f873e8e9524bc28e150ee6fe77f55 100644 (file)
@@ -1,6 +1,3 @@
-// This test currently fails with error
-// 're2c: error: line 11, column 9: code to setup rule 'r1' is already defined'
-// This must be fixed later
 
 /*!types:re2c */