编译我的代码有问题:
柔性:
%{
#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)