java: add support for parse.error=detailed

In Java there is no need for N_ and yytranslate_.  So instead of
hard-coding the use of N_ in the table of the symbol names, rely on
b4_symbol_translate.

* src/output.c (prepare_symbol_names): Use b4_symbol_translate instead
of N_.
* data/skeletons/c.m4 (b4_symbol_translate): New.
* data/skeletons/lalr1.java (yysymbolName): New.
Use it.
* examples/java/calc/Calc.y: Use parse.error=detailed.
* tests/calc.at: Check parse.error=detailed.
This commit is contained in:
Akim Demaille
2020-02-06 08:25:44 +01:00
parent 650b253843
commit 52db24b2bc
6 changed files with 91 additions and 46 deletions

View File

@@ -200,8 +200,8 @@ prepare_symbol_names (char const *muscle_name)
set_quoting_flags (qo, QA_SPLIT_TRIGRAPHS);
for (int i = 0; i < nsyms; i++)
{
char *cp =
symbols[i]->tag[0] == '"' && !quote
char *cp
= symbols[i]->tag[0] == '"' && !quote
? xescape_trigraphs (symbols[i]->tag)
: quotearg_alloc (symbols[i]->tag, -1, qo);
/* Width of the next token, including the two quotes, the
@@ -219,10 +219,10 @@ prepare_symbol_names (char const *muscle_name)
if (i)
obstack_1grow (&format_obstack, ' ');
if (!quote && symbols[i]->translatable)
obstack_sgrow (&format_obstack, "N_(");
obstack_sgrow (&format_obstack, "]b4_symbol_translate([");
obstack_escape (&format_obstack, cp);
if (!quote && symbols[i]->translatable)
obstack_1grow (&format_obstack, ')');
obstack_sgrow (&format_obstack, "])[");
free (cp);
obstack_1grow (&format_obstack, ',');
j += width;