[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/8] tests: de-duplicate
From: |
Akim Demaille |
Subject: |
[PATCH 2/8] tests: de-duplicate |
Date: |
Thu, 21 Feb 2019 07:09:40 +0100 |
* tests/conflicts.at (AT_YYLEX_PROTOTYPE): Don't define it, leave that
task to AT_DATA_GRAMMAR.
But be honest: tell AT_BISON_OPTION_PUSHDEFS all the options we use.
---
tests/conflicts.at | 68 ++++++++++++++++++++--------------------------
1 file changed, 29 insertions(+), 39 deletions(-)
diff --git a/tests/conflicts.at b/tests/conflicts.at
index edd86600..5ae1e02b 100644
--- a/tests/conflicts.at
+++ b/tests/conflicts.at
@@ -402,11 +402,7 @@ m4_pushdef([AT_CONSISTENT_ERRORS_CHECK], [
AT_SETUP([[parse.error=verbose and consistent errors: ]$1])
-AT_BISON_OPTION_PUSHDEFS([$1])
-
-m4_pushdef([AT_YYLEX_PROTOTYPE],
-[AT_CXX_IF([[int yylex (yy::parser::semantic_type *lvalp)]],
- [[int yylex (YYSTYPE *lvalp)]])])
+AT_BISON_OPTION_PUSHDEFS([$1 AT_CXX_IF([[%defines]], [[%define api.pure]])])
AT_JAVA_IF([AT_DATA], [AT_DATA_GRAMMAR])([input.y],
[AT_JAVA_IF([[
@@ -415,12 +411,10 @@ AT_JAVA_IF([AT_DATA], [AT_DATA_GRAMMAR])([input.y],
import java.io.IOException;
}]], [[
-%code {]AT_CXX_IF([[
- #include <string>]], [[
+%code {
#include <assert.h>
- #include <stdio.h>
- ]AT_YYERROR_DECLARE])[
- ]AT_YYLEX_PROTOTYPE[;
+ ]AT_YYERROR_DECLARE[
+ ]AT_YYLEX_DECLARE[
#define USE(Var)
}
@@ -442,37 +436,34 @@ AT_JAVA_IF([AT_DATA], [AT_DATA_GRAMMAR])([input.y],
]$2[
-]AT_JAVA_IF([[%code lexer {]], [[%%]])[
+]AT_JAVA_IF([[%code lexer {
+
+ /*--------.
+ | yylex. |
+ `--------*/
+
+ public String input = "]$3[";
+ public int index = 0;
+ public int yylex ()
+ {
+ if (index < input.length ())
+ return input.charAt (index++);
+ else
+ return 0;
+ }
+ public Object getLVal ()
+ {
+ return new Integer(1);
+ }
-/*--------.
-| yylex. |
-`--------*/]AT_JAVA_IF([[
-
-public String input = "]$3[";
-public int index = 0;
-public int yylex ()
-{
- if (index < input.length ())
- return input.charAt (index++);
- else
- return 0;
-}
-public Object getLVal ()
-{
- return new Integer(1);
-}]], [[
-
-]AT_YYLEX_PROTOTYPE[
-{
- static char const *input = "]$3[";
- *lvalp = 1;
- return *input++;
-}]])[
]AT_YYERROR_DEFINE[
-]AT_JAVA_IF([[
};
-
-%%]])[
+%%
+]], [[
+%%
+]AT_YYLEX_DEFINE(["$3"], [[*lvalp = 1]])[
+]AT_YYERROR_DEFINE[
+]])[
/*-------.
| main. |
@@ -493,7 +484,6 @@ AT_JAVA_IF([AT_JAVA_PARSER_CHECK([[input]], [[0]]],
]])
m4_popdef([AT_EXPECTING])
-m4_popdef([AT_YYLEX_PROTOTYPE])
AT_BISON_OPTION_POPDEFS
AT_CLEANUP
--
2.20.1
- [PATCH 0/8] Clean up the tests, Akim Demaille, 2019/02/21
- [PATCH 1/8] tests: formatting changes, Akim Demaille, 2019/02/21
- [PATCH 5/8] tests: java: factor the definition of Position, Akim Demaille, 2019/02/21
- [PATCH 2/8] tests: de-duplicate,
Akim Demaille <=
- [PATCH 8/8] tests: factor the execution of Java parsers, Akim Demaille, 2019/02/21
- [PATCH 3/8] tests: dispatch per lang on the definition of yylex, Akim Demaille, 2019/02/21
- [PATCH 7/8] tests: fix a Java tests, Akim Demaille, 2019/02/21
- [PATCH 6/8] tests: simplify AT_PARSER_CHECK usage, Akim Demaille, 2019/02/21
- [PATCH 4/8] tests: dispatch per lang on AT_DATA_GRAMMAR, Akim Demaille, 2019/02/21