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.
This commit is contained in:
Joel E. Denny
2007-09-25 05:47:27 +00:00
parent 3f999f78be
commit d782395d52
22 changed files with 771 additions and 713 deletions

View File

@@ -214,13 +214,7 @@ b4_define_flag_if([error_verbose]) # Whether error are verbose.
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

View File

@@ -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)"])

View File

@@ -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]])])

View File

@@ -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
])

View File

@@ -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. ##
## ---------------- ##

View File

@@ -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)"])

View File

@@ -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 for Bison's Yacc-like parsers in C],dnl '
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

View File

@@ -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])])