[ACCEPTED]-Generating a compiler from lex and yacc grammar-lex

Accepted answer
Score: 19

The version of yacc you are using is producing 11 C code which is invalid for C99.

The code 10 it produces does not include declarations 9 for the functions yylex or yyerror prior 8 to calling them. This is producing the warnings. In 7 the case of yyerror, it is also resulting 6 in an implicit declaration which does not 5 match the later actual definition.

You can 4 get around it by including the following 3 at the top of the .y file:

%{
int yylex();
void yyerror(const char *s);
%}

Or, you can switch 2 to a more modern yacc compiler.

See also 1 this: Simple yacc grammars give an error

More Related questions