(科学的な)Cプログラム用の単純な入出力ライブラリと一緒に使用できる単純な字句解析プログラムを構築しようとしています。automake、libtool、autoconfなどのautotoolsでコンパイルすると、次のエラーが発生します。
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;
}
*compilation*
Emacsのバッファハイパーリンク%}%
は、プリアンブルの最後にあるを参照しています。なぜこのエラーが発生するのですか?「of」という記号もありません。
ありがとう、
ジョエル