Hi Simon,
depending on your grammar, you might treat the keyword as an identifier
and just throw a warning in the lexer:
"banana" {
if (!SUPPORTS_KEYWORD(yyextra->config.std)) {
fprintf(stderr, "warning: `banana' keyword not
available\n");
return TOK_ID;
}
return TOK_KW_BANANA;
}
Alternatively, semantic predicates might help you:
http://www.gnu.org/software/bison/manual/bison.html#Semantic-Predicates
Or the lexer could store the last few keywords in a global list and
--instead of parsing `unexpected %s'-- yyerror uses this list. But I am
not sure about that one, I would expect its success depends heavily on
the parser-algorithm.
Cheers,
Matthias
_______________________________________________
help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison