我正在尝试构建一个简单的词法分析器,以及一个用于(科学)C 程序的简单输入输出库。使用自动工具(包括 automake、libtool 和 autoconf)进行编译时,出现以下错误:
simpleio_lex.l:41: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘of’
这通常意味着我忘记了函数原型末尾的分号,但我检查了我的标题并且没有这样的遗漏。
这是 simpleio_lex.l:
%{
int yylex(void);
#define yylex sio_lex
#include "simpleio.h"
%}
NUM [0-9] /* a number */
FLOAT {NUM}+"."{NUM}* /* a floating point number */
FLOATSEQ {FLOAT[[:space:]]?}+
FLOATLN ^FLOATSEQ$
SYMBOL [a-z]+ /* a symbol always comes at the
beginning of a line */
SYMDEF ^SYMBOL[[:space:]]*FLOAT /* define a single value for a symbol */
RANGE FLOAT":"FLOAT":"FLOAT /* a range of numbers */
SYMRANGE ^SYMBOL[[:space:]]+RANGE$ /* assign a range of values to a symbol */
%%
/* a set of lines with just numbers
indicates we should parse it as data */
{FLOATLN}+ sio_read_stk_inits (yytext);
SYMDEF sio_read_parse_symdef (yytext);
SYMRANGE sio_read_parse_symrange (yytext);
%%
/* might as well define these here */
sio_symdef_t *
sio_read_parse_symdef (char * symdef)
{
sio_symdef_t * def = malloc (sizeof (sio_symdef_t));
/* split the string into tokens on the LHS and RHS */
char * delim = " ";
char * lvalue = strtok (symdef, delim);
size_t lsize = sizeof (lvalue);
char * rest = strtok (NULL, delim);
double plval; /* place holder */
int s_ck = sscanf (rest, "%lg", &plval);
if (s_ck == EOF)
return NULL;
else
{
def->value = plval;
def->name = malloc (lsize);
memcpy(def->name, lvalue, lsize);
}
return def;
}
Emacs 中的*compilation*
缓冲区超链接将我指向%}%
序言末尾的 。为什么我会收到此错误?我也没有称为“的”的符号。
谢谢,
乔尔