In my lex file I have:
[a-zA-Z][a-zA-Z0-9]*
{
yylval.val = _strdup(yytext); // <- error here
yylval.length = yylen;
return id;
}
... for parsing text such as "myid2"
This is causing a compilation error:
error C2143: syntax error : missing ';' before '='
How to do this correctly so that I can pass on the id as a character string (char *) in the yacc file?
I am using win_flex and win_bison.
UPDATE: I put the statements on one line in the lex file:
[a-zA-Z][a-zA-Z0-9]* { yylval.val = _strdup(yytext); yylval.length = yylen; return id; }
Now I get the compilation errors:
error C2039: 'length' : is not a member of 'YYSTYPE'
error C2039: 'val' : is not a member of 'YYSTYPE'
error C2065: 'yylen' : undeclared identifier