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:
2025-01-14 23:13:02 -04:00
parent 9a9f5058ed
commit 4dee8c62c9
+8 -1
View File
@@ -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));
}
%}