]> granicus.if.org Git - re2c/commitdiff
Fix "CODE" symbol collision on OS X (see #122)
authorOleksii Taran <oleksii.taran@gmail.com>
Sat, 28 Nov 2015 04:08:09 +0000 (20:08 -0800)
committerUlya Trofimovich <skvadrik@gmail.com>
Sat, 28 Nov 2015 10:52:47 +0000 (10:52 +0000)
On OS X bison generates token enums as CPP macro
constants (y.tab.h):
    #define CODE 260
while on my box it's
   enum yytokentype {
     ...
     CODE = 260,
     ...
   };

That #define causes symbol collision as:

    ../src/parse/lex.re:169:38: error: expected unqualified-id
                                            else if (opts->target == opt_t::CODE)
                                                                            ^
    src/parse/y.tab.h:58:14: note: expanded from macro 'CODE'
    #define CODE 260

Renamed enum entry to TOKEN_CODE.

re2c/bootstrap/src/parse/lex.cc
re2c/bootstrap/src/parse/parser.cc
re2c/bootstrap/src/parse/y.tab.h
re2c/src/parse/lex.re
re2c/src/parse/parser.ypp

index f62533f28ca112d896f901eb60fda7090ed8757e..634a68ba5b4f76309345f82bd1bd646c14d2a75d 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.15.2 on Fri Nov 27 14:24:13 2015*/
+/* Generated by re2c 0.15.2 on Sat Nov 28 10:47:09 2015*/
 #line 1 "../src/parse/lex.re"
 #include <stdlib.h>
 #include <string.h>
@@ -1448,7 +1448,7 @@ yy236:
                                                        --cur;
                                                }
                                                yylval.code = new Code (tok, tok_len (), get_fname (), tline);
-                                               return CODE;
+                                               return TOKEN_CODE;
                                        }
                                        else if (cur == eof)
                                        {
@@ -1495,7 +1495,7 @@ yy241:
                                        else if (--depth == 0)
                                        {
                                                yylval.code = new Code (tok, tok_len (), get_fname (), tline);
-                                               return CODE;
+                                               return TOKEN_CODE;
                                        }
                                        goto code;
                                }
index 914f7951110f7df1810eb6b615c483c17631becc..6318628b1ceb6bfee98f774cbbc3f84e0b214dd6 100644 (file)
@@ -242,7 +242,7 @@ void default_rule(CondList *clist, const Code * code)
    enum yytokentype {
      CLOSE = 258,
      CLOSESIZE = 259,
-     CODE = 260,
+     TOKEN_CODE = 260,
      CONF = 261,
      ID = 262,
      FID = 263,
@@ -596,11 +596,11 @@ static const yytype_uint16 yyrline[] =
    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
 static const char *const yytname[] =
 {
-  "$end", "error", "$undefined", "CLOSE", "CLOSESIZE", "CODE", "CONF",
-  "ID", "FID", "FID_END", "NOCOND", "REGEXP", "SETUP", "STAR", "'='",
-  "';'", "'/'", "'<'", "'>'", "':'", "','", "'|'", "'\\\\'", "'('", "')'",
-  "$accept", "spec", "decl", "rule", "cond", "clist", "newcond", "look",
-  "expr", "diff", "term", "factor", "close", "primary", 0
+  "$end", "error", "$undefined", "CLOSE", "CLOSESIZE", "TOKEN_CODE",
+  "CONF", "ID", "FID", "FID_END", "NOCOND", "REGEXP", "SETUP", "STAR",
+  "'='", "';'", "'/'", "'<'", "'>'", "':'", "','", "'|'", "'\\\\'", "'('",
+  "')'", "$accept", "spec", "decl", "rule", "cond", "clist", "newcond",
+  "look", "expr", "diff", "term", "factor", "close", "primary", 0
 };
 #endif
 
index afb75933df9efc023e8e7d4491252a43b5ccabcf..d484c429f5f14bab546d9e88529683efea49e948 100644 (file)
@@ -40,7 +40,7 @@
    enum yytokentype {
      CLOSE = 258,
      CLOSESIZE = 259,
-     CODE = 260,
+     TOKEN_CODE = 260,
      CONF = 261,
      ID = 262,
      FID = 263,
index cdb7a404d6ad6e8dde9507026454431fb081faee..ccc24e987d1d04995b43e1164faf9e47f42290c0 100644 (file)
@@ -407,7 +407,7 @@ code:
                                        else if (--depth == 0)
                                        {
                                                yylval.code = new Code (tok, tok_len (), get_fname (), tline);
-                                               return CODE;
+                                               return TOKEN_CODE;
                                        }
                                        goto code;
                                }
@@ -448,7 +448,7 @@ code:
                                                        --cur;
                                                }
                                                yylval.code = new Code (tok, tok_len (), get_fname (), tline);
-                                               return CODE;
+                                               return TOKEN_CODE;
                                        }
                                        else if (cur == eof)
                                        {
index b2b01087a862d81b90b9828176ee34cb93693247..590d93439bacaa103bcab80ee3203bcd8cc59b4c 100644 (file)
@@ -159,7 +159,7 @@ void default_rule(CondList *clist, const Code * code)
 
 %token CLOSE
 %token CLOSESIZE
-%token CODE
+%token TOKEN_CODE
 %token CONF
 %token ID
 %token FID
@@ -171,7 +171,7 @@ void default_rule(CondList *clist, const Code * code)
 
 %type <op>      CLOSE STAR SETUP close
 %type <extop>   CLOSESIZE
-%type <code>    CODE
+%type <code>    TOKEN_CODE
 %type <regexp>  REGEXP rule look expr diff term factor primary
 %type <str>     ID FID newcond
 %type <clist>   cond clist
@@ -220,7 +220,7 @@ decl:
 ;
 
 rule:
-               expr look CODE
+               expr look TOKEN_CODE
                {
                        if (opts->cFlag)
                        {
@@ -237,7 +237,7 @@ rule:
                                );
                        spec.add (rule);
                }
-       |       STAR CODE /* default rule */
+       |       STAR TOKEN_CODE /* default rule */
                {
                        if (opts->cFlag)
                                in->fatal("condition or '<*>' required when using -c switch");
@@ -255,7 +255,7 @@ rule:
                                in->fatal("code to default rule is already defined");
                        }
                }
-       |       '<' cond '>' expr look newcond CODE
+       |       '<' cond '>' expr look newcond TOKEN_CODE
                {
                        context_rule ($2, $7->loc, $4, $5, $7, $6);
                }
@@ -265,7 +265,7 @@ rule:
                        Loc loc (in->get_fname (), in->get_cline ());
                        context_rule ($2, loc, $4, $5, NULL, $7);
                }
-       |       '<' cond '>' look newcond CODE
+       |       '<' cond '>' look newcond TOKEN_CODE
                {
                        context_none($2);
                        delete $5;
@@ -276,11 +276,11 @@ rule:
                        context_none($2);
                        delete $6;
                }
-       |       '<' cond '>' STAR CODE /* default rule for conditions */
+       |       '<' cond '>' STAR TOKEN_CODE /* default rule for conditions */
                {
                        default_rule($2, $5);
                }
-       |       '<' STAR '>' expr look newcond CODE
+       |       '<' STAR '>' expr look newcond TOKEN_CODE
                {
                        context_check(NULL);
                        RuleOp * rule = new RuleOp
@@ -312,7 +312,7 @@ rule:
                        specStar.push_back (rule);
                        delete $7;
                }
-       |       '<' STAR '>' look newcond CODE
+       |       '<' STAR '>' look newcond TOKEN_CODE
                {
                        context_none(NULL);
                        delete $5;
@@ -323,7 +323,7 @@ rule:
                        context_none(NULL);
                        delete $6;
                }
-       |       '<' STAR '>' STAR CODE /* default rule for all conditions */
+       |       '<' STAR '>' STAR TOKEN_CODE /* default rule for all conditions */
                {
                        if (star_default)
                        {
@@ -339,7 +339,7 @@ rule:
                                , NULL
                                );
                }
-       |       NOCOND newcond CODE
+       |       NOCOND newcond TOKEN_CODE
                {
                        context_check(NULL);
                        if (specNone)
@@ -377,13 +377,13 @@ rule:
                                );
                        delete $3;
                }
-       |       SETUP STAR '>' CODE
+       |       SETUP STAR '>' TOKEN_CODE
                {
                        CondList *clist = new CondList();
                        clist->insert("*");
                        setup_rule(clist, $4);
                }
-       |       SETUP cond '>' CODE
+       |       SETUP cond '>' TOKEN_CODE
                {
                        setup_rule($2, $4);
                }