bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

%push-* -> %define push_pull


From: Joel E. Denny
Subject: %push-* -> %define push_pull
Date: Tue, 25 Sep 2007 01:49:02 -0400 (EDT)

I committed the following.  Be sure to read the first couple of lines in 
the ChangeLog as the way to request push parsing has changed.

Index: ChangeLog
===================================================================
RCS file: /sources/bison/bison/ChangeLog,v
retrieving revision 1.1728
diff -p -u -r1.1728 ChangeLog
--- ChangeLog   24 Sep 2007 19:35:08 -0000      1.1728
+++ ChangeLog   25 Sep 2007 05:30:24 -0000
@@ -1,3 +1,48 @@
+2007-09-25  Joel E. Denny  <address@hidden>
+
+       Replace `%push-parser' and `%push-pull-parser' with
+       `%define push_pull "push"' and `%define push_pull "both"'.
+       `%define push_pull "pull"' is the default.
+       * doc/bison.texinfo (Push Decl, Push Parser Function,
+       Pull Parser Function, Parser Create Function, Parser Delete Function):
+       Update declarations.
+       (Decl Summary, Table of Symbols): Replace %push-parser and
+       %push-pull-parser entries with a %define push_pull entry.
+       * data/bison.m4 (b4_percent_define_check_values): New macro.
+       (b4_pull_if, b4_push_if, b4_use_push_for_pull_if): Move these
+       definitions...
+       * data/c.m4 (b4_identification): ... and the YYPUSH and YYPULL cpp
+       definitions...
+       * data/push.c: ... to here and compute them from the value of the
+       %define variable push_pull.
+       * data/c-skel.m4: Instead of choosing the push.c skeleton for push
+       parsing requests here...
+       * data/yacc.c: ... hack this to switch to push.c any time
+       b4_use_push_pull_flag or the %define variable push_pull is set.  This
+       will go away when we mv push.c yacc.c.
+       * data/c++-skel.m4, data/glr.c, data/java-skel.m4: Don't report that
+       push parsing is not supported since unused %define variables are
+       reported anyway.
+       * src/getargs.c, src/getargs.h (pull_parser, push_parser): Remove.
+       * src/muscle_tab.h (muscle_percent_define_check_values): Update
+       comments for consistency with b4_percent_define_check_values.
+       * src/output.c (prepare): Don't insert b4_pull_flag and b4_push_flag
+       muscles.
+       * src/parse-gram.y (PERCENT_PUSH_PARSER, PERCENT_PUSH_PULL_PARSER):
+       Remove.
+       (prologue_declaration): Remove %push-parser and %push-pull-parser
+       rules.
+       * src/scan-gram.l (%push-parser, %push-pull-parser): Remove rules.
+       * tests/calc.at: Update declarations.
+       * tests/input.at (%define enum variables): New test case.
+       * tests/push.at (Push Parsing: Memory Leak for Early Deletion): Update
+       declaration.
+       (Push Parsing: Multiple impure instances): Update declaration.
+       (Push Parsing: Unsupported Skeletons): New test case.
+       * tests/torture.at (Exploding the Stack Size with Alloca): Update
+       declaration.
+       (Exploding the Stack Size with Malloc): Update declaration.
+
 2007-09-24  Wojciech Polak  <address@hidden>
 
        Add XSLT transformations.
Index: data/bison.m4
===================================================================
RCS file: /sources/bison/bison/data/bison.m4,v
retrieving revision 1.20
diff -p -u -r1.20 bison.m4
--- data/bison.m4       28 Aug 2007 07:14:11 -0000      1.20
+++ data/bison.m4       25 Sep 2007 05:30:24 -0000
@@ -214,13 +214,7 @@ 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([pull])              # Whether pull parsing is requested.
 b4_define_flag_if([pure])              # Whether the interface is pure.
-b4_define_flag_if([push])              # Whether push parsing is requested.
-b4_define_flag_if([use_push_for_pull])  # Whether push parsing should be used
-                                        # in place of pull parsing (where
-                                        # available) for the sake of the test
-                                        # suite.
 b4_define_flag_if([yacc])              # Whether POSIX Yacc is emulated.
 
 
@@ -403,6 +397,43 @@ m4_define([b4_percent_define_default],
             m4_define([b4_percent_define_loc(]$1[)],
                       [[[[[Bison:b4_percent_define_default]:0.0]], 
[[[Bison:b4_percent_define_default]:0.0]]]])])])
 
+# b4_percent_define_check_values(VALUES)
+# --------------------------------------
+# Mimic muscle_percent_define_check_values in ../src/muscle_tab.h exactly
+# except that the VALUES structure is more appropriate for M4.  That is, VALUES
+# is a list of sublists of strings.  For each sublist, the first string is the
+# name of a %define variable, and all remaining strings in that sublist are the
+# valid values for that variable.  Complain if such a variable is undefined (a
+# Bison error since the default value should have been set already) or defined
+# to any other value (possibly a user error).  Don't record this as a Bison
+# usage of the variable as there's no reason to suspect that the value has yet
+# influenced the output.
+#
+# For example:
+#
+#   b4_percent_define_check_values([[[[foo]], [[foo-value1]], [[foo-value2]]]],
+#                                  [[[[bar]], [[bar-value1]]]])
+m4_define([b4_percent_define_check_values],
+[m4_foreach([b4_sublist], m4_quote($@),
+            [_b4_percent_define_check_values(b4_sublist)])])
+
+m4_define([_b4_percent_define_check_values],
+[m4_ifdef([b4_percent_define(]$1[)],
+  [m4_pushdef([b4_good_value], [0])dnl
+   m4_if($#, 1, [],
+         [m4_foreach([b4_value], m4_dquote(m4_shift($@)),
+                     [m4_if(m4_indir([b4_percent_define(]$1[)]), b4_value,
+                            [m4_define([b4_good_value], [1])])])])dnl
+   m4_if(b4_good_value, [0],
+         [m4_pushdef([b4_loc], m4_indir([b4_percent_define_loc(]$1[)]))dnl
+          b4_complain_at(b4_loc,
+                         [[invalid value for %%define variable `%s': `%s']],
+                         [$1],
+                         m4_dquote(m4_indir([b4_percent_define(]$1[)])))dnl
+          m4_popdef([b4_loc])])dnl
+   m4_popdef([b4_good_value])],
+  [b4_fatal([[undefined %%define variable `%s' passed to 
b4_percent_define_check_values]], [$1])])])
+
 # b4_percent_code_get([QUALIFIER])
 # --------------------------------
 # If any %code blocks for QUALIFIER are defined, emit them beginning with a
Index: data/c++-skel.m4
===================================================================
RCS file: /sources/bison/bison/data/c++-skel.m4,v
retrieving revision 1.6
diff -p -u -r1.6 c++-skel.m4
--- data/c++-skel.m4    15 Aug 2007 20:21:21 -0000      1.6
+++ data/c++-skel.m4    25 Sep 2007 05:30:24 -0000
@@ -19,8 +19,6 @@
 b4_glr_if(             [m4_define([b4_used_skeleton], 
[b4_pkgdatadir/[glr.cc]])])
 b4_nondeterministic_if([m4_define([b4_used_skeleton], 
[b4_pkgdatadir/[glr.cc]])])
 
-b4_push_if([b4_complain([[C++ push parsers are not supported]])])
-
 m4_define_default([b4_used_skeleton], [b4_pkgdatadir/[lalr1.cc]])
 m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"])
 
Index: data/c-skel.m4
===================================================================
RCS file: /sources/bison/bison/data/c-skel.m4,v
retrieving revision 1.4
diff -p -u -r1.4 c-skel.m4
--- data/c-skel.m4      15 Aug 2007 20:21:22 -0000      1.4
+++ data/c-skel.m4      25 Sep 2007 05:30:24 -0000
@@ -16,7 +16,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-b4_push_if(            [m4_define([b4_used_skeleton], 
[b4_pkgdatadir/[push.c]])])
 b4_glr_if(             [m4_define([b4_used_skeleton], 
[b4_pkgdatadir/[glr.c]])])
 b4_nondeterministic_if([m4_define([b4_used_skeleton], 
[b4_pkgdatadir/[glr.c]])])
 
Index: data/c.m4
===================================================================
RCS file: /sources/bison/bison/data/c.m4,v
retrieving revision 1.72
diff -p -u -r1.72 c.m4
--- data/c.m4   15 Aug 2007 20:21:22 -0000      1.72
+++ data/c.m4   25 Sep 2007 05:30:24 -0000
@@ -41,12 +41,6 @@ m4_define([b4_identification],
 /* Pure parsers.  */
 [#]define YYPURE b4_pure_flag
 
-/* Push parsers.  */
-[#]define YYPUSH b4_push_flag
-
-/* Pull parsers.  */
-[#]define YYPULL b4_pull_flag
-
 /* Using locations.  */
 [#]define YYLSP_NEEDED b4_locations_flag
 ])
Index: data/glr.c
===================================================================
RCS file: /sources/bison/bison/data/glr.c,v
retrieving revision 1.207
diff -p -u -r1.207 glr.c
--- data/glr.c  15 Aug 2007 20:21:22 -0000      1.207
+++ data/glr.c  25 Sep 2007 05:30:25 -0000
@@ -20,9 +20,6 @@
 
 m4_include(b4_pkgdatadir/[c.m4])
 
-b4_push_if([
-b4_complain([[non-deterministic push parsers are not yet supported]])])
-
 ## ---------------- ##
 ## Default values.  ##
 ## ---------------- ##
Index: data/java-skel.m4
===================================================================
RCS file: /sources/bison/bison/data/java-skel.m4,v
retrieving revision 1.2
diff -p -u -r1.2 java-skel.m4
--- data/java-skel.m4   15 Aug 2007 20:21:22 -0000      1.2
+++ data/java-skel.m4   25 Sep 2007 05:30:25 -0000
@@ -18,7 +18,6 @@
 
 b4_glr_if(             [b4_complain([%%glr-parser not supported for Java])])
 b4_nondeterministic_if([b4_complain([%%nondeterministic-parser not supported 
for Java])])
-b4_push_if(            [b4_complain([%%push-parser is not supported for 
Java])])
 
 m4_define_default([b4_used_skeleton], [b4_pkgdatadir/[lalr1.java]])
 m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"])
Index: data/push.c
===================================================================
RCS file: /sources/bison/bison/data/push.c,v
retrieving revision 1.41
diff -p -u -r1.41 push.c
--- data/push.c 18 Aug 2007 00:45:51 -0000      1.41
+++ data/push.c 25 Sep 2007 05:30:25 -0000
@@ -18,17 +18,22 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+# Check the value of %define push_pull.
+b4_percent_define_default([[push_pull]], [[pull]])
+b4_percent_define_check_values([[[[push_pull]], [[pull]], [[push]], [[both]]]])
+b4_define_flag_if([pull]) m4_define([b4_pull_flag], [[1]])
+b4_define_flag_if([push]) m4_define([b4_push_flag], [[1]])
+m4_case(b4_percent_define_get([[push_pull]]),
+        [pull], [m4_define([b4_push_flag], [[0]])],
+        [push], [m4_define([b4_pull_flag], [[0]])])
+
 # Handle BISON_USE_PUSH_FOR_PULL for the test suite.  So that push parsing
 # tests function as written, don't let BISON_USE_PUSH_FOR_PULL modify Bison's
 # behavior at all when push parsing is already requested.
+b4_define_flag_if([use_push_for_pull])
 b4_use_push_for_pull_if([
-  b4_push_if([
-    m4_define([b4_use_push_for_pull_flag], [[0]])
-    b4_define_flag_if([use_push_for_pull])
-  ], [
-    m4_define([b4_push_flag], [[1]])
-    b4_define_flag_if([push])
-  ])])
+  b4_push_if([m4_define([b4_use_push_for_pull_flag], [[0]])],
+             [m4_define([b4_push_flag], [[1]])])])
 
 m4_include(b4_pkgdatadir/[c.m4])
 
@@ -157,8 +162,14 @@ b4_copyright([Skeleton implementation fo
    define necessary library symbols; they are noted "INFRINGES ON
    USER NAME SPACE" below.  */
 
-]b4_identification
-b4_percent_code_get([[top]])[]dnl
+]b4_identification[
+/* Push parsers.  */
+#define YYPUSH ]b4_push_flag[
+
+/* Pull parsers.  */
+#define YYPULL ]b4_pull_flag[
+
+]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.166
diff -p -u -r1.166 yacc.c
--- data/yacc.c 15 Aug 2007 20:21:23 -0000      1.166
+++ data/yacc.c 25 Sep 2007 05:30:26 -0000
@@ -18,8 +18,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Handle BISON_USE_PUSH_FOR_PULL for the test suite.
-b4_use_push_for_pull_if([m4_include(b4_pkgdatadir/[push.c])], [
+# This hack will go away when we mv push.c yacc.c.
+m4_ifndef([b4_percent_define(push_pull)],
+[m4_if(b4_use_push_for_pull_flag, [0], [
 
 m4_include(b4_pkgdatadir/[c.m4])
 
@@ -1532,4 +1533,6 @@ b4_percent_code_get([[provides]])
 ])dnl b4_defines_if
 m4_divert_pop(0)
 
-])dnl b4_use_push_for_pull_if
+],
+[m4_include(b4_pkgdatadir/[push.c])])],
+[m4_include(b4_pkgdatadir/[push.c])])
Index: doc/bison.texinfo
===================================================================
RCS file: /sources/bison/bison/doc/bison.texinfo,v
retrieving revision 1.236
diff -p -u -r1.236 bison.texinfo
--- doc/bison.texinfo   28 Aug 2007 07:14:11 -0000      1.236
+++ doc/bison.texinfo   25 Sep 2007 05:30:29 -0000
@@ -4528,7 +4528,7 @@ valid grammar.
 @subsection A Push Parser
 @cindex push parser
 @cindex push parser
address@hidden %push-parser
address@hidden %define push_pull
 
 A pull parser is called once and it takes control until all its input 
 is completely parsed.  A push parser, on the other hand, is called 
@@ -4539,12 +4539,12 @@ main event loop in the client's applicat
 a requirement of a GUI, when the main event loop needs to be triggered 
 within a certain time period.  
 
-Normally, Bison generates a pull parser.  The Bison declaration 
address@hidden says that you want the parser to be a push parser.
-It looks like this:
+Normally, Bison generates a pull parser.
+The following Bison declaration says that you want the parser to be a push
+parser (@pxref{Decl Summary,,%define push_pull}):
 
 @example
-%push-parser
+%define push_pull "push"
 @end example
 
 In almost all cases, you want to ensure that your push parser is also
@@ -4555,7 +4555,7 @@ what you are doing, your declarations sh
 
 @example
 %pure-parser
-%push-parser
+%define push_pull "push"
 @end example
 
 There is a major notable functional difference between the pure push parser 
@@ -4604,15 +4604,16 @@ for use by the next invocation of the @c
 
 Bison also supports both the push parser interface along with the pull parser 
 interface in the same generated parser.  In order to get this functionality,
-you should replace the @code{%push-parser} declaration with the 
address@hidden declaration.  Doing this will create all of the 
+you should replace the @code{%define push_pull "push"} declaration with the 
address@hidden push_pull "both"} declaration.  Doing this will create all of 
the 
 symbols mentioned earlier along with the two extra symbols, @code{yyparse} 
 and @code{yypull_parse}.  @code{yyparse} can be used exactly as it normally 
 would be used.  However, the user should note that it is implemented in the 
-generated parser by calling @code{yypull_parse}.  This makes the 
address@hidden function that is generated with the @code{%push-pull-parser} 
-declaration slower than the normal @code{yyparse} function.  If the user 
-calls the @code{yypull_parse} function it will parse the rest of the input 
+generated parser by calling @code{yypull_parse}.
+This makes the @code{yyparse} function that is generated with the
address@hidden push_pull "both"} declaration slower than the normal
address@hidden function.  If the user
+calls the @code{yypull_parse} function it will parse the rest of the input
 stream.  It is possible to @code{yypush_parse} tokens to select a subgrammar 
 and then @code{yypull_parse} the rest of the input stream.  If you would like 
 to switch back and forth between between parsing styles, you would have to 
@@ -4627,8 +4628,8 @@ yypstate_delete (ps);
 @end example
 
 Adding the @code{%pure-parser} declaration does exactly the same thing to the 
-generated parser with @code{%push-pull-parser} as it did for 
address@hidden
+generated parser with @code{%define push_pull "both"} as it did for 
address@hidden push_pull "push"}.
 
 @node Decl Summary
 @subsection Bison Declaration Summary
@@ -4834,6 +4835,14 @@ target language and/or parser skeleton.
 @end enumerate
 @end deffn
 
address@hidden {Directive} %define push_pull "@var{value}"
+Bison declaration to request a @code{"pull"} parser, a @code{"push"} parser, or
address@hidden"both"}.
+The default @code{"@var{value}"} is @code{"pull"}.
+This directive is currently only available for LALR(1) parsers in C.
address@hidden Decl, ,A Push Parser}.
address@hidden deffn
+
 @deffn {Directive} %defines
 Write a header file containing macro definitions for the token type
 names defined in the grammar as well as a few other declarations.
@@ -4944,16 +4953,6 @@ Request a pure (reentrant) parser progra
 (Reentrant) Parser}).
 @end deffn
 
address@hidden {Directive} %push-parser
-Bison declaration to request a push parser.
address@hidden Decl, ,A Push Parser}.
address@hidden deffn
-
address@hidden {Directive} %push-pull-parser
-Bison declaration to request a push and a pull parser.
address@hidden Decl, ,A Push Parser}.
address@hidden deffn
-
 @deffn {Directive} %require "@var{version}"
 Require version @var{version} or higher of Bison.  @xref{Require Decl, ,
 Require a Version of Bison}.
@@ -5163,8 +5162,8 @@ exp: @dots{}    @{ @dots{}; *randomness 
 @findex yypush_parse
 
 You call the function @code{yypush_parse} to parse a single token.  This 
-function is available if either the @code{%push-parser} or 
address@hidden declaration is used.  
+function is available if either the @code{%define push_pull "push"} or 
address@hidden push_pull "both"} declaration is used.  
 @xref{Push Decl, ,A Push Parser}.
 
 @deftypefun int yypush_parse (yypstate *yyps)
@@ -5178,7 +5177,7 @@ is required to finish parsing the gramma
 @findex yypull_parse
 
 You call the function @code{yypull_parse} to parse the rest of the input 
-stream.  This function is available if the @code{%push-pull-parser} 
+stream.  This function is available if the @code{%define push_pull "both"} 
 declaration is used.  
 @xref{Push Decl, ,A Push Parser}.
 
@@ -5191,8 +5190,8 @@ The value returned by @code{yypull_parse
 @findex yypstate_new
 
 You call the function @code{yypstate_new} to create a new parser instance.  
-This function is available if either the @code{%push-parser} or 
address@hidden declaration is used.  
+This function is available if either the @code{%define push_pull "push"} or 
address@hidden push_pull "both"} declaration is used.  
 @xref{Push Decl, ,A Push Parser}.
 
 @deftypefun yypstate *yypstate_new (void)
@@ -5205,8 +5204,8 @@ or NULL if no memory was available.
 @findex yypstate_delete
 
 You call the function @code{yypstate_delete} to delete a parser instance.
-This function is available if either the @code{%push-parser} or 
address@hidden declaration is used.  
+function is available if either the @code{%define push_pull "push"} or 
address@hidden push_pull "both"} declaration is used.  
 @xref{Push Decl, ,A Push Parser}.
 
 @deftypefun void yypstate_delete (yypstate *yyps)
@@ -9330,6 +9329,12 @@ Define a variable to adjust Bison's beha
 @xref{Decl Summary,,%define}.
 @end deffn
 
address@hidden {Directive} %define push_pull "@var{value}"
+Bison declaration to request a @code{"pull"} parser, a @code{"push"} parser, or
address@hidden"both"}.
address@hidden Summary,,%define push_pull}.
address@hidden deffn
+
 @deffn {Directive} %defines
 Bison declaration to create a header file meant for the scanner.
 @xref{Decl Summary}.
@@ -9452,16 +9457,6 @@ Bison declaration to request a pure (ree
 @xref{Pure Decl, ,A Pure (Reentrant) Parser}.
 @end deffn
 
address@hidden {Directive} %push-parser
-Bison declaration to request a push parser.
address@hidden Decl, ,A Push Parser}.
address@hidden deffn
-
address@hidden {Directive} %push-pull-parser
-Bison declaration to request a push and a pull parser.
address@hidden Decl, ,A Push Parser}.
address@hidden deffn
-
 @deffn {Directive} %require "@var{version}"
 Require version @var{version} or higher of Bison.  @xref{Require Decl, ,
 Require a Version of Bison}.
Index: src/getargs.c
===================================================================
RCS file: /sources/bison/bison/src/getargs.c,v
retrieving revision 1.95
diff -p -u -r1.95 getargs.c
--- src/getargs.c       21 Sep 2007 22:53:57 -0000      1.95
+++ src/getargs.c       25 Sep 2007 05:30:29 -0000
@@ -58,9 +58,7 @@ bool error_verbose = false;
 
 bool nondeterministic_parser = false;
 bool glr_parser = false;
-bool pull_parser = true;
 bool pure_parser = false;
-bool push_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.42
diff -p -u -r1.42 getargs.h
--- src/getargs.h       21 Sep 2007 22:53:57 -0000      1.42
+++ src/getargs.h       25 Sep 2007 05:30:29 -0000
@@ -51,19 +51,11 @@ extern bool error_verbose;
 
 extern bool glr_parser;
 
-/* PULL_PARSER is true if should generate a pull parser.  */
-
-extern bool pull_parser;
-
 /* PURE_PARSER is true if should generate a parser that is all pure
    and reentrant.  */
 
 extern bool pure_parser;
 
-/* PUSH_PARSER is true if should generate a push parser.  */
-
-extern bool push_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/muscle_tab.h
===================================================================
RCS file: /sources/bison/bison/src/muscle_tab.h,v
retrieving revision 1.28
diff -p -u -r1.28 muscle_tab.h
--- src/muscle_tab.h    15 Aug 2007 20:21:30 -0000      1.28
+++ src/muscle_tab.h    25 Sep 2007 05:30:29 -0000
@@ -156,15 +156,17 @@ bool muscle_percent_define_flag_if (char
    suspect that the value has yet influenced the output.  */
 void muscle_percent_define_default (char const *variable, char const *value);
 
-/* VALUES points to a sequence of strings that is partitioned into
-   subsequences by NULL's, one terminating each subsequence.  The last
-   subsequence is followed by a second NULL.  For each subsequence, the first
-   string is the name of a %define variable, and all remaining strings in that
-   subsequence are the valid values for that variable.  Complain if such a
-   variable is undefined (a Bison error since the default value should have
-   been set already) or defined to any other value (possibly a user error).
-   Don't record this as a Bison usage of the variable as there's no reason to
-   suspect that the value has yet influenced the output.  */
+/* Mimic b4_percent_define_check_values in ../data/bison.m4 exactly except that
+   the VALUES structure is more appropriate for C.  That is, VALUES points to a
+   list of strings that is partitioned into sublists by NULL's, one terminating
+   each sublist.  The last sublist is followed by a second NULL.  For each
+   sublist, the first string is the name of a %define variable, and all
+   remaining strings in that sublist are the valid values for that variable.
+   Complain if such a variable is undefined (a Bison error since the default
+   value should have been set already) or defined to any other value (possibly
+   a user error).  Don't record this as a Bison usage of the variable as
+   there's no reason to suspect that the value has yet influenced the
+   output.  */
 void muscle_percent_define_check_values (char const * const *values);
 
 /* Grow the muscle for the %code qualifier QUALIFIER appearing at QUALIFIER_LOC
Index: src/output.c
===================================================================
RCS file: /sources/bison/bison/src/output.c,v
retrieving revision 1.268
diff -p -u -r1.268 output.c
--- src/output.c        15 Aug 2007 20:21:30 -0000      1.268
+++ src/output.c        25 Sep 2007 05:30:30 -0000
@@ -571,9 +571,7 @@ 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 ("pull_flag", pull_parser);
   MUSCLE_INSERT_BOOL ("pure_flag", pure_parser);
-  MUSCLE_INSERT_BOOL ("push_flag", push_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.120
diff -p -u -r1.120 parse-gram.y
--- src/parse-gram.y    15 Aug 2007 20:21:31 -0000      1.120
+++ src/parse-gram.y    25 Sep 2007 05:30:30 -0000
@@ -150,9 +150,6 @@ static int current_prec = 0;
   PERCENT_OUTPUT          "%output"
   PERCENT_PARSE_PARAM     "%parse-param"
   PERCENT_PURE_PARSER     "%pure-parser"
-  PERCENT_PUSH_PARSER     "%push-parser"
-  PERCENT_PUSH_PULL_PARSER
-                          "%push-pull-parser"
   PERCENT_REQUIRE        "%require"
   PERCENT_SKELETON        "%skeleton"
   PERCENT_START           "%start"
@@ -270,8 +267,6 @@ prologue_declaration:
 | "%output" "=" STRING          { spec_outfile = $3; }  /* deprecated */
 | "%parse-param" "{...}"       { add_param ("parse_param", $2, @2); }
 | "%pure-parser"                { pure_parser = true; }
-| "%push-parser"                { push_parser = true; pull_parser = false; }
-| "%push-pull-parser"           { push_parser = true; pull_parser = true; }
 | "%require" STRING             { version_check (&@2, $2); }
 | "%skeleton" STRING
     {
Index: src/scan-gram.l
===================================================================
RCS file: /sources/bison/bison/src/scan-gram.l,v
retrieving revision 1.116
diff -p -u -r1.116 scan-gram.l
--- src/scan-gram.l     15 Aug 2007 20:21:31 -0000      1.116
+++ src/scan-gram.l     25 Sep 2007 05:30:31 -0000
@@ -185,8 +185,6 @@ splice       (\\[ \f\t\v]*\n)*
   "%prec"                          return PERCENT_PREC;
   "%printer"                       return PERCENT_PRINTER;
   "%pure"[-_]"parser"              return PERCENT_PURE_PARSER;
-  "%push-parser"                   return PERCENT_PUSH_PARSER;
-  "%push-pull-parser"              return PERCENT_PUSH_PULL_PARSER;
   "%require"                       return PERCENT_REQUIRE;
   "%right"                         return PERCENT_RIGHT;
   "%skeleton"                      return PERCENT_SKELETON;
Index: tests/calc.at
===================================================================
RCS file: /sources/bison/bison/tests/calc.at,v
retrieving revision 1.106
diff -p -u -r1.106 calc.at
--- tests/calc.at       15 Aug 2007 20:21:32 -0000      1.106
+++ tests/calc.at       25 Sep 2007 05:30:31 -0000
@@ -560,7 +560,7 @@ AT_CHECK_CALC_LALR([%yacc])
 AT_CHECK_CALC_LALR([%error-verbose])
 
 AT_CHECK_CALC_LALR([%pure-parser %locations])
-AT_CHECK_CALC_LALR([%push-pull-parser %pure-parser %locations])
+AT_CHECK_CALC_LALR([%define push_pull "both" %pure-parser %locations])
 AT_CHECK_CALC_LALR([%error-verbose %locations])
 
 AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix "calc" 
%verbose %yacc])
@@ -569,7 +569,7 @@ 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([%push-pull-parser %pure-parser %error-verbose %debug 
%locations %defines %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR([%define push_pull "both" %pure-parser %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}])
 
Index: tests/input.at
===================================================================
RCS file: /sources/bison/bison/tests/input.at,v
retrieving revision 1.80
diff -p -u -r1.80 input.at
--- tests/input.at      28 Aug 2007 07:14:11 -0000      1.80
+++ tests/input.at      25 Sep 2007 05:30:31 -0000
@@ -822,10 +822,10 @@ input.y:5.9-16: warning: %define variabl
 AT_CLEANUP
 
 ## --------------------------- ##
-## Boolean %define variables.  ##
+## %define Boolean variables.  ##
 ## --------------------------- ##
 
-AT_SETUP([Boolean %define variables])
+AT_SETUP([[%define Boolean variables]])
 
 AT_DATA([Input.y],
 [[%language "Java"
@@ -840,3 +840,21 @@ AT_CHECK([[bison Input.y]], [1], [],
 ]])
 
 AT_CLEANUP
+
+## ------------------------ ##
+## %define enum variables.  ##
+## ------------------------ ##
+
+AT_SETUP([[%define enum variables]])
+
+AT_DATA([[input.y]],
+[[%define push_pull "neither"
+%%
+start: ;
+]])
+
+AT_CHECK([[bison input.y]], [1], [],
+[[input.y:1.9-17: invalid value for %define variable `push_pull': `neither'
+]])
+
+AT_CLEANUP
Index: tests/push.at
===================================================================
RCS file: /sources/bison/bison/tests/push.at,v
retrieving revision 1.4
diff -p -u -r1.4 push.at
--- tests/push.at       18 Aug 2007 00:45:52 -0000      1.4
+++ tests/push.at       25 Sep 2007 05:30:31 -0000
@@ -33,7 +33,7 @@ AT_DATA_GRAMMAR([[input.y]],
   void yyerror (char const *msg);
 %}
 
-%pure-parser %push-parser
+%pure-parser %define push_pull "push"
 
 %%
 
@@ -77,7 +77,6 @@ AT_PARSER_CHECK([[./input]])
 
 AT_CLEANUP
 
-
 ## ----------------------------------------- ##
 ## Push Parsing: Multiple impure instances.  ##
 ## ----------------------------------------- ##
@@ -93,7 +92,7 @@ AT_DATA_GRAMMAR([[input.y]],
   int yylex (void);
 %}
 
-%push-pull-parser
+%define push_pull "both"
 
 %%
 
@@ -150,3 +149,22 @@ cannot allocate multiple impure push-par
 ]])
 
 AT_CLEANUP
+
+## ------------------------------------- ##
+## Push Parsing: Unsupported Skeletons.  ##
+## ------------------------------------- ##
+
+AT_SETUP([[Push Parsing: Unsupported Skeletons]])
+
+AT_DATA([[input.y]],
+[[%glr-parser
+%define push_pull "push"
+%%
+start: ;
+]])
+
+AT_CHECK([[bison input.y]], [0], [],
+[[input.y:2.9-17: warning: %define variable `push_pull' is not used
+]])
+
+AT_CLEANUP
Index: tests/torture.at
===================================================================
RCS file: /sources/bison/bison/tests/torture.at,v
retrieving revision 1.39
diff -p -u -r1.39 torture.at
--- tests/torture.at    15 Aug 2007 20:21:33 -0000      1.39
+++ tests/torture.at    25 Sep 2007 05:30:31 -0000
@@ -496,7 +496,7 @@ AT_PARSER_CHECK([./input 10000], 2, [], 
 # just helps guarantee we don't let the YYSTACK_USE_ALLOCA feature affect
 # push parsers.
 AT_DATA_STACK_TORTURE([AT_USE_ALLOCA],
-[[%push-pull-parser
+[[%define push_pull "both"
 ]])
 AT_PARSER_CHECK([./input 20], 0, [], [ignore],
                 [[VALGRIND_OPTS="$VALGRIND_OPTS --log-fd=1"]])
@@ -534,7 +534,7 @@ AT_PARSER_CHECK([./input 10000], 2, [], 
                 [[VALGRIND_OPTS="$VALGRIND_OPTS --log-fd=1"]])
 
 AT_DATA_STACK_TORTURE([AT_USE_ALLOCA],
-[[%push-pull-parser
+[[%define push_pull "both"
 ]])
 AT_PARSER_CHECK([./input 20], 0, [], [ignore],
                 [[VALGRIND_OPTS="$VALGRIND_OPTS --log-fd=1"]])




reply via email to

[Prev in Thread] Current Thread [Next in Thread]