mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-17 16:23:04 +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:
@@ -97,6 +97,9 @@ struct symbol
|
||||
/** The "defining" location. */
|
||||
location location;
|
||||
|
||||
/** Whether this symbol is translatable. */
|
||||
bool translatable;
|
||||
|
||||
/** Whether \a location is about the first uses as left-hand side
|
||||
symbol of a rule (true), or simply the first occurrence (e.g.,
|
||||
in a %type, or as a rhs symbol of a rule). The former type of
|
||||
@@ -117,6 +120,8 @@ struct symbol
|
||||
|
||||
struct sym_content
|
||||
{
|
||||
/** The main symbol that denotes this content (it contains the
|
||||
possible alias). */
|
||||
symbol *symbol;
|
||||
|
||||
/** Its \c \%type.
|
||||
@@ -179,7 +184,7 @@ symbol *dummy_symbol_get (location loc);
|
||||
void symbol_print (symbol const *s, FILE *f);
|
||||
|
||||
/** Is this a dummy nonterminal? */
|
||||
bool symbol_is_dummy (const symbol *sym);
|
||||
bool symbol_is_dummy (symbol const *sym);
|
||||
|
||||
/** The name of the code_props type: "\%destructor" or "\%printer". */
|
||||
char const *code_props_type_string (code_props_type kind);
|
||||
|
||||
Reference in New Issue
Block a user