bison没有创建tab.h文件
发布时间:2020-12-15 01:48:33 所属栏目:百科 来源:网络整理
导读:我是flex和bison的新手,我现在已经在这个项目上工作了几天.我有一个以前工作正常的野牛文件,我稍微更改了一下,现在它没有创建一个tab.h文件…我已将错误和我的野牛和flex文件放在下面…… ??错误: In file included from stojk_3_2.y:55: stojkovic_project
我是flex和bison的新手,我现在已经在这个项目上工作了几天.我有一个以前工作正常的野牛文件,我稍微更改了一下,现在它没有创建一个tab.h文件…我已将错误和我的野牛和flex文件放在下面……
??错误: 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文件: %{ #include <stdio.h> #include <stdlib.h> #include <ctype.h> #define YYSTYPE double int yylex(void); static void yyerror(char *s) { printf("yyerror: %sn",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 'n' {printf("%gn",$2);} | lines 'n' | /*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文件 /*** 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} %{ /* C code to be copied verbatim */ #include <stdio.h> %} /* 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; } .|n { /* Ignore all other characters. */ } %% 解决方法
试试跑步
bison -d blah.y 这将使它生成.h文件 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |