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.
This commit is contained in:
Joel E. Denny
2007-10-29 17:36:40 +00:00
parent c373bf8bb8
commit d9df47b656
20 changed files with 397 additions and 262 deletions

View File

@@ -249,7 +249,6 @@ 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([pure]) # Whether the interface is pure.
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.

View File

@@ -28,22 +28,31 @@ m4_define([b4_comment], [/* m4_bpatsubst([$1], [
# 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[
]])
## ---------------- ##

View File

@@ -34,6 +34,13 @@ m4_define_default([b4_stack_depth_init], [200])
## 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
# ---------------

View File

@@ -51,6 +51,10 @@ m4_define_default([b4_stack_depth_init], [200])
## 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 for Bison's Yacc-like parsers in C],dnl '
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

View File

@@ -37,6 +37,10 @@ m4_define_default([b4_stack_depth_init], [200])
## 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)
# ----------------------------------