相关疑难解决方法(0)

使用yyparse()进行编译时遇到的困难(g ++,bison,flex);

编译我的代码有问题:

柔性:

%{
#include "lista4.tab.hpp"
#include <stdlib.h>
extern int yylex();
%}
%%
"=" {return EQ;}
"!="    {return NE;}
"<" {return LT;}
">" {return GT;}
":="    {return ASSIGN;}
";" {return SEMICOLON;}
"IF"    {return IF;}
"THEN"{return THEN;}

"END" {return END;}
[_a-z]+ {yylval.text = strdup(yytext); return IDENTIFIER;}
[ \t]+
[0-9]+          {
                yylval.var = atoi (yytext);
                return NUMBER;
                }
[-+/^*'%'()]    {
                return *yytext;
                }
\n              return RESULT;
%%
Run Code Online (Sandbox Code Playgroud)

野牛:

%{
  extern "C"
  {
    int yyparse();
    int yylex(void);
    void yyerror(char *s){}
    int yywrap(void){return 1;}
  } …
Run Code Online (Sandbox Code Playgroud)

c++ compiler-construction g++ bison flex-lexer

4
推荐指数
1
解决办法
7675
查看次数

标签 统计

bison ×1

c++ ×1

compiler-construction ×1

flex-lexer ×1

g++ ×1