Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
%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?
–
If you put the declaration of yyerror
in a %code provides
block instead of a default %code
block, it will be copied into the generated header file which will make the declaration available to your scanner implementation. (You need provides
rather than requires
because the declaration depends on the declaration of YYLTYPE
.)
Of course, you will need to call it with all of its required arguments.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.