bison-patches
[Top][All Lists]
Advanced

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

java: lac: a stronger test for the exploratory stack


From: Akim Demaille
Subject: java: lac: a stronger test for the exploratory stack
Date: Fri, 6 Nov 2020 07:39:19 +0100

I believe this was the last thing that needed to be done to complete LAC 
support in Java.

commit d49da0101a916edeaa2d9adf056a9ea5017ceb2e
Author: Akim Demaille <akim.demaille@gmail.com>
Date:   Fri Nov 6 07:19:47 2020 +0100

    java: lac: a stronger test for the exploratory stack
    
    * tests/local.at (AT_YYLEX_DEFINE(java)): Fix overquoting issue.
    Style changes.
    * tests/regression.at (LAC: Exploratory stack): Run for lalr1.java too.

diff --git a/TODO b/TODO
index 72af014b..8b009d08 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,7 @@
 * Soon
+** yyerrok in Java
+And add tests in calc.at, to prepare work for D.
+
 ** YYERROR and yynerrs
 We are missing some cases.  Write a test case, and check all the skeletons.
 
diff --git a/tests/conflicts.at b/tests/conflicts.at
index c7c13147..fcd7821b 100644
--- a/tests/conflicts.at
+++ b/tests/conflicts.at
@@ -440,7 +440,7 @@ AT_DATA_GRAMMAR([input.y],
 ]$2[
 
 ]AT_JAVA_IF([[%code lexer {
-  ]AT_YYLEX_DEFINE([$3], [[return new Integer(1)]])[
+  ]AT_YYLEX_DEFINE(["$3"], [[return new Integer(1)]])[
   ]AT_YYERROR_DEFINE[
 };
 %%
diff --git a/tests/local.at b/tests/local.at
index d9b11f9a..22fae30a 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -1036,30 +1036,27 @@ m4_define([AT_YYLEX_DEFINE(java)],
   | yylex.  |
   `--------*/
 
-  public String input = "]$1[";
+  public String input = ]$1[;
   public int index = 0;
-  public int yylex ()
-  {
-    if (index < input.length ())
-      return input.charAt (index++);
+  public int yylex() {
+    if (index < input.length())
+      return input.charAt(index++);
     else
       return 0;
   }
-  public Object getLVal ()
-  {
-    ]$2[;
+  public Object getLVal() {
+    ]m4_ifval([$2], [$2], [return null])[;
   }
 ]])
 
 m4_define([AT_MAIN_DEFINE(java)],
 [[class input
 {
-  public static void main (String[] args) throws IOException
-  {
-    ]AT_API_prefix[Parser p = new ]AT_API_prefix[Parser ();
-    boolean success = p.parse ();
+  public static void main(String[] args) throws IOException {
+    ]AT_API_prefix[Parser p = new ]AT_API_prefix[Parser();
+    boolean success = p.parse();
     if (!success)
-      System.exit (1);
+      System.exit(1);
   }
 }]])
 
diff --git a/tests/regression.at b/tests/regression.at
index 293e8536..3e57e38a 100644
--- a/tests/regression.at
+++ b/tests/regression.at
@@ -1341,11 +1341,21 @@ m4_pushdef([AT_LAC_CHECK], [
 AT_BISON_OPTION_PUSHDEFS([%debug $1])
 
 AT_DATA_GRAMMAR([input.y],
+[AT_JAVA_IF([[%code imports {
+  import java.io.IOException;
+}
+
+%code lexer {
+]AT_YYERROR_DEFINE[
+]AT_YYLEX_DEFINE(["bbbbc"])[
+};
+]],
 [[%code {
 #include <stdio.h> /* printf */
   ]AT_YYERROR_DECLARE[
   ]AT_YYLEX_DECLARE[
 }
+]])[
 %debug
 ]$1[
 %define parse.error verbose
@@ -1359,13 +1369,15 @@ S: A B A A B A A A A B A A A A A A A B C C A A A A A A 
A A A A A A B ;
 //       ^                     ^                               ^
 // LAC reallocs
 
-A: 'a' | %empty { printf ("inconsistent default reduction\n"); } ;
+A: 'a' | %empty { ]AT_JAVA_IF([System.out.print], [printf])[ ("inconsistent 
default reduction\n"); } ;
 B: 'b' ;
-C: %empty { printf ("consistent default reduction\n"); } ;
+C: %empty { ]AT_JAVA_IF([System.out.print], [printf])[ ("consistent default 
reduction\n"); } ;
 
 %%
-]AT_YYERROR_DEFINE[
-]AT_YYLEX_DEFINE(["bbbbc"])[
+]AT_JAVA_IF([], [[
+  ]AT_YYERROR_DEFINE[
+  ]AT_YYLEX_DEFINE(["bbbbc"])[
+]])[
 
 ]AT_MAIN_DEFINE[
 ]])
@@ -1402,13 +1414,18 @@ AT_PERL_CHECK([[-0777 -ne 'print s/\bconsistent default 
reduction//g;' stdout.tx
 AT_BISON_OPTION_POPDEFS
 ])
 
+# C.
 AT_LAC_CHECK([[%define api.push-pull pull]])
 AT_LAC_CHECK([[%define api.push-pull pull %define api.pure]])
 AT_LAC_CHECK([[%define api.push-pull both]])
 AT_LAC_CHECK([[%define api.push-pull both %define api.pure]])
 
+# C++.
 AT_LAC_CHECK([[%skeleton "lalr1.cc"]])
 
+# Java.
+AT_LAC_CHECK([[%skeleton "lalr1.java"]])
+
 m4_popdef([AT_LAC_CHECK])
 
 AT_CLEANUP




reply via email to

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