我在尝试将Flex和Bison一起使用时遇到了问题.当我使用gcc命令(gcc -c y.tab.c lex.yy.c)进行编译时,我不断收到flex文件的错误说
error: expected identifier or ‘(’ before string constant
Run Code Online (Sandbox Code Playgroud)
这是代码:
FLEX(文件名为arxeioflex.l):
%{
#include "y.tab.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
%}
%option noyywrap
id [a-zA-Z][a-zA-Z0-9]*
num [0-9]*
%%
%%
%%
"extern" {return EXTERN;}
"void" {return VOID;}
"(" {return LP;}
")" {return RP;}
"int" {return INT;}
"bool" {return BOOL;}
"string" {return STRING;}
";" {return SC;}
"," {return S;}
"&" {return DEC;}
"begin" {return BEGIN;}
"end" {return END;}
"{" {return LB;}
"}" {return RB;}
"if" …Run Code Online (Sandbox Code Playgroud)