I am trying to get this example code working but i keep getting the error: fatal error: 'y.tab.h' file not found #include "y.tab.h" . What can I do about this?
%{
#include <stdlib.h>
void yyerror(char *);
#include "y.tab.h"
%}
%% [0-9]+ {
yylval = atoi(yytext);
return INTEGER;
}
[-+\n] return *yytext;
[ \t] ; /* skip whitespace */
. yyerror("invalid character");
%%
int yywrap(void) {
return 1;
}
the "y.tab.h" file included in the flex file is generated when you run bison with -dy. example:
flex mylex.l
bison -dy myparser.y
then you should compile them both together:
gcc lex.yy.c myparser.tab.c -o mycompiler.exe
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With