[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: %push-* -> %define push_pull
From: |
Joel E. Denny |
Subject: |
Re: %push-* -> %define push_pull |
Date: |
Mon, 29 Oct 2007 13:12:13 -0400 (EDT) |
On Mon, 29 Oct 2007, Paolo Bonzini wrote:
>
> > /**
> > * Entry point for the scanner. Returns the token identifier
> > corresponding
> > * to the next token and ]b4_pure_if([prepares to return], [stores])[
> > * the semantic value]b4_locations_if([ and beginning/ending positions])[
> > * of the token.
> > * @@return the token identifier corresponding to the next token. */
> > int yylex () ]b4_maybe_throws([b4_lex_throws])[;
> >
> > Aren't Java interfaces always pure? That is, it seems that the user should
> > be warned that `%define api.pure' has no effect for Java.
>
> Yes, I have a patch for that but I never finished it. Will work on it soon.
Great. Thanks.
The following patch implements `%define api.pure' except that it doesn't
update the skeleton or documentation for Java. Thus, b4_pure_if ends up
unexpanded in comments in the generated Java code from above. This
doesn't break anything, I believe. It just looks ugly. If you plan to
follow soon with your patch, then I'll go ahead and commit mine anyway.
Is that ok with you?
Index: ChangeLog
===================================================================
RCS file: /sources/bison/bison/ChangeLog,v
retrieving revision 1.1744
diff -p -u -r1.1744 ChangeLog
--- ChangeLog 28 Oct 2007 20:11:33 -0000 1.1744
+++ ChangeLog 29 Oct 2007 16:58:10 -0000
@@ -1,5 +1,50 @@
2007-10-28 Joel E. Denny <address@hidden>
+ Deprecate %pure-parser and add `%define api.pure'. Discussed starting
+ at
+ <http://lists.gnu.org/archive/html/bison-patches/2007-09/msg00006.html>.
+ * NEWS (2.3a+): Mention.
+ * data/bison.m4 (b4_pure_if): Don't define it here.
+ * data/c.m4 (b4_identification): Depend on individual skeletons to
+ define b4_pure_flag, b4_push_flag, or b4_pull_flag if they use the
+ values of the %define variables api.pure or api.push_pull. Define
+ YYPURE, YYPUSH, and YYPULL accordingly.
+ * data/glr.c: Define b4_pure_if based on `%define api.pure' unless
+ glr.cc has already defined b4_pure_flag.
+ * data/push.c: Define b4_pure_if based on `%define api.pure'.
+ Remove YYPUSH and YYPULL since they're back in b4_identification again.
+ * data/yacc.c Define b4_pure_if based on `%define api.pure'.
+ * doc/bison.texinfo (Pure Decl): Update.
+ (Push Decl): Update.
+ (Decl Summary): Add api.pure to %define entry.
+ In %pure-parser entry, say it's deprecated and reference %define.
+ (Pure Calling): Update.
+ (Error Reporting): Update.
+ (C++ Scanner Interface): Update.
+ (How Can I Reset the Parser): Update.
+ (Table of Symbols): In %pure-parser entry, say it's deprecated and
+ reference %define.
+ * src/getargs.c (pure_parser): Remove global variable.
+ * src/getargs.h (pure_parser): Remove extern.
+ * src/output.c (prepare): Don't define pure_flag muscle.
+ * src/parse-gram.y (prologue_declaration): Implement %pure-parser as a
+ wrapper around `%define api.pure'.
+ * tests/calc.at (Simple LALR Calculator): Update.
+ (Simple GLR Calculator): Update.
+ * tests/cxx-type.at (GLR: Resolve ambiguity, pure, no locations):
+ Update.
+ (GLR: Resolve ambiguity, pure, locations): Update.
+ (GLR: Merge conflicting parses, pure, no locations): Update.
+ (GLR: Merge conflicting parses, pure, locations): Update.
+ * tests/glr-regression.at (Uninitialized location when reporting
+ ambiguity): Update
+ * tests/input.at (Unused %define api.pure): New test case.
+ * tests/local.at (_AT_BISON_OPTION_PUSHDEFS): Update definition for
+ AT_PURE_IF and AT_PURE_AND_LOC_IF.
+ * tests/push.at (Push Parsing: Memory Leak for Early Deletion): Update.
+
+2007-10-28 Joel E. Denny <address@hidden>
+
%define push_pull -> %define api.push_pull. Discussed starting at
<http://lists.gnu.org/archive/html/bison-patches/2007-09/msg00005.html>.
* data/push.c: Expect the new name.
Index: NEWS
===================================================================
RCS file: /sources/bison/bison/NEWS,v
retrieving revision 1.179
diff -p -u -r1.179 NEWS
--- NEWS 28 Oct 2007 20:11:34 -0000 1.179
+++ NEWS 29 Oct 2007 16:58:11 -0000
@@ -3,6 +3,18 @@ Bison News
Changes in version 2.3a+ (????-??-??):
+* The quotes around NAME that used to be required in the following directive
+ are now deprecated:
+
+ %define NAME "VALUE"
+
+* The directive `%pure-parser' is now deprecated in favor of:
+
+ %define api.pure
+
+ which has the same effect except that Bison is more careful to warn about
+ unreasonable usage in the latter case.
+
* Push Parsing
Bison can now generate an LALR(1) parser in C with a push interface. That
@@ -69,11 +81,6 @@ Changes in version 2.3a+ (????-??-??):
%name-prefix "c_"
%output "parser.c"
-* The quotes around NAME that used to be required in the following directive
- are now deprecated:
-
- %define NAME "VALUE"
-
* An Alternative to `%{...%}' -- `%code QUALIFIER {CODE}'
Bison 2.3a provided a new set of directives as a more flexible alternative to
Index: data/bison.m4
===================================================================
RCS file: /sources/bison/bison/data/bison.m4,v
retrieving revision 1.23
diff -p -u -r1.23 bison.m4
--- data/bison.m4 8 Oct 2007 04:00:13 -0000 1.23
+++ data/bison.m4 29 Oct 2007 16:58:11 -0000
@@ -249,7 +249,6 @@ b4_define_flag_if([error_verbose]) # Whe
b4_define_flag_if([glr]) # Whether a GLR parser is requested.
b4_define_flag_if([locations]) # Whether locations are tracked.
b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled.
-b4_define_flag_if([pure]) # Whether the interface is pure.
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
Index: data/c.m4
===================================================================
RCS file: /sources/bison/bison/data/c.m4,v
retrieving revision 1.73
diff -p -u -r1.73 c.m4
--- data/c.m4 25 Sep 2007 05:47:25 -0000 1.73
+++ data/c.m4 29 Oct 2007 16:58:11 -0000
@@ -28,22 +28,31 @@ m4_define([b4_comment], [/* m4_bpatsubst
# b4_identification
# -----------------
+# Depends on individual skeletons to define b4_pure_flag, b4_push_flag, or
+# b4_pull_flag if they use the values of the %define variables api.pure or
+# api.push_pull.
m4_define([b4_identification],
-[/* Identify Bison output. */
-[#]define YYBISON 1
+[[/* Identify Bison output. */
+#define YYBISON 1
/* Bison version. */
-[#]define YYBISON_VERSION "b4_version"
+#define YYBISON_VERSION "]b4_version["
/* Skeleton name. */
-[#]define YYSKELETON_NAME b4_skeleton
+#define YYSKELETON_NAME ]b4_skeleton[]m4_ifdef([b4_pure_flag], [[
/* Pure parsers. */
-[#]define YYPURE b4_pure_flag
+#define YYPURE ]b4_pure_flag])[]m4_ifdef([b4_push_flag], [[
+
+/* Push parsers. */
+#define YYPUSH ]b4_push_flag])[]m4_ifdef([b4_pull_flag], [[
+
+/* Pull parsers. */
+#define YYPULL ]b4_pull_flag])[
/* Using locations. */
-[#]define YYLSP_NEEDED b4_locations_flag
-])
+#define YYLSP_NEEDED ]b4_locations_flag[
+]])
## ---------------- ##
Index: data/glr.c
===================================================================
RCS file: /sources/bison/bison/data/glr.c,v
retrieving revision 1.208
diff -p -u -r1.208 glr.c
--- data/glr.c 25 Sep 2007 05:47:25 -0000 1.208
+++ data/glr.c 29 Oct 2007 16:58:12 -0000
@@ -34,6 +34,13 @@ m4_define_default([b4_stack_depth_init],
## Pure/impure interfaces. ##
## ------------------------ ##
+b4_define_flag_if([pure])
+# If glr.cc is including this file and thus has already set b4_pure_flag, don't
+# change the value of b4_pure_flag, and don't record a use of api.pure.
+m4_ifndef([b4_pure_flag],
+[b4_percent_define_default([[api.pure]], [[false]])
+ m4_define([b4_pure_flag],
+ [b4_percent_define_flag_if([[api.pure]], [[1]], [[0]])])])
# b4_user_formals
# ---------------
Index: data/push.c
===================================================================
RCS file: /sources/bison/bison/data/push.c,v
retrieving revision 1.43
diff -p -u -r1.43 push.c
--- data/push.c 28 Oct 2007 20:11:34 -0000 1.43
+++ data/push.c 29 Oct 2007 16:58:12 -0000
@@ -51,6 +51,10 @@ m4_define_default([b4_stack_depth_init],
## Pure/impure interfaces. ##
## ------------------------ ##
+b4_percent_define_default([[api.pure]], [[false]])
+b4_define_flag_if([pure])
+m4_define([b4_pure_flag],
+ [b4_percent_define_flag_if([[api.pure]], [[1]], [[0]])])
# b4_yacc_pure_if(IF-TRUE, IF-FALSE)
# ----------------------------------
@@ -163,14 +167,9 @@ b4_copyright([Skeleton implementation fo
define necessary library symbols; they are noted "INFRINGES ON
USER NAME SPACE" below. */
-]b4_identification[
-/* Push parsers. */
-#define YYPUSH ]b4_push_flag[
+]b4_identification
-/* Pull parsers. */
-#define YYPULL ]b4_pull_flag[
-
-]b4_percent_code_get([[top]])[]dnl
+b4_percent_code_get([[top]])[]dnl
m4_if(b4_prefix, [yy], [],
[[/* Substitute the variable and function names. */
]b4_pull_if([[#define yyparse ]b4_prefix[parse
Index: data/yacc.c
===================================================================
RCS file: /sources/bison/bison/data/yacc.c,v
retrieving revision 1.168
diff -p -u -r1.168 yacc.c
--- data/yacc.c 28 Oct 2007 20:11:34 -0000 1.168
+++ data/yacc.c 29 Oct 2007 16:58:13 -0000
@@ -37,6 +37,10 @@ m4_define_default([b4_stack_depth_init],
## Pure/impure interfaces. ##
## ------------------------ ##
+b4_percent_define_default([[api.pure]], [[false]])
+b4_define_flag_if([pure])
+m4_define([b4_pure_flag],
+ [b4_percent_define_flag_if([[api.pure]], [[1]], [[0]])])
# b4_yacc_pure_if(IF-TRUE, IF-FALSE)
# ----------------------------------
Index: doc/bison.texinfo
===================================================================
RCS file: /sources/bison/bison/doc/bison.texinfo,v
retrieving revision 1.242
diff -p -u -r1.242 bison.texinfo
--- doc/bison.texinfo 28 Oct 2007 20:11:34 -0000 1.242
+++ doc/bison.texinfo 29 Oct 2007 16:58:16 -0000
@@ -4487,7 +4487,7 @@ may override this restriction with the @
@subsection A Pure (Reentrant) Parser
@cindex reentrant parser
@cindex pure parser
address@hidden %pure-parser
address@hidden %define api.pure
A @dfn{reentrant} program is one which does not alter in the course of
execution; in other words, it consists entirely of @dfn{pure} (read-only)
@@ -4503,11 +4503,11 @@ statically allocated variables for commu
including @code{yylval} and @code{yylloc}.)
Alternatively, you can generate a pure, reentrant parser. The Bison
-declaration @code{%pure-parser} says that you want the parser to be
+declaration @code{%define api.pure} says that you want the parser to be
reentrant. It looks like this:
@example
-%pure-parser
+%define api.pure
@end example
The result is that the communication variables @code{yylval} and
@@ -4554,7 +4554,7 @@ compatibility with the impure Yacc pull
what you are doing, your declarations should look like this:
@example
-%pure-parser
+%define api.pure
%define api.push_pull "push"
@end example
@@ -4627,8 +4627,8 @@ yypull_parse (ps); /* Will call the lexe
yypstate_delete (ps);
@end example
-Adding the @code{%pure-parser} declaration does exactly the same thing to the
-generated parser with @code{%define api.push_pull "both"} as it did for
+Adding the @code{%define api.pure} declaration does exactly the same thing to
+the generated parser with @code{%define api.push_pull "both"} as it did for
@code{%define api.push_pull "push"}.
@node Decl Summary
@@ -4837,6 +4837,20 @@ target language and/or parser skeleton.
Some of the accepted @var{variable}s are:
@itemize @bullet
address@hidden api.pure
address@hidden %define api.pure
+
address@hidden @bullet
address@hidden Language(s): C
+
address@hidden Purpose: Request a pure (reentrant) parser program.
address@hidden Decl, ,A Pure (Reentrant) Parser}.
+
address@hidden Accepted Values: Boolean
+
address@hidden Default Value: @code{"false"}
address@hidden itemize
+
@item api.push_pull
@findex %define api.push_pull
@@ -5054,8 +5068,8 @@ Specify @var{file} for the parser file.
@end deffn
@deffn {Directive} %pure-parser
-Request a pure (reentrant) parser program (@pxref{Pure Decl, ,A Pure
-(Reentrant) Parser}).
+Deprecated version of @code{%define api.pure} (@pxref{Decl Summary, ,%define}),
+for which Bison is more careful to warn about unreasonable usage.
@end deffn
@deffn {Directive} %require "@var{version}"
@@ -5498,7 +5512,7 @@ The data type of @code{yylloc} has the n
@node Pure Calling
@subsection Calling Conventions for Pure Parsers
-When you use the Bison declaration @code{%pure-parser} to request a
+When you use the Bison declaration @code{%define api.pure} to request a
pure, reentrant parser, the global communication variables @code{yylval}
and @code{yylloc} cannot be used. (@xref{Pure Decl, ,A Pure (Reentrant)
Parser}.) In such parsers the two global variables are replaced by
@@ -5549,7 +5563,7 @@ int yylex (int *nastiness);
int yyparse (int *nastiness, int *randomness);
@end example
-If @code{%pure-parser} is added:
+If @code{%define api.pure} is added:
@example
int yylex (YYSTYPE *lvalp, int *nastiness);
@@ -5557,7 +5571,7 @@ int yyparse (int *nastiness, int *random
@end example
@noindent
-and finally, if both @code{%pure-parser} and @code{%locations} are used:
+and finally, if both @code{%define api.pure} and @code{%locations} are used:
@example
int yylex (YYSTYPE *lvalp, YYLTYPE *llocp, int *nastiness);
@@ -5623,7 +5637,7 @@ Obviously, in location tracking pure par
an access to the current location.
This is indeed the case for the @acronym{GLR}
parsers, but not for the Yacc parser, for historical reasons. I.e., if
address@hidden %pure-parser} is passed then the prototypes for
address@hidden %define api.pure} is passed then the prototypes for
@code{yyerror} are:
@example
@@ -5641,13 +5655,14 @@ void yyerror (int *nastiness, char const
Finally, @acronym{GLR} and Yacc parsers share the same @code{yyerror} calling
convention for absolutely pure parsers, i.e., when the calling
convention of @code{yylex} @emph{and} the calling convention of
address@hidden are pure. I.e.:
address@hidden api.pure} are pure.
+I.e.:
@example
/* Location tracking. */
%locations
/* Pure yylex. */
-%pure-parser
+%define api.pure
%lex-param @{int address@hidden
/* Pure yyparse. */
%parse-param @{int address@hidden
@@ -8108,7 +8123,7 @@ described by @var{m}.
The parser invokes the scanner by calling @code{yylex}. Contrary to C
parsers, C++ parsers are always pure: there is no point in using the
address@hidden directive. Therefore the interface is as follows.
address@hidden api.pure} directive. Therefore the interface is as follows.
@deftypemethod {parser} {int} yylex (semantic_value_type& @var{yylval},
location_type& @var{yylloc}, @var{type1} @var{arg1}, ...)
Return the next token. Its type is the return value, its semantic
@@ -8860,10 +8875,9 @@ The return type can be changed using @sa
@end deftypemethod
-If @code{%pure-parser} is not specified, the lexer interface
-resides in the same class (@code{YYParser}) as the Bison-generated
-parser. The fields and methods that are provided to
-this end are as follows.
+The lexer interface resides in the same class (@code{YYParser}) as the
+Bison-generated parser.
+The fields and methods that are provided to this end are as follows.
@deftypemethod {YYParser} {void} error (Location @var{l}, String @var{m})
As explained in @pxref{Java Parser Interface}, this method is defined
@@ -8996,7 +9010,7 @@ or
@display
My parser includes support for an @samp{#include}-like feature, in
which case I run @code{yyparse} from @code{yyparse}. This fails
-although I did specify I needed a @code{%pure-parser}.
+although I did specify @code{%define api.pure}.
@end display
These problems typically come not from Bison itself, but from
@@ -9558,8 +9572,8 @@ Bison declaration to assign a precedence
@end deffn
@deffn {Directive} %pure-parser
-Bison declaration to request a pure (reentrant) parser.
address@hidden Decl, ,A Pure (Reentrant) Parser}.
+Deprecated version of @code{%define api.pure} (@pxref{Decl Summary, ,%define}),
+for which Bison is more careful to warn about unreasonable usage.
@end deffn
@deffn {Directive} %require "@var{version}"
Index: src/getargs.c
===================================================================
RCS file: /sources/bison/bison/src/getargs.c,v
retrieving revision 1.98
diff -p -u -r1.98 getargs.c
--- src/getargs.c 9 Oct 2007 08:57:14 -0000 1.98
+++ src/getargs.c 29 Oct 2007 16:58:17 -0000
@@ -59,7 +59,6 @@ bool error_verbose = false;
bool nondeterministic_parser = false;
bool glr_parser = false;
-bool pure_parser = false;
int report_flag = report_none;
int trace_flag = trace_none;
Index: src/getargs.h
===================================================================
RCS file: /sources/bison/bison/src/getargs.h,v
retrieving revision 1.43
diff -p -u -r1.43 getargs.h
--- src/getargs.h 25 Sep 2007 05:47:26 -0000 1.43
+++ src/getargs.h 29 Oct 2007 16:58:17 -0000
@@ -51,11 +51,6 @@ extern bool error_verbose;
extern bool glr_parser;
-/* PURE_PARSER is true if should generate a parser that is all pure
- and reentrant. */
-
-extern bool pure_parser;
-
/* NONDETERMINISTIC_PARSER is true iff conflicts are accepted. This
is used by the GLR parser, and might be used in BackTracking
parsers too. */
Index: src/output.c
===================================================================
RCS file: /sources/bison/bison/src/output.c,v
retrieving revision 1.270
diff -p -u -r1.270 output.c
--- src/output.c 5 Oct 2007 02:54:33 -0000 1.270
+++ src/output.c 29 Oct 2007 16:58:17 -0000
@@ -571,7 +571,6 @@ prepare (void)
MUSCLE_INSERT_BOOL ("glr_flag", glr_parser);
MUSCLE_INSERT_BOOL ("locations_flag", locations_flag);
MUSCLE_INSERT_BOOL ("nondeterministic_flag", nondeterministic_parser);
- MUSCLE_INSERT_BOOL ("pure_flag", pure_parser);
MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag);
MUSCLE_INSERT_BOOL ("tag_seen_flag", tag_seen);
MUSCLE_INSERT_BOOL ("use_push_for_pull_flag", use_push_for_pull_flag);
Index: src/parse-gram.y
===================================================================
RCS file: /sources/bison/bison/src/parse-gram.y,v
retrieving revision 1.121
diff -p -u -r1.121 parse-gram.y
--- src/parse-gram.y 25 Sep 2007 05:47:26 -0000 1.121
+++ src/parse-gram.y 29 Oct 2007 16:58:18 -0000
@@ -266,7 +266,19 @@ prologue_declaration:
| "%output" STRING { spec_outfile = $2; }
| "%output" "=" STRING { spec_outfile = $3; } /* deprecated */
| "%parse-param" "{...}" { add_param ("parse_param", $2, @2); }
-| "%pure-parser" { pure_parser = true; }
+| "%pure-parser"
+ {
+ /* %pure-parser is deprecated in favor of `%define api.pure', so use
+ `%define api.pure' in a backward-compatible manner here. First, don't
+ complain if %pure-parser is specified multiple times. */
+ if (!muscle_find_const ("percent_define(api.pure)"))
+ muscle_percent_define_insert ("api.pure", @1, "");
+ /* In all cases, use api.pure now so that the backend doesn't complain if
+ the skeleton ignores api.pure, but do warn now if there's a previous
+ conflicting definition from an actual %define. */
+ if (!muscle_percent_define_flag_if ("api.pure"))
+ muscle_percent_define_insert ("api.pure", @1, "");
+ }
| "%require" STRING { version_check (&@2, $2); }
| "%skeleton" STRING
{
Index: tests/calc.at
===================================================================
RCS file: /sources/bison/bison/tests/calc.at,v
retrieving revision 1.108
diff -p -u -r1.108 calc.at
--- tests/calc.at 28 Oct 2007 20:11:34 -0000 1.108
+++ tests/calc.at 29 Oct 2007 16:58:18 -0000
@@ -559,8 +559,8 @@ AT_CHECK_CALC_LALR([%verbose])
AT_CHECK_CALC_LALR([%yacc])
AT_CHECK_CALC_LALR([%error-verbose])
-AT_CHECK_CALC_LALR([%pure-parser %locations])
-AT_CHECK_CALC_LALR([%define api.push_pull "both" %pure-parser %locations])
+AT_CHECK_CALC_LALR([%define api.pure %locations])
+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])
@@ -568,10 +568,10 @@ AT_CHECK_CALC_LALR([%error-verbose %loca
AT_CHECK_CALC_LALR([%debug])
AT_CHECK_CALC_LALR([%error-verbose %debug %locations %defines %name-prefix
"calc" %verbose %yacc])
-AT_CHECK_CALC_LALR([%pure-parser %error-verbose %debug %locations %defines
%name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_LALR([%define api.push_pull "both" %pure-parser %error-verbose
%debug %locations %defines %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR([%define api.pure %error-verbose %debug %locations %defines
%name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR([%define api.push_pull "both" %define api.pure
%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_LALR([%pure-parser %error-verbose %debug %locations %defines
%name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result}
%parse-param {int *count}])
+AT_CHECK_CALC_LALR([%define api.pure %error-verbose %debug %locations %defines
%name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result}
%parse-param {int *count}])
# ----------------------- #
@@ -597,7 +597,7 @@ AT_CHECK_CALC_GLR([%verbose])
AT_CHECK_CALC_GLR([%yacc])
AT_CHECK_CALC_GLR([%error-verbose])
-AT_CHECK_CALC_GLR([%pure-parser %locations])
+AT_CHECK_CALC_GLR([%define api.pure %locations])
AT_CHECK_CALC_GLR([%error-verbose %locations])
AT_CHECK_CALC_GLR([%error-verbose %locations %defines %name-prefix "calc"
%verbose %yacc])
@@ -605,9 +605,9 @@ AT_CHECK_CALC_GLR([%error-verbose %locat
AT_CHECK_CALC_GLR([%debug])
AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %name-prefix
"calc" %verbose %yacc])
-AT_CHECK_CALC_GLR([%pure-parser %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])
-AT_CHECK_CALC_GLR([%pure-parser %error-verbose %debug %locations %defines
%name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result}
%parse-param {int *count}])
+AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines
%name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result}
%parse-param {int *count}])
# ----------------------------- #
Index: tests/cxx-type.at
===================================================================
RCS file: /sources/bison/bison/tests/cxx-type.at,v
retrieving revision 1.35
diff -p -u -r1.35 cxx-type.at
--- tests/cxx-type.at 15 Aug 2007 20:21:33 -0000 1.35
+++ tests/cxx-type.at 29 Oct 2007 16:58:18 -0000
@@ -1,5 +1,6 @@
# Checking GLR Parsing. -*- Autotest -*-
-# Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation,
+# Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -423,14 +424,14 @@ AT_PARSER_CHECK([[./types test-input]],
AT_CLEANUP
AT_SETUP([GLR: Resolve ambiguity, pure, no locations])
-_AT_TEST_GLR_CXXTYPES([%pure-parser],
+_AT_TEST_GLR_CXXTYPES([%define api.pure],
[%dprec 1], [%dprec 2])
AT_PARSER_CHECK([[./types test-input]], 0,
_AT_RESOLVED_GLR_OUTPUT, _AT_GLR_STDERR)
AT_CLEANUP
AT_SETUP([GLR: Resolve ambiguity, pure, locations])
-_AT_TEST_GLR_CXXTYPES([%pure-parser %locations],
+_AT_TEST_GLR_CXXTYPES([%define api.pure %locations],
[%dprec 1], [%dprec 2])
AT_PARSER_CHECK([[./types test-input]], 0,
_AT_RESOLVED_GLR_OUTPUT_WITH_LOC, _AT_GLR_STDERR)
@@ -451,13 +452,13 @@ AT_PARSER_CHECK([[./types test-input]],
AT_CLEANUP
AT_SETUP([GLR: Merge conflicting parses, pure, no locations])
-_AT_TEST_GLR_CXXTYPES([%pure-parser],
+_AT_TEST_GLR_CXXTYPES([%define api.pure],
[%merge <stmtMerge>], [%merge <stmtMerge>])
AT_PARSER_CHECK([[./types test-input]], 0,
_AT_AMBIG_GLR_OUTPUT, _AT_GLR_STDERR)
AT_CLEANUP
AT_SETUP([GLR: Merge conflicting parses, pure, locations])
-_AT_TEST_GLR_CXXTYPES([%pure-parser %locations],
+_AT_TEST_GLR_CXXTYPES([%define api.pure %locations],
[%merge <stmtMerge>],[%merge <stmtMerge>])
AT_PARSER_CHECK([[./types test-input]], 0,
_AT_AMBIG_GLR_OUTPUT_WITH_LOC, _AT_GLR_STDERR)
Index: tests/glr-regression.at
===================================================================
RCS file: /sources/bison/bison/tests/glr-regression.at,v
retrieving revision 1.44
diff -p -u -r1.44 glr-regression.at
--- tests/glr-regression.at 15 Aug 2007 20:21:33 -0000 1.44
+++ tests/glr-regression.at 29 Oct 2007 16:58:18 -0000
@@ -1646,7 +1646,7 @@ AT_DATA_GRAMMAR([glr-regr17.y],
[[
%glr-parser
%locations
-%pure-parser
+%define api.pure
%error-verbose
%union { int dummy; }
Index: tests/input.at
===================================================================
RCS file: /sources/bison/bison/tests/input.at,v
retrieving revision 1.83
diff -p -u -r1.83 input.at
--- tests/input.at 28 Oct 2007 20:11:35 -0000 1.83
+++ tests/input.at 29 Oct 2007 16:58:18 -0000
@@ -859,6 +859,39 @@ AT_CHECK([[bison input.y]], [1], [],
AT_CLEANUP
+## ------------------------- ##
+## Unused %define api.pure. ##
+## ------------------------- ##
+
+AT_SETUP([[Unused %define api.pure]])
+
+# AT_CHECK_API_PURE(DECLS, VALUE)
+# -------------------------------
+# Make sure Bison reports that `%define api.pure VALUE' is unused when DECLS
+# are specified.
+m4_define([AT_CHECK_API_PURE],
+[
+AT_DATA([[input.y]],
+[[%define api.pure ]$2[
+]$1[
+%%
+start: ;
+]])
+
+AT_CHECK([[bison input.y]], [0], [],
+[[input.y:1.9-16: warning: %define variable `api.pure' is not used
+]])
+])
+
+AT_CHECK_API_PURE([[%language "c++" %defines]], [[]])
+AT_CHECK_API_PURE([[%language "c++" %defines]], [["false"]])
+AT_CHECK_API_PURE([[%language "c++" %defines %glr-parser]], [[""]])
+AT_CHECK_API_PURE([[%language "c++" %defines %glr-parser]], [["false"]])
+AT_CHECK_API_PURE([[%language "java"]], [["true"]])
+AT_CHECK_API_PURE([[%language "java"]], [["false"]])
+
+AT_CLEANUP
+
## -------------------------------- ##
## C++ namespace reference errors. ##
## -------------------------------- ##
Index: tests/local.at
===================================================================
RCS file: /sources/bison/bison/tests/local.at,v
retrieving revision 1.27
diff -p -u -r1.27 local.at
--- tests/local.at 15 Aug 2007 20:21:33 -0000 1.27
+++ tests/local.at 29 Oct 2007 16:58:18 -0000
@@ -57,10 +57,11 @@ m4_pushdef([AT_PARAM_IF],
m4_pushdef([AT_LOCATION_IF],
[m4_bmatch([$3], [%locations], [$1], [$2])])
m4_pushdef([AT_PURE_IF],
-[m4_bmatch([$3], [%pure-parser], [$1], [$2])])
+[m4_bmatch([$3], [%define *api\.pure\|%pure-parser],
+ [m4_bmatch([$3], [%define *api\.pure *"false"], [$2], [$1])],
+ [$2])])
m4_pushdef([AT_PURE_AND_LOC_IF],
-[m4_bmatch([$3], [%locations.*%pure-parser\|%pure-parser.*%locations],
- [$1], [$2])])
+[m4_bmatch([$3], [%locations], [AT_PURE_IF($@)], [$2])])
m4_pushdef([AT_GLR_OR_PARAM_IF],
[m4_bmatch([$3], [%glr-parser\|%parse-param], [$1], [$2])])
m4_pushdef([AT_NAME_PREFIX],
@@ -79,7 +80,7 @@ m4_pushdef([AT_YYERROR_SEES_LOC_IF],
[$1])],
[$2])])
-# The interface is pure: either because %pure-parser, or because we
+# The interface is pure: either because %define api.pure, or because we
# are using the C++ parsers.
m4_pushdef([AT_PURE_LEX_IF],
[AT_PURE_IF([$1],
Index: tests/push.at
===================================================================
RCS file: /sources/bison/bison/tests/push.at,v
retrieving revision 1.6
diff -p -u -r1.6 push.at
--- tests/push.at 28 Oct 2007 20:11:35 -0000 1.6
+++ tests/push.at 29 Oct 2007 16:58:18 -0000
@@ -33,7 +33,7 @@ AT_DATA_GRAMMAR([[input.y]],
void yyerror (char const *msg);
%}
-%pure-parser %define api.push_pull "push"
+%define api.pure %define api.push_pull "push"
%%