Lex code:
identifier [\._a-zA-Z0-9\/]+
comment "//"
<*>{comment} {
cout<<"Comment\n";
char c;
while((c= yyinput()) != '\n')
{
}
}
<INITIAL>{s}{e}{t} {
BEGIN(SAMPLE_STATE);
return SET;
}
<SAMPLE_STATE>{identifier} {
strncpy(yylval.str, yytext,1023);
yylval.str[1023] = '\0';
return IDENTIFIER;
}
In the above lex code, there is no error when "// set name" is parsed. Please notice the space after "//" in the sentence parsed. However, when "//set name" is parsed, there is an error reported. Could you point to where I am going wrong? Thanks.
The error is caught by yyerror
and reports
SampleParser.y:43: int CMTSTapTestSeq_yyerror(char*): Assertion `0 && "Error parsing Sample file\n"' failed.
This assertion is added by me.