mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-16 07:43:03 +00:00
parsers: support translatable token aliases
In addition to
%token NUM "number"
accept
%token NUM _("number")
in which case the token will be translated in error messages.
Do not use _() in the output if there are no translatable tokens.
* src/symtab.h, src/symtab.c (symbol): Add a 'translatable' member.
* src/parse-gram.y (TSTRING): New token.
(string_as_id.opt): Replace with...
(alias): this.
Use it.
* src/scan-gram.l (SC_ESCAPED_TSTRING): New start conditions, to match
TSTRINGs.
* src/output.c (prepare_symbols): Define b4_translatable if there are
translatable strings.
* data/skeletons/glr.c, data/skeletons/lalr1.cc,
* data/skeletons/yacc.c (yytnamerr): Receive b4_translatable, and use it.
This commit is contained in:
@@ -109,6 +109,7 @@ symbol_new (uniqstr tag, location loc)
|
||||
|
||||
res->tag = tag;
|
||||
res->location = loc;
|
||||
res->translatable = false;
|
||||
res->location_of_lhs = false;
|
||||
res->alias = NULL;
|
||||
res->content = sym_content_new (res);
|
||||
@@ -954,7 +955,7 @@ dummy_symbol_get (location loc)
|
||||
}
|
||||
|
||||
bool
|
||||
symbol_is_dummy (const symbol *sym)
|
||||
symbol_is_dummy (symbol const *sym)
|
||||
{
|
||||
return sym->tag[0] == '@' || (sym->tag[0] == '$' && sym->tag[1] == '@');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user