Reputation: 516
I have a .y
file that I trying to use with bison -d
, but for some reason the .tab.h
file is not being generated. Any suggestions?
%{
#include <stdio.h>
int yyerror(const char* err);
%}
%token G
%token INT
%token X
%token Y
%token Z
%token END
%token ZERO
%token EOL
%%
program: list_of_expr
;
list_of_expr: expr
| list_of_expr expr
;
expr: G INT X INT Y INT Z INT EOL
| ZERO EOL
| END
;
%%
int main(int argc, char** argv){
yyparse();
}
int yyerror(const char* err){
printf("%s\n", err);
}
Upvotes: 0
Views: 324
Reputation: 14906
With GNU Bison 3.0.4
(default Ubuntu 18 bison) ~
The -d
option will only work if your bison grammar file has the .y
extension, e.g: my_grammar.y
.
But you can work around it by using bison --defines=my_tab.h my_grammar.whatever
instead.
EDIT: Your bison grammar file must have the .y
extension.
Upvotes: 0