Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lex error y.tab.h

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;
}
like image 404
codenamejupiterx Avatar asked Nov 15 '12 01:11

codenamejupiterx


1 Answers

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
like image 187
Andrade Avatar answered Sep 21 '22 15:09

Andrade