小编vag*_*g77的帖子

FLEX-BISON:错误:预期标识符或'('字符串常量之前

我在尝试将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)

c gcc yacc bison flex-lexer

0
推荐指数
1
解决办法
1681
查看次数

标签 统计

bison ×1

c ×1

flex-lexer ×1

gcc ×1

yacc ×1