Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCC says "syntax error before numeric constant" in generated header file from bison

When I compile my .y file with bison parser.y -d -t and then include the parser.tab.h file in my flex file, gcc says "error: syntax error before numeric constant." It's referencing line 32, which is the first line in the enum of yytokentype.

enum yytokentype {
   BREAK = 258,
   ... }

The error is about the line "BREAK = 258." I honestly don't know why this is happening--I would really like to use the generated yylval and I need it from this header file. Even if I declared yytokentype like this in my flex file, I would get the same error. Anything I could be doing wrong?

like image 247
Kizaru Avatar asked Aug 13 '10 02:08

Kizaru


1 Answers

Is BREAK defined somewhere else in your code? I get a similar error from the following toy example:

#define BREAK 10
enum yytokentype {
    BREAK = 258
};

Build example:

$ cc -c file.c 
file.c:4: error: expected identifier before numeric constant
like image 169
Carl Norum Avatar answered Oct 25 '22 01:10

Carl Norum