devSpec:yacc: We now print out the current lex token string
We used some preprocessor logic to enable access to yytext and now we can have verbose, useful error messages from the parser :)
This commit is contained in:
@@ -25,13 +25,20 @@
|
||||
#undef yylex
|
||||
#define yylex deviceSpecllex
|
||||
|
||||
#ifdef yytext
|
||||
#undef yytext
|
||||
#endif
|
||||
#define yytext deviceSpecltext
|
||||
|
||||
// Declare the symbols that our lexer will export.
|
||||
int yylex(void);
|
||||
extern char* yytext; // Declare yytext to access the current token text
|
||||
void yyerror(const char *message)
|
||||
{
|
||||
throw std::runtime_error(
|
||||
std::string("deviceSpec parser error: ")
|
||||
+ std::string(message));
|
||||
+ std::string(message)
|
||||
+ " at token: " + std::string(yytext));
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
Reference in New Issue
Block a user