parsers: issue tname with i18n markup

Some users would like to avoid having to "parse" the *.y file to find
the strings to translate.  Let's issue the translatable tokens with N_
to allow "parsing" the generated parsers instead.

See
https://lists.gnu.org/archive/html/bison-patches/2019-01/msg00015.html

* src/output.c (prepare_symbol_names): Issue symbol_names with N_()
markup.
This commit is contained in:
Akim Demaille
2019-01-05 15:23:28 +01:00
parent 2e12257803
commit 6ada985ff3
2 changed files with 8 additions and 1 deletions

View File

@@ -206,7 +206,9 @@ prepare_symbol_names (char const *muscle_name)
: 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;
int width
= strlen (cp) + 2
+ (!quote && symbols[i]->translatable ? strlen ("N_()") : 0);
if (j + width > 75)
{
@@ -216,7 +218,11 @@ prepare_symbol_names (char const *muscle_name)
if (i)
obstack_1grow (&format_obstack, ' ');
if (!quote && symbols[i]->translatable)
obstack_sgrow (&format_obstack, "N_(");
obstack_escape (&format_obstack, cp);
if (!quote && symbols[i]->translatable)
obstack_1grow (&format_obstack, ')');
free (cp);
obstack_1grow (&format_obstack, ',');
j += width;

View File

@@ -422,6 +422,7 @@ void location_print (FILE *o, Span s);
]AT_YYLEX_DECLARE_EXTERN[
]AT_TOKEN_TRANSLATE_IF([[
#define N_
static
const char *
_ (const char *cp)