[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Test token.prefix in all the skeletons.
From: |
Akim Demaille |
Subject: |
[PATCH] Test token.prefix in all the skeletons. |
Date: |
Sun, 7 Dec 2008 13:58:06 +0100 |
* data/java.m4 (b4_token_enum): Use the token.prefix.
* tests/local.at (AT_BISON_OPTION_PUSHDEFS): Define AT_TOKEN_PREFIX.
* tests/calc.at (_AT_DATA_CALC_Y): Use it.
Add checks for yacc.c, glr.c, lalr1.cc and glr.cc.
* tests/java.at: Comment changes.
(AT_CHECK_JAVA_MINIMAL): Define the END token.
(Java parser class and package names): Add token.prefix check.
---
ChangeLog | 11 +++++++++++
data/java.m4 | 2 +-
tests/calc.at | 8 ++++++--
tests/java.at | 26 +++++++++++++++-----------
tests/local.at | 5 ++++-
5 files changed, 37 insertions(+), 15 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3364675..c2b16f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2008-12-08 Akim Demaille <address@hidden>
+ Test token.prefix in all the skeletons.
+ * data/java.m4 (b4_token_enum): Use the token.prefix.
+ * tests/local.at (AT_BISON_OPTION_PUSHDEFS): Define AT_TOKEN_PREFIX.
+ * tests/calc.at (_AT_DATA_CALC_Y): Use it.
+ Add checks for yacc.c, glr.c, lalr1.cc and glr.cc.
+ * tests/java.at: Comment changes.
+ (AT_CHECK_JAVA_MINIMAL): Define the END token.
+ (Java parser class and package names): Add token.prefix check.
+
+2008-12-08 Akim Demaille <address@hidden>
+
Fix regeneration of atconfig.
* tests/local.mk (tests/atconfig): The rule was incorrect, but
remove it: now that there is no tests/Makefile.am, the top-level
diff --git a/data/java.m4 b/data/java.m4
index 4b33728..a56338f 100644
--- a/data/java.m4
+++ b/data/java.m4
@@ -147,7 +147,7 @@ m4_define([b4_integral_parser_table_define],
# Output the definition of this token as an enum.
m4_define([b4_token_enum],
[ /** Token number, to be returned by the scanner. */
- static final int $1 = $2;
+ static final int b4_percent_define_get([token.prefix])$1 = $2;
])
diff --git a/tests/calc.at b/tests/calc.at
index 14bd20f..afbb251 100644
--- a/tests/calc.at
+++ b/tests/calc.at
@@ -142,12 +142,12 @@ int
{
unget_char (]AT_LEX_PRE_ARGS[ c);
]AT_VAL[.ival = read_signed_integer (]AT_LEX_ARGS[);
- return NUM;
+ return ]AT_TOKEN_PREFIX[NUM;
}
/* Return end-of-file. */
if (c == EOF)
- return CALC_EOF;
+ return ]AT_TOKEN_PREFIX[CALC_EOF;
/* Return single chars. */
return c;
@@ -579,6 +579,7 @@ AT_CHECK_CALC_LALR([%define api.push_pull "both" %define
api.pure %locations])
AT_CHECK_CALC_LALR([%error-verbose %locations])
AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix "calc"
%verbose %yacc])
+AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix "calc"
%define token.prefix "TOK_" %verbose %yacc])
AT_CHECK_CALC_LALR([%debug])
AT_CHECK_CALC_LALR([%error-verbose %debug %locations %defines %name-prefix
"calc" %verbose %yacc])
@@ -619,6 +620,7 @@ AT_CHECK_CALC_GLR([%error-verbose %locations %defines
%name-prefix "calc" %verbo
AT_CHECK_CALC_GLR([%debug])
AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %name-prefix
"calc" %verbose %yacc])
+AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %name-prefix
"calc" %define token.prefix "TOK_" %verbose %yacc])
AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines
%name-prefix "calc" %verbose %yacc])
@@ -648,6 +650,7 @@ AT_CHECK_CALC_LALR1_CC([%locations %error-verbose
%name-prefix "calc" %verbose %
AT_CHECK_CALC_LALR1_CC([%locations %error-verbose %debug %name-prefix "calc"
%verbose %yacc])
AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %error-verbose %debug
%name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %error-verbose %debug
%name-prefix "calc" %define token.prefix "TOK_" %verbose %yacc])
AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %error-verbose %debug
%name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result}
%parse-param {int *count}])
@@ -676,5 +679,6 @@ AT_CHECK_CALC_GLR_CC([%debug])
AT_CHECK_CALC_GLR_CC([%error-verbose %debug %name-prefix "calc" %verbose
%yacc])
AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc"
%verbose %yacc])
+AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc"
%define token.prefix "TOK_" %verbose %yacc])
AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc"
%verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
diff --git a/tests/java.at b/tests/java.at
index 0e3122b..5e868dc 100644
--- a/tests/java.at
+++ b/tests/java.at
@@ -24,7 +24,7 @@ AT_BANNER([[Java Calculator.]])
# _AT_DATA_JAVA_CALC_Y($1, $2, $3, [BISON-DIRECTIVES])
-# ----------------------------------------------------------------------
+# ----------------------------------------------------
# Produce `calc.y'. Don't call this macro directly, because it contains
# some occurrences of `$1' etc. which will be interpreted by m4. So
# you should call it with $1, $2, and $3 as arguments, which is what
@@ -212,7 +212,7 @@ class Position {
# AT_DATA_CALC_Y([BISON-OPTIONS])
-# -------------------------------------------------
+# -------------------------------
# Produce `calc.y'.
m4_define([AT_DATA_JAVA_CALC_Y],
[_AT_DATA_JAVA_CALC_Y($[1], $[2], $[3], [$1])
@@ -275,7 +275,7 @@ AT_CHECK([cat stderr], 0, [expout])
])
# _AT_CHECK_JAVA_CALC([BISON-DIRECTIVES], [BISON-CODE])
-# -----------------------------------------------------------------------
+# -----------------------------------------------------
# Start a testing chunk which compiles `calc' grammar with
# BISON-DIRECTIVES, and performs several tests over the parser.
m4_define([_AT_CHECK_JAVA_CALC],
@@ -367,7 +367,7 @@ AT_CLEANUP
# AT_CHECK_JAVA_CALC([BISON-DIRECTIVES])
-# --------------------------------------------------------
+# --------------------------------------
# Start a testing chunk which compiles `calc' grammar with
# BISON-DIRECTIVES, and performs several tests over the parser.
# Run the test with and without %error-verbose.
@@ -420,9 +420,10 @@ AT_DATA([[YYParser.y]], [
%debug
%error-verbose
%token-table
+%token END "end"
$1
%%
-start: "end" {$2};
+start: END {$2};
%%
class m4_default([$3], [Position]) {}
])
@@ -474,9 +475,9 @@ m4_define([AT_CHECK_JAVA_GREP],
])
-# ----------------------------------- #
-# Java parser class and package names #
-# ----------------------------------- #
+# ------------------------------------- #
+# Java parser class and package names. #
+# ------------------------------------- #
AT_SETUP([Java parser class and package names])
@@ -486,6 +487,9 @@ AT_CHECK_JAVA_GREP([[class YYParser]])
AT_CHECK_JAVA_MINIMAL([[%name-prefix "Prefix"]])
AT_CHECK_JAVA_GREP([[class PrefixParser]])
+AT_CHECK_JAVA_MINIMAL([[%define token.prefix "TOK_"]])
+AT_CHECK_JAVA_GREP([[.*TOK_END.*]])
+
AT_CHECK_JAVA_MINIMAL([[%define parser_class_name "ParserClassName"]])
AT_CHECK_JAVA_GREP([[class ParserClassName]])
@@ -495,9 +499,9 @@ AT_CHECK_JAVA_GREP([[package user_java_package;]])
AT_CLEANUP
-# --------------------------- #
-# Java parser class modifiers #
-# --------------------------- #
+# ----------------------------- #
+# Java parser class modifiers. #
+# ----------------------------- #
AT_SETUP([Java parser class modifiers])
diff --git a/tests/local.at b/tests/local.at
index 7a95918..19f53ce 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -35,7 +35,7 @@ m4_define([AT_BISON_OPTION_PUSHDEFS],
# --------------------------------------------------
# This macro works around the impossibility to define macros
# inside macros, because issuing `[$1]' is not possible in M4 :(.
-# This sucks hard, GNU M4 should really provide M5 like $$1.
+# This sucks hard, GNU M4 should really provide M5-like $$1.
m4_define([_AT_BISON_OPTION_PUSHDEFS],
[m4_if([$1$2], $[1]$[2], [],
[m4_fatal([$0: Invalid arguments: address@hidden)])dnl
@@ -70,6 +70,9 @@ m4_pushdef([AT_NAME_PREFIX],
[m4_bmatch([$3], [%name-prefix ".*"],
[m4_bregexp([$3], [name-prefix "\([^"]*\)"], [\1])],
[yy])])
+m4_pushdef([AT_TOKEN_PREFIX],
+[m4_bmatch([$3], [%define token.prefix ".*"],
+ [m4_bregexp([$3], [%define token.prefix "\(.*\)"], [\1])])])
# yyerror receives the location if %location & %pure & (%glr or %parse-param).
m4_pushdef([AT_YYERROR_ARG_LOC_IF],
[AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],
--
1.6.0.4.790.gaa14a
- [PATCH] Test token.prefix in all the skeletons.,
Akim Demaille <=