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

@@ -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 %locations %defines %name-prefix "calc" %verb
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 %locations %defines %name-prefix "calc" %verbo
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}])
# ----------------------------- #

View File

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

View File

@@ -1646,7 +1646,7 @@ AT_DATA_GRAMMAR([glr-regr17.y],
[[
%glr-parser
%locations
%pure-parser
%define api.pure
%error-verbose
%union { int dummy; }

View File

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

View File

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

View File

@@ -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"
%%