mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-10 12:53:03 +00:00
yacc.c: add support for parse.error detailed
"detailed" error messages are almost like "verbose", except that we don't double escape them, they don't get inner quotes, we don't use yytnamerr, and we hide the table. "custom" is exposed with the "detailed" tokens, not the "verbose" ones: they are not double-quoted. Because there's a risk that some people use yytname even without "verbose", let's keep yytname (instead of yys_name) in "simple" parse.error. * src/output.c (prepare_symbol_names): Be ready to output symbol names unquoted. (prepare_symbol_names): Output both the old tname table, and the new symbol_names one. * data/skeletons/bison.m4: Accept 'detailed'. * data/skeletons/yacc.c: When parse.error is 'detailed', don't emit yytname and yytnamerr, just yysymbol_name with the table inside. * tests/calc.at: Adjust.
This commit is contained in:
@@ -139,13 +139,17 @@ static void
|
||||
prepare_symbol_names (char const *muscle_name)
|
||||
{
|
||||
/* We assume that the table will be output starting at column 2. */
|
||||
const bool quote = STREQ (muscle_name, "tname");
|
||||
int j = 2;
|
||||
struct quoting_options *qo = clone_quoting_options (0);
|
||||
set_quoting_style (qo, c_quoting_style);
|
||||
set_quoting_flags (qo, QA_SPLIT_TRIGRAPHS);
|
||||
for (int i = 0; i < nsyms; i++)
|
||||
{
|
||||
char *cp = quotearg_alloc (symbols[i]->tag, -1, qo);
|
||||
char *cp =
|
||||
symbols[i]->tag[0] == '"' && !quote
|
||||
? xstrdup (symbols[i]->tag)
|
||||
: quotearg_alloc (symbols[i]->tag, -1, qo);
|
||||
/* Width of the next token, including the two quotes, the
|
||||
comma and the space. */
|
||||
int width = strlen (cp) + 2;
|
||||
@@ -192,6 +196,7 @@ prepare_symbols (void)
|
||||
|
||||
/* tname -- token names. */
|
||||
prepare_symbol_names ("tname");
|
||||
prepare_symbol_names ("symbol_names");
|
||||
|
||||
/* Output YYTOKNUM. */
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user