Skip to content

Commit 417e31d

Browse files
committed
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.
1 parent 97abf54 commit 417e31d

File tree

5 files changed

+37
-15
lines changed

5 files changed

+37
-15
lines changed

ChangeLog

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2008-12-08 Akim Demaille <[email protected]>
2+
3+
Test token.prefix in all the skeletons.
4+
* data/java.m4 (b4_token_enum): Use the token.prefix.
5+
* tests/local.at (AT_BISON_OPTION_PUSHDEFS): Define AT_TOKEN_PREFIX.
6+
* tests/calc.at (_AT_DATA_CALC_Y): Use it.
7+
Add checks for yacc.c, glr.c, lalr1.cc and glr.cc.
8+
* tests/java.at: Comment changes.
9+
(AT_CHECK_JAVA_MINIMAL): Define the END token.
10+
(Java parser class and package names): Add token.prefix check.
11+
112
2008-12-08 Akim Demaille <[email protected]>
213

314
Fix regeneration of atconfig.

data/java.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ m4_define([b4_integral_parser_table_define],
147147
# Output the definition of this token as an enum.
148148
m4_define([b4_token_enum],
149149
[ /** Token number, to be returned by the scanner. */
150-
static final int $1 = $2;
150+
static final int b4_percent_define_get([token.prefix])$1 = $2;
151151
])
152152

153153

tests/calc.at

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,12 @@ int
142142
{
143143
unget_char (]AT_LEX_PRE_ARGS[ c);
144144
]AT_VAL[.ival = read_signed_integer (]AT_LEX_ARGS[);
145-
return NUM;
145+
return ]AT_TOKEN_PREFIX[NUM;
146146
}
147147

148148
/* Return end-of-file. */
149149
if (c == EOF)
150-
return CALC_EOF;
150+
return ]AT_TOKEN_PREFIX[CALC_EOF;
151151

152152
/* Return single chars. */
153153
return c;
@@ -579,6 +579,7 @@ AT_CHECK_CALC_LALR([%define api.push_pull "both" %define api.pure %locations])
579579
AT_CHECK_CALC_LALR([%error-verbose %locations])
580580

581581
AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix "calc" %verbose %yacc])
582+
AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix "calc" %define token.prefix "TOK_" %verbose %yacc])
582583

583584
AT_CHECK_CALC_LALR([%debug])
584585
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
619620

620621
AT_CHECK_CALC_GLR([%debug])
621622
AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
623+
AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %name-prefix "calc" %define token.prefix "TOK_" %verbose %yacc])
622624

623625
AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
624626

@@ -648,6 +650,7 @@ AT_CHECK_CALC_LALR1_CC([%locations %error-verbose %name-prefix "calc" %verbose %
648650
AT_CHECK_CALC_LALR1_CC([%locations %error-verbose %debug %name-prefix "calc" %verbose %yacc])
649651

650652
AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc])
653+
AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %error-verbose %debug %name-prefix "calc" %define token.prefix "TOK_" %verbose %yacc])
651654

652655
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}])
653656

@@ -676,5 +679,6 @@ AT_CHECK_CALC_GLR_CC([%debug])
676679
AT_CHECK_CALC_GLR_CC([%error-verbose %debug %name-prefix "calc" %verbose %yacc])
677680

678681
AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc])
682+
AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %define token.prefix "TOK_" %verbose %yacc])
679683

680684
AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])

tests/java.at

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ AT_BANNER([[Java Calculator.]])
2424

2525

2626
# _AT_DATA_JAVA_CALC_Y($1, $2, $3, [BISON-DIRECTIVES])
27-
# ----------------------------------------------------------------------
27+
# ----------------------------------------------------
2828
# Produce `calc.y'. Don't call this macro directly, because it contains
2929
# some occurrences of `$1' etc. which will be interpreted by m4. So
3030
# you should call it with $1, $2, and $3 as arguments, which is what
@@ -212,7 +212,7 @@ class Position {
212212

213213

214214
# AT_DATA_CALC_Y([BISON-OPTIONS])
215-
# -------------------------------------------------
215+
# -------------------------------
216216
# Produce `calc.y'.
217217
m4_define([AT_DATA_JAVA_CALC_Y],
218218
[_AT_DATA_JAVA_CALC_Y($[1], $[2], $[3], [$1])
@@ -275,7 +275,7 @@ AT_CHECK([cat stderr], 0, [expout])
275275
])
276276

277277
# _AT_CHECK_JAVA_CALC([BISON-DIRECTIVES], [BISON-CODE])
278-
# -----------------------------------------------------------------------
278+
# -----------------------------------------------------
279279
# Start a testing chunk which compiles `calc' grammar with
280280
# BISON-DIRECTIVES, and performs several tests over the parser.
281281
m4_define([_AT_CHECK_JAVA_CALC],
@@ -367,7 +367,7 @@ AT_CLEANUP
367367

368368

369369
# AT_CHECK_JAVA_CALC([BISON-DIRECTIVES])
370-
# --------------------------------------------------------
370+
# --------------------------------------
371371
# Start a testing chunk which compiles `calc' grammar with
372372
# BISON-DIRECTIVES, and performs several tests over the parser.
373373
# Run the test with and without %error-verbose.
@@ -420,9 +420,10 @@ AT_DATA([[YYParser.y]], [
420420
%debug
421421
%error-verbose
422422
%token-table
423+
%token END "end"
423424
$1
424425
%%
425-
start: "end" {$2};
426+
start: END {$2};
426427
%%
427428
class m4_default([$3], [Position]) {}
428429
])
@@ -474,9 +475,9 @@ m4_define([AT_CHECK_JAVA_GREP],
474475
])
475476

476477

477-
# ----------------------------------- #
478-
# Java parser class and package names #
479-
# ----------------------------------- #
478+
# ------------------------------------- #
479+
# Java parser class and package names. #
480+
# ------------------------------------- #
480481

481482
AT_SETUP([Java parser class and package names])
482483

@@ -486,6 +487,9 @@ AT_CHECK_JAVA_GREP([[class YYParser]])
486487
AT_CHECK_JAVA_MINIMAL([[%name-prefix "Prefix"]])
487488
AT_CHECK_JAVA_GREP([[class PrefixParser]])
488489

490+
AT_CHECK_JAVA_MINIMAL([[%define token.prefix "TOK_"]])
491+
AT_CHECK_JAVA_GREP([[.*TOK_END.*]])
492+
489493
AT_CHECK_JAVA_MINIMAL([[%define parser_class_name "ParserClassName"]])
490494
AT_CHECK_JAVA_GREP([[class ParserClassName]])
491495

@@ -495,9 +499,9 @@ AT_CHECK_JAVA_GREP([[package user_java_package;]])
495499
AT_CLEANUP
496500

497501

498-
# --------------------------- #
499-
# Java parser class modifiers #
500-
# --------------------------- #
502+
# ----------------------------- #
503+
# Java parser class modifiers. #
504+
# ----------------------------- #
501505

502506
AT_SETUP([Java parser class modifiers])
503507

tests/local.at

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ m4_define([AT_BISON_OPTION_PUSHDEFS],
3535
# --------------------------------------------------
3636
# This macro works around the impossibility to define macros
3737
# inside macros, because issuing `[$1]' is not possible in M4 :(.
38-
# This sucks hard, GNU M4 should really provide M5 like $$1.
38+
# This sucks hard, GNU M4 should really provide M5-like $$1.
3939
m4_define([_AT_BISON_OPTION_PUSHDEFS],
4040
[m4_if([$1$2], $[1]$[2], [],
4141
[m4_fatal([$0: Invalid arguments: $@])])dnl
@@ -70,6 +70,9 @@ m4_pushdef([AT_NAME_PREFIX],
7070
[m4_bmatch([$3], [%name-prefix ".*"],
7171
[m4_bregexp([$3], [name-prefix "\([^"]*\)"], [\1])],
7272
[yy])])
73+
m4_pushdef([AT_TOKEN_PREFIX],
74+
[m4_bmatch([$3], [%define token.prefix ".*"],
75+
[m4_bregexp([$3], [%define token.prefix "\(.*\)"], [\1])])])
7376
# yyerror receives the location if %location & %pure & (%glr or %parse-param).
7477
m4_pushdef([AT_YYERROR_ARG_LOC_IF],
7578
[AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],

0 commit comments

Comments
 (0)