summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2020-02-06 08:25:44 +0100
committerAkim Demaille <akim.demaille@gmail.com>2020-02-08 11:24:53 +0100
commit52db24b2bc46ca1cc9af2ce1cb15b00bdab99d90 (patch)
tree5d449f81f3cb1b6002250185639691cda6e8e881 /tests
parent650b253843727980af2a14e3bc2b667e62d7d0d5 (diff)
downloadbison-52db24b2bc46ca1cc9af2ce1cb15b00bdab99d90.tar.gz
java: add support for parse.error=detailed
In Java there is no need for N_ and yytranslate_. So instead of hard-coding the use of N_ in the table of the symbol names, rely on b4_symbol_translate. * src/output.c (prepare_symbol_names): Use b4_symbol_translate instead of N_. * data/skeletons/c.m4 (b4_symbol_translate): New. * data/skeletons/lalr1.java (yysymbolName): New. Use it. * examples/java/calc/Calc.y: Use parse.error=detailed. * tests/calc.at: Check parse.error=detailed.
Diffstat (limited to 'tests')
-rw-r--r--tests/calc.at17
1 files changed, 15 insertions, 2 deletions
diff --git a/tests/calc.at b/tests/calc.at
index f2f40fd8..25a1c806 100644
--- a/tests/calc.at
+++ b/tests/calc.at
@@ -509,7 +509,6 @@ void location_print (FILE *o, Span s);
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)
@@ -649,10 +648,23 @@ m4_define([_AT_DATA_CALC_Y(java)],
}
%code {
-]AT_CALC_MAIN[
+ ]AT_CALC_MAIN[
+
+ ]AT_TOKEN_TRANSLATE_IF([[
+ static String _ (String s)
+ {
+ if (s.equals ("end of input"))
+ return "end of file";
+ else if (s.equals ("number"))
+ return "nombre";
+ else
+ return s;
+ }
+ ]])[
}
/* Bison Declarations */
+%token CALC_EOF 0 ]AT_TOKEN_TRANSLATE_IF([_("end of input")], ["end of input"])[
%token <Integer> NUM "number"
%type <Integer> exp
@@ -1173,6 +1185,7 @@ m4_define([AT_CHECK_CALC_LALR1_JAVA],
[AT_CHECK_CALC([%language "Java" $1], [$2])])
AT_CHECK_CALC_LALR1_JAVA
+AT_CHECK_CALC_LALR1_JAVA([%define parse.error detailed])
AT_CHECK_CALC_LALR1_JAVA([%define parse.error verbose])
AT_CHECK_CALC_LALR1_JAVA([%locations %define parse.error verbose])
AT_CHECK_CALC_LALR1_JAVA([%define parse.trace %define parse.error verbose])