Hello,
I'm trying to build a simple lexical analyzer to go along with a simple input output library for (scientific) C programs. When compiling with autotools, including automake, libtool, and autoconf, I get the following error:
simpleio_lex.l:41: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘of’
This usually means that I've forgotten a semicolon at the end of a function prototype, but I've checked my header and there's no such omission.
Here's 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;
}
The *compilation*
buffer hyperlink in Emacs refers me to the %}%
at the end of the preamble. Why am I getting this error? I have no symbol called "of," either.
Thanks,
Joel