I have yyerror()
defined in my Bison file:
parser.y
...
%code {
void yyerror(YYLTYPE* yyllocp, yyscan_t unused, const char** errorReturn, const char* msg);
}
...
void yyerror(YYLTYPE* yyllocp, yyscan_t unused, const char** errorReturn, const char* msg) {
...
}
And I'd like to invoke it in my flex file with a custom message if possible:
flex.l
%option reentrant bison-bridge bison-locations
...
"]" return TOKEN(TCLOSEINDEX);
. {yyerror("Unknown token");}
%%
How can I achieve this?
return yytext[0];
to the parser and let it deal with the bad character as a syntax error.