I am trying to generate a compiler so I can pass the .c file to it later.
I downloaded the YACC and LEX grammars from http://www.quut.com/c/ANSI-C-grammar-y.html and named them clexyacc.l and clexyacc.y
When generating on the terminal, I did:
yacc -d clexyacc.y
lex clexyacc.l
Everything went fine. When I go to the last part, I get a few errors.
Last part: cc lex.yy.c y.tab.c -oclexyacc.exe
But I get these errors:
y.tab.c:2261:16: warning: implicit declaration of function 'yylex' is invalid in
C99 [-Wimplicit-function-declaration]
yychar = YYLEX;
^
y.tab.c:1617:16: note: expanded from macro 'YYLEX'
# define YYLEX yylex ()
^
y.tab.c:2379:7: warning: implicit declaration of function 'yyerror' is invalid
in C99 [-Wimplicit-function-declaration]
yyerror (YY_("syntax error"));
^
clexyacc.y:530:6: error: conflicting types for 'yyerror'
void yyerror(const char *s)
^
y.tab.c:2379:7: note: previous implicit declaration is here
yyerror (YY_("syntax error"));
^
2 warnings and 1 error generated.
source
share