6

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;
}
codenamejupiterx
  • 1,589
  • 9
  • 23
  • 34

2 Answers2

6

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
Andrade
  • 1,179
  • 12
  • 15
0

The yacc file that you're using is probably creating an output file called "y.tab.c" instead of the "y.tab.h" that you are trying to include here. You should probably try changing that.

arkarc
  • 21
  • 1