c++ - syntax error, unexpected token, expecting end of file -
i following error when run parser file ( binary got after compiling flex/bison files). error: syntax error, unexpected tkn_primary, expecting end of file
here rule defined in flex code:
<primary_mme_state>{number} { lexval = yytext(); std::cout<<"primary mme --> "<<lexval<<std::endl; yylval->strval = new std::string(lexval); return token::tkn_primarymme; }
and understanding since value of tkn_primary 0 ( value defined end %token end 0 "end of file") instead of returning tkn_primary , expecting token end returned. please comment if understanding correct . , how tackle issue.
if tkn_primary
, end
have same value (or, in general, if 2 different tokens have same value), bison parser going act in unpredictable ways.
quoting bison manual:
it best, however, let bison choose numeric codes token types. bison automatically select codes don't conflict each other or normal characters.
i think that's best way of dealing problem.
Comments
Post a Comment