d: add internationalisation support

The D parser implements this feature similarly to the C parser,
by using Gettext. Functions gettext() and dgettext() are
imported using extern(C). The internationalisation uses yysymbol_name
to report the name of the SymbolKinds.

* data/skeletons/d.m4 (SymbolKind.toString.yytranslatable,
SymbolKind.toString.yysymbol_name: New), data/skeletons/lalr1.d: Here.
* doc/bison.texi: Document it.
* tests/calc.at: Test it.
This commit is contained in:
Adela Vais
2020-11-28 21:09:39 +02:00
committed by Akim Demaille
parent e51e89856a
commit 594cae57ca
4 changed files with 145 additions and 15 deletions

View File

@@ -654,6 +654,23 @@ m4_define([_AT_DATA_CALC_Y(d)],
};
%printer { fprintf (yyo, "%d", $$); } <ival>;
%code {
]AT_TOKEN_TRANSLATE_IF([[
static string _(string s)
{
switch (s)
{
case "end of input":
return "end of file";
case "number":
return "nombre";
default:
return s;
}
}
]])[
}
/* Bison Declarations */
%token EOF 0 ]AT_TOKEN_TRANSLATE_IF([_("end of file")], ["end of input"])[
%token <ival> NUM "number"
@@ -665,7 +682,7 @@ m4_define([_AT_DATA_CALC_Y(d)],
STAR "*"
SLASH "/"
POW "^"
EOL "\n"
EOL "'\\n'"
LPAR "("
RPAR ")"
NOT "!"