Bison did not create a TAB.H file

I am new to flex and bison, and I have been working on this project for a few days now. I have a bison file that worked fine before, I changed it a bit, and now it doesn’t Create a tab.h file… I have put the error and my bison and flex files below…
Error:

In file included from stojk_3_2 .y:55:
stojkovic_project1_2.l:4:27: error: stojk_3_2.tab.h: No such file or directory
stojk_3_2.tab.c: In function'int yyparse()':< br /> stojk_3_2.tab.c:1416: warning: deprecated conversion from string constant to'char*'
stojk_3_2.tab.c:1562: warning: deprecated conversion from string constant to'char*'

.y file:

%{
#include
#include
#include

#define YYSTYPE double

int yylex(void);

static
void yyerror(char *s)
{
printf("yyerror: %s ", s);
}

%}

% token PLUS
%token MINUS
%token MULT
%token DIVIDE

%token LPAREN
%token RPAREN

% token UNSIGNEDINTEGER

%left PLUS MINUS
%left MULT DIVIDE

%token Variable
%token Exp
%token Sign
%token Unsigned_int
%token Unsigned_float_int
%token Factor

%%

lines: lines expr' ' {printf("%g ", $2);}
| lines' '
| /*empty*/
;

expr: expr PLUS expr {$$ = $1 + $3;}
| expr MINUS expr {$$ = $1-$3; }
| expr MULT expr {$$ = $1 * $3;}
| expr DIVIDE expr {$$ = $1 / $3;}
| LPAREN expr RPAREN {$$= $2;}
| UNSIGNEDINTEGER
;

%%

#include "lex.yy.c"

int yylex(void );
int yyparse(void);

int main(void)
{
return yyparse();
}

.l file

/*** Definition section ***/
%{

#include "stojk_3_2.tab.h "
%}


Variable [a-zA-Z_]+[a-zA-Z0-9_] *
Digit [0-9]
Digits [0-9]*
Sign [+]|[-]
Exp [E]+{Sign}|[e] +{Sign}
Unsigned_int {Digit}|{Digits}
Unsigned_float_int ({Digit}|{Digits}+[.]+{Digit}|{Digits})({Digit}| {Digits} +[.]+{Digit}|{Digits}+{Exp}+{Digit}|{Digits})
Factor {Variable}|{Unsigned_int}| {Unsigned_float_int}

< br />

%{
/* C code to be copied verbatim */
#include

%}

/* This tells flex to read only one input file */
%option noyywrap

%%
/*** Rules section ***/

/* [0-9]+ matches a string of one or more digits */

{Variable} {return Variable; }

{Exp} {return Exp; }
{Sign} {return Sign; }

{Unsigned_int} {return Unsigned_int; }
{Unsigned_float_int} {return Unsigned_float_int; }
{Factor} {return Factor; }









.| { /* Ignore all other characters. */ }

%%

Try running

bison -d blah.y

This will make it generate a .h file

< /p>

I am new to flex and bison, and I have been working on this project for a few days now. I have a bison file that worked fine before, I changed it a bit, and now it does not create a tab.h File… I have put the error and my bison and flex files below…
Error:

In file included from stojk_3_2.y:55: 
stojkovic_project1_2.l:4:27: error: stojk_3_2.tab.h: No such file or directory
stojk_3_2.tab.c: In function'int yyparse()':
stojk_3_2. tab.c:1416: warning: deprecated conversion from string constant to'char*'
stojk_3_2.tab.c:1562: warning: deprecated conversion from string constant to'char*'

. y file:

%{
#include
#include
#include

#define YYSTYPE double

int yylex(void);

static
void yyerr or(char *s)
{
printf("yyerror: %s ", s);
}

%}

%token PLUS
%token MINUS
%token MULT
%token DIVIDE

%token LPAREN
%token RPAREN

%token UNSIGNEDINTEGER

%left PLUS MINUS
%left MULT DIVIDE

%token Variable
%token Exp
%token Sign
%token Unsigned_int
%token Unsigned_float_int
%token Factor

%%

lines: lines expr' ' {printf( "%g ", $2);}
| lines' '
| /*empty*/
;

expr: expr PLUS expr { $$ = $1 + $3;}
| expr MINUS expr {$$ = $1-$3;}
| expr MULT expr {$$ = $1 * $3;}
| expr DIVIDE expr {$$ = $1 / $3;}
| LPAREN expr RPAREN {$$= $2;}
| UNSIGNEDINTEGER
;

%%
< br />#include "lex.yy.c"

int yylex(void);
int yyparse(void);

int main(void)
{
return yyparse();
}

. lFile

/*** Definition section ***/
%{

#include "stojk_3_2.tab.h"< br />%}


Variable [a-zA-Z_]+[a-zA-Z0-9_]*
Digit [0-9]
Digits [0-9]*
Sign [+]|[-]
Exp [E]+{Sign}|[e]+{Sign}
Unsigned_int {Digit}|{Digits }
Unsigned_float_int ({Digit}|{Digits}+[.]+{Digit}|{Digits})({Digit}| {Digits}+[.]+{Digit}|{Digits}+{Exp }+{Digit}|{Digits})
Factor {Variable}|{Unsigned_int}| {Unsigned_float_int}




%{
/* C code to be copied verbatim */
#include

%}

/* This tells flex to read only one input file */
%option noyywrap

%%
/*** Rules section ***/

/* [0-9] + matches a stri ng of one or more digits */

{Variable} {return Variable; }

{Exp} {return Exp; }
{Sign} {return Sign ; }

{Unsigned_int} {return Unsigned_int; }
{Unsigned_float_int} {return Unsigned_float_int; }
{Factor} {return Factor; }









.| {/* Ignore all other characters. */ }

%%

Try running

bison -d blah. y

This will make it generate a .h file

Leave a Comment

Your email address will not be published.