[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Is there an option to change the message produced by YYERROR_VERBOSE
From: |
Matthias Simon |
Subject: |
Re: Is there an option to change the message produced by YYERROR_VERBOSE? |
Date: |
Wed, 27 Apr 2016 15:05:30 +0200 |
User-agent: |
Roundcube Webmail/0.9.5 |
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
Re: Is there an option to change the message produced by YYERROR_VERBOSE?, Hans Åberg, 2016/04/26
Re: Is there an option to change the message produced by YYERROR_VERBOSE?,
Matthias Simon <=