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:
Akim Demaille
2020-01-16 18:31:26 +01:00
parent 8e6233353f
commit f443673450
4 changed files with 65 additions and 38 deletions

View File

@@ -1018,16 +1018,17 @@ m4_define([b4_bison_locations_if],
# b4_error_verbose_if([IF-ERRORS-ARE-VERBOSE], [IF-NOT])
# ------------------------------------------------------
# Map %define parse.error "(custom|simple|verbose)" to b4_error_verbose_if and
# b4_error_verbose_flag.
# Map %define parse.error "(custom|detailed|simple|verbose)" to
# b4_error_verbose_if and b4_error_verbose_flag.
b4_percent_define_default([[parse.error]], [[simple]])
b4_percent_define_check_values([[[[parse.error]],
[[custom]], [[simple]], [[verbose]]]])
[[custom]], [[detailed]], [[simple]], [[verbose]]]])
m4_define([b4_error_verbose_flag],
[m4_case(b4_percent_define_get([[parse.error]]),
[custom], [[1]],
[simple], [[0]],
[verbose], [[1]])])
[custom], [[1]],
[detailed], [[1]],
[simple], [[0]],
[verbose], [[1]])])
b4_define_flag_if([error_verbose])
# yytoken_table is needed to support verbose errors.