I have a question for yacc compiler. I do not compile simple yacc grammar. Here is the code section :
/*anbn_0.y */
%token A B
%%
start: anbn '\n' {printf(" is in anbn_0\n");
return 0;}
anbn: empty
| A anbn B
;
empty: ;
%%
#include "lex.yy.c"
yyerror(s)
char *s;
{ printf("%s, it is not in anbn_0\n", s);
I use mac os x and, i try yo command;
$ yacc anbn_0.y
and then
$ gcc -o anbn_0 y.tab.c -ll
and give me error. Here is the error ;
warning: implicit declaration of function 'yylex' is invalid in C99 [-Wimplicit-function-declaration]
yychar = YYLEX;
Why do I get an error ?
Its a warning, not an error, so you should be fine if you ignore it. But if you really want to get rid of the warning, you could add
%{
int yylex();
%}
to the top of your .y
file