bison-patches
[Top][All Lists]
Advanced

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

[PATCH 5/8] tests: java: factor the definition of Position


From: Akim Demaille
Subject: [PATCH 5/8] tests: java: factor the definition of Position
Date: Thu, 21 Feb 2019 07:09:43 +0100

* tests/local.at (AT_JAVA_POSITION_DEFINE): New.
* tests/java.at, tests/javapush.at: Use it.
---
 tests/java.at     | 38 +-------------------------------------
 tests/javapush.at | 25 +------------------------
 tests/local.at    | 41 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 43 insertions(+), 61 deletions(-)

diff --git a/tests/java.at b/tests/java.at
index 22bc5ca1..50b72968 100644
--- a/tests/java.at
+++ b/tests/java.at
@@ -158,43 +158,7 @@ AT_LOCATION_IF([[
 };
 %%]], [[
 }]])[
-
-class Position {
-  public int line;
-  public int token;
-
-  public Position ()
-  {
-    line = 0;
-    token = 0;
-  }
-
-  public Position (int l, int t)
-  {
-    line = l;
-    token = t;
-  }
-
-  public boolean equals (Position l)
-  {
-    return l.line == line && l.token == token;
-  }
-
-  public String toString ()
-  {
-    return Integer.toString (line) + "." + Integer.toString(token);
-  }
-
-  public int lineno ()
-  {
-    return line;
-  }
-
-  public int token ()
-  {
-    return token;
-  }
-}
+]AT_JAVA_POSITION_DEFINE[
 ]])
 
 AT_BISON_OPTION_POPDEFS
diff --git a/tests/javapush.at b/tests/javapush.at
index 43c60e83..829d988e 100644
--- a/tests/javapush.at
+++ b/tests/javapush.at
@@ -673,30 +673,7 @@ AT_DATA([Calc.y],[[/* Infix notation calculator--calc.  */
   }
 }
 
-%code {
-class Position {
-  public int line;
-  public int token;
-
-  public Position () { line = 0; token = 0; }
-
-  public Position (int l, int t) { line = l; token = t; }
-
-  public boolean equals (Position l)
-  {
-    return l.line == line && l.token == token;
-  }
-
-  public String toString ()
-  {
-    return Integer.toString(line)  + "." + Integer.toString(token);
-  }
-
-  public int lineno () { return line; }
-
-  public int token () { return token; }
-}//Class Position
-}
+%code { ]AT_JAVA_POSITION_DEFINE[ }
 
 %code {
 public static void main (String[] argv)
diff --git a/tests/local.at b/tests/local.at
index 74ac18c6..24d31fe4 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -643,6 +643,47 @@ CXXFLAGS=$at_for_each_std_CXXFLAGS_save
 m4_copy([AT_DATA], [AT_DATA_GRAMMAR(java)])
 
 
+# AT_JAVA_POSITION_DEFINE
+# -----------------------
+m4_define([AT_JAVA_POSITION_DEFINE],
+[[class Position {
+  public int line;
+  public int token;
+
+  public Position ()
+  {
+    line = 0;
+    token = 0;
+  }
+
+  public Position (int l, int t)
+  {
+    line = l;
+    token = t;
+  }
+
+  public boolean equals (Position l)
+  {
+    return l.line == line && l.token == token;
+  }
+
+  public String toString ()
+  {
+    return Integer.toString (line) + "." + Integer.toString(token);
+  }
+
+  public int lineno ()
+  {
+    return line;
+  }
+
+  public int token ()
+  {
+    return token;
+  }
+}]])
+
+
 m4_define([AT_YYERROR_DEFINE(java)],
 [AT_LOCATION_IF([[public void yyerror (Calc.Location l, String s)
 {
-- 
2.20.1




reply via email to

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