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.
This commit is contained in:
Akim Demaille
2008-12-07 13:58:06 +01:00
parent 97abf54412
commit 417e31d2c3
5 changed files with 37 additions and 15 deletions

View File

@@ -1,3 +1,14 @@
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> 2008-12-08 Akim Demaille <demaille@gostai.com>
Fix regeneration of atconfig. Fix regeneration of atconfig.

View File

@@ -147,7 +147,7 @@ m4_define([b4_integral_parser_table_define],
# Output the definition of this token as an enum. # Output the definition of this token as an enum.
m4_define([b4_token_enum], m4_define([b4_token_enum],
[ /** Token number, to be returned by the scanner. */ [ /** Token number, to be returned by the scanner. */
static final int $1 = $2; static final int b4_percent_define_get([token.prefix])$1 = $2;
]) ])

View File

@@ -142,12 +142,12 @@ int
{ {
unget_char (]AT_LEX_PRE_ARGS[ c); unget_char (]AT_LEX_PRE_ARGS[ c);
]AT_VAL[.ival = read_signed_integer (]AT_LEX_ARGS[); ]AT_VAL[.ival = read_signed_integer (]AT_LEX_ARGS[);
return NUM; return ]AT_TOKEN_PREFIX[NUM;
} }
/* Return end-of-file. */ /* Return end-of-file. */
if (c == EOF) if (c == EOF)
return CALC_EOF; return ]AT_TOKEN_PREFIX[CALC_EOF;
/* Return single chars. */ /* Return single chars. */
return c; 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])
AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix "calc" %verbose %yacc]) 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([%debug])
AT_CHECK_CALC_LALR([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc]) 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([%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" %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_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 %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" %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_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([%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" %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_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])

View File

@@ -24,7 +24,7 @@ AT_BANNER([[Java Calculator.]])
# _AT_DATA_JAVA_CALC_Y($1, $2, $3, [BISON-DIRECTIVES]) # _AT_DATA_JAVA_CALC_Y($1, $2, $3, [BISON-DIRECTIVES])
# ---------------------------------------------------------------------- # ----------------------------------------------------
# Produce `calc.y'. Don't call this macro directly, because it contains # Produce `calc.y'. Don't call this macro directly, because it contains
# some occurrences of `$1' etc. which will be interpreted by m4. So # 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 # 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]) # AT_DATA_CALC_Y([BISON-OPTIONS])
# ------------------------------------------------- # -------------------------------
# Produce `calc.y'. # Produce `calc.y'.
m4_define([AT_DATA_JAVA_CALC_Y], m4_define([AT_DATA_JAVA_CALC_Y],
[_AT_DATA_JAVA_CALC_Y($[1], $[2], $[3], [$1]) [_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]) # _AT_CHECK_JAVA_CALC([BISON-DIRECTIVES], [BISON-CODE])
# ----------------------------------------------------------------------- # -----------------------------------------------------
# Start a testing chunk which compiles `calc' grammar with # Start a testing chunk which compiles `calc' grammar with
# BISON-DIRECTIVES, and performs several tests over the parser. # BISON-DIRECTIVES, and performs several tests over the parser.
m4_define([_AT_CHECK_JAVA_CALC], m4_define([_AT_CHECK_JAVA_CALC],
@@ -367,7 +367,7 @@ AT_CLEANUP
# AT_CHECK_JAVA_CALC([BISON-DIRECTIVES]) # AT_CHECK_JAVA_CALC([BISON-DIRECTIVES])
# -------------------------------------------------------- # --------------------------------------
# Start a testing chunk which compiles `calc' grammar with # Start a testing chunk which compiles `calc' grammar with
# BISON-DIRECTIVES, and performs several tests over the parser. # BISON-DIRECTIVES, and performs several tests over the parser.
# Run the test with and without %error-verbose. # Run the test with and without %error-verbose.
@@ -420,9 +420,10 @@ AT_DATA([[YYParser.y]], [
%debug %debug
%error-verbose %error-verbose
%token-table %token-table
%token END "end"
$1 $1
%% %%
start: "end" {$2}; start: END {$2};
%% %%
class m4_default([$3], [Position]) {} 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]) 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_MINIMAL([[%name-prefix "Prefix"]])
AT_CHECK_JAVA_GREP([[class PrefixParser]]) 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_MINIMAL([[%define parser_class_name "ParserClassName"]])
AT_CHECK_JAVA_GREP([[class ParserClassName]]) AT_CHECK_JAVA_GREP([[class ParserClassName]])
@@ -495,9 +499,9 @@ AT_CHECK_JAVA_GREP([[package user_java_package;]])
AT_CLEANUP AT_CLEANUP
# --------------------------- # # ----------------------------- #
# Java parser class modifiers # # Java parser class modifiers. #
# --------------------------- # # ----------------------------- #
AT_SETUP([Java parser class modifiers]) AT_SETUP([Java parser class modifiers])

View File

@@ -35,7 +35,7 @@ m4_define([AT_BISON_OPTION_PUSHDEFS],
# -------------------------------------------------- # --------------------------------------------------
# This macro works around the impossibility to define macros # This macro works around the impossibility to define macros
# inside macros, because issuing `[$1]' is not possible in M4 :(. # 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_define([_AT_BISON_OPTION_PUSHDEFS],
[m4_if([$1$2], $[1]$[2], [], [m4_if([$1$2], $[1]$[2], [],
[m4_fatal([$0: Invalid arguments: $@])])dnl [m4_fatal([$0: Invalid arguments: $@])])dnl
@@ -70,6 +70,9 @@ m4_pushdef([AT_NAME_PREFIX],
[m4_bmatch([$3], [%name-prefix ".*"], [m4_bmatch([$3], [%name-prefix ".*"],
[m4_bregexp([$3], [name-prefix "\([^"]*\)"], [\1])], [m4_bregexp([$3], [name-prefix "\([^"]*\)"], [\1])],
[yy])]) [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). # yyerror receives the location if %location & %pure & (%glr or %parse-param).
m4_pushdef([AT_YYERROR_ARG_LOC_IF], m4_pushdef([AT_YYERROR_ARG_LOC_IF],
[AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])], [AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],