* 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 <demaille@gostai.com>
+
+ 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 <demaille@gostai.com>
Fix regeneration of atconfig.
# 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;
])
{
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;
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])
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])
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}])
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}])
# _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
# 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])
])
# _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],
# 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.
%debug
%error-verbose
%token-table
+%token END "end"
$1
%%
-start: "end" {$2};
+start: END {$2};
%%
class m4_default([$3], [Position]) {}
])
])
-# ----------------------------------- #
-# Java parser class and package names #
-# ----------------------------------- #
+# ------------------------------------- #
+# Java parser class and package names. #
+# ------------------------------------- #
AT_SETUP([Java parser class and package names])
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]])
AT_CLEANUP
-# --------------------------- #
-# Java parser class modifiers #
-# --------------------------- #
+# ----------------------------- #
+# Java parser class modifiers. #
+# ----------------------------- #
AT_SETUP([Java parser class modifiers])
# --------------------------------------------------
# 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: $@])])dnl
[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])],