Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
bison没有创建tab.h文件_Bison_Lex_Flex Lexer - Fatal编程技术网

bison没有创建tab.h文件

bison没有创建tab.h文件,bison,lex,flex-lexer,Bison,Lex,Flex Lexer,我是flex和bison的新手,我已经在这个项目上工作了几天了。我有一个bison文件,它以前工作正常,我对它做了一些修改,现在它没有创建tab.h文件。。。我把错误和我的bison和flex文件都放在下面。。。 错误: .y文件: %{ #include <stdio.h> #include <stdlib.h> #include <ctype.h> #define YYSTYPE double int yylex(void); static void

我是flex和bison的新手,我已经在这个项目上工作了几天了。我有一个bison文件,它以前工作正常,我对它做了一些修改,现在它没有创建tab.h文件。。。我把错误和我的bison和flex文件都放在下面。。。 错误:

.y文件:

%{
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

#define YYSTYPE double

int yylex(void);

static
void yyerror(char *s)
{
printf("yyerror: %s\n", 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("%g\n", $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();
}
%{
#包括
#包括
#包括
#定义YYSTYPE双精度
int yylex(无效);
静止的
无效错误(字符*s)
{
printf(“YY错误:%s\n”,s);
}
%}
%代币加号
%代币负号
%代币骡子
%代币分割
%令牌LPAREN
%令牌RPAREN
%令牌无符号整数
%左加减
%左多分裂
%标记变量
%代币出口
%象征符号
%令牌无符号整数
%令牌无符号浮点数
%表征因子
%%
行:行expr'\n'{printf(“%g\n”,$2);}
|行“\n”
|/*空*/
;
expr:expr加上expr{$$=$1+$3;}
|expr减去expr{$$=$1-$3;}
|expr MULT expr{$$=$1*$3;}
|expr除以expr{$$=$1/$3;}
|LPAREN expr RPAREN{$$=$2;}
|无符号整数
;
%%
#包括“lex.yy.c”
int yylex(无效);
int(void);
内部主(空)
{
返回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. */   }

%%
/***定义部分***/
%{
#包括“stojk_3_2.tab.h”
%}
变量[a-zA-Z_]+[a-zA-Z0-9_]*
数字[0-9]
数字[0-9]*
符号[+]|[-]
Exp[E]+{Sign}|[E]+{Sign}
无符号_int{Digit}{Digits}
无符号浮点数({Digit}{Digits}+[.]+{Digit}{Digits}{Digits})({Digits}{Digits}+[.]+{Digits}{Digits}+{Exp}+{Digits}{Digits})
因子{Variable}{Unsigned_int}{Unsigned_float_int}
%{
/*要逐字复制的C代码*/
#包括
%}
/*这告诉flex只读取一个输入文件*/
%选项No yywrap
%%
/***规则组***/
/*[0-9]+匹配一个或多个数字的字符串*/
{Variable}{return Variable;}
{Exp}{return Exp;}
{Sign}{return Sign;}
{Unsigned_int}{返回Unsigned_int;}
{Unsigned_float_int}{返回Unsigned_float_int;}
{Factor}{return Factor;}
.|\n{/*忽略所有其他字符。*/}
%%
尝试运行

bison -d blah.y

这将使它生成.h文件

这两个文件?stojk_3_2.tab.h是在目录中创建的吗?等等,什么?你为什么要把它包括在内?它从哪里来?这在莱克斯档案里!jso i删除了.l文件中的include,它现在可以工作了,但它仍然没有创建tab.h文件。我读到bison生成了一个tab.h文件,您应该将它包含在.l文件中。d:=这与--defines相同,除了-d不接受文件参数,因为POSIX Yacc要求-d可以与其他短文件绑定我重新标记,因为这与Adobe/ApacheUI框架无关。
bison -d blah.y