bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 6/8] tests: check that internationalization of token works


From: Akim Demaille
Subject: [PATCH 6/8] tests: check that internationalization of token works
Date: Sat, 29 Dec 2018 17:30:25 +0100

* tests/calc.at: Check it.
---
 tests/calc.at  | 21 ++++++++++++++++++---
 tests/local.at |  5 ++++-
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/tests/calc.at b/tests/calc.at
index f5628c66..0db36145 100644
--- a/tests/calc.at
+++ b/tests/calc.at
@@ -270,6 +270,21 @@ static int power (int base, int exponent);
 
 ]AT_YYERROR_DECLARE[
 ]AT_YYLEX_DECLARE_EXTERN[
+
+]AT_ERROR_VERBOSE_IF([[
+  static
+  const char *
+  _ (const char *cp)
+  {
+    /* Make sure only "end of input" is translated.  */
+    if (strcmp (cp, "end of input") == 0)
+      return "end of file";
+    else if (strcmp (cp, "number") == 0)
+      return "nombre";
+    else
+      return cp;
+  }
+]])[
 }
 
 ]AT_CXX_IF([AT_LOCATION_TYPE_SPAN_IF([[
@@ -280,8 +295,8 @@ static int power (int base, int exponent);
 }]])])[
 
 /* Bison Declarations */
-%token CALC_EOF 0 "end of input"
-%token <ival> NUM "number"
+%token CALC_EOF 0 _("end of input")
+%token <ival> NUM   "number"
 %type  <ival> exp
 
 %nonassoc '='   /* comparison          */
@@ -530,7 +545,7 @@ _AT_CHECK_CALC_ERROR([$1], [1],
                      [2.1: syntax error, unexpected '+'])
 # Exercise error messages with EOF: work on an empty file.
 _AT_CHECK_CALC_ERROR([$1], [1], [/dev/null], [4],
-                     [1.1: syntax error, unexpected end of input])
+                     [1.1: syntax error, unexpected end of file])
 
 # Exercise the error token: without it, we die at the first error,
 # hence be sure to
diff --git a/tests/local.at b/tests/local.at
index 4ce9f825..6f8d347a 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -144,7 +144,9 @@ m4_pushdef([AT_AUTOMOVE_IF],
 m4_pushdef([AT_DEFINES_IF],
 [m4_bmatch([$3], [%defines], [$1], [$2])])
 m4_pushdef([AT_DEBUG_IF],
-[m4_bmatch([$3], [%debug\|%define parse.trace], [$1], [$2])])
+           [m4_bmatch([$3], [%debug\|%define parse.trace], [$1], [$2])])
+m4_pushdef([AT_ERROR_VERBOSE_IF],
+           [m4_bmatch([$3], [%define parse\.error verbose], [$1], [$2])])
 m4_pushdef([AT_CXX_IF],
 [m4_bmatch([$3], [%language "[Cc]\+\+"\|%skeleton "[a-z0-9]+\.cc"], [$1], 
[$2])])
 m4_pushdef([AT_JAVA_IF],
@@ -336,6 +338,7 @@ m4_popdef([AT_JAVA_IF])
 m4_popdef([AT_GLR_CC_IF])
 m4_popdef([AT_LALR1_CC_IF])
 m4_popdef([AT_DEFINES_IF])
+m4_popder([AT_ERROR_VERBOSE_IF])
 m4_popdef([AT_DEBUG_IF])
 AT_LOC_POPDEF])dnl
 ])# AT_BISON_OPTION_POPDEFS
-- 
2.20.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]