%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.
* data/yacc.c: Likewise.
* doc/bison.texinfo (Push Decl): Update.
(Decl Summary): Update %define entry.
(Push Parser Function): Update.
(Pull Parser Function): Update.
(Parser Create Function): Update.
(Parser Delete Function): Update.
* tests/calc.at (Simple LALR Calculator): Update.
* tests/input.at (%define enum variables): Update.
* tests/push.at (Push Parsing: Memory Leak for Early Deletion): Update.
(Push Parsing: Multiple impure instances): Update.
(Push Parsing: Unsupported Skeletons): Update.
* tests/torture.at (Exploding the Stack Size with Alloca): Update.
(Exploding the Stack Size with Malloc): Update.

* NEWS (2.3a+): Add an entry for the push parser, and clean up the
other entries some.
This commit is contained in:
Joel E. Denny
2007-10-28 20:11:35 +00:00
parent 32f19b6b47
commit c373bf8bb8
9 changed files with 96 additions and 51 deletions

View File

@@ -1,3 +1,26 @@
2007-10-28 Joel E. Denny <jdenny@ces.clemson.edu>
%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.
* data/yacc.c: Likewise.
* doc/bison.texinfo (Push Decl): Update.
(Decl Summary): Update %define entry.
(Push Parser Function): Update.
(Pull Parser Function): Update.
(Parser Create Function): Update.
(Parser Delete Function): Update.
* tests/calc.at (Simple LALR Calculator): Update.
* tests/input.at (%define enum variables): Update.
* tests/push.at (Push Parsing: Memory Leak for Early Deletion): Update.
(Push Parsing: Multiple impure instances): Update.
(Push Parsing: Unsupported Skeletons): Update.
* tests/torture.at (Exploding the Stack Size with Alloca): Update.
(Exploding the Stack Size with Malloc): Update.
* NEWS (2.3a+): Add an entry for the push parser, and clean up the
other entries some.
2007-10-27 Joel E. Denny <jdenny@ces.clemson.edu> 2007-10-27 Joel E. Denny <jdenny@ces.clemson.edu>
For the XML output's terminal element, rename @number to @token-number, For the XML output's terminal element, rename @number to @token-number,

55
NEWS
View File

@@ -3,7 +3,35 @@ Bison News
Changes in version 2.3a+ (????-??-??): Changes in version 2.3a+ (????-??-??):
* Previously, Bison sometimes generated parser tables containing unreachable * Push Parsing
Bison can now generate an LALR(1) parser in C with a push interface. That
is, instead of invoking yyparse, which pulls tokens from `yylex', you can
push one token at a time to the parser using `yypush_parse', which will
return to the caller after processing each token. By default, the push
interface is disabled. Either of the following directives will enable it:
%define api.push_pull "push" // Just push; does not require yylex.
%define api.push_pull "both" // Push and pull; requires yylex.
See the new section `A Push Parser' in the Bison manual for details.
* The -g and --graph options now output graphs in Graphviz DOT format,
not VCG format.
* An experimental directive %language specifies the language of the
generated parser, which can be C (the default) or C++. This
directive affects the skeleton used, and the names of the generated
files if the grammar file's name ends in ".y".
* The grammar file may now specify the name of the parser header file using
%defines. For example:
%defines "parser.h"
* Unreachable State Removal
Previously, Bison sometimes generated parser tables containing unreachable
states. A state can become unreachable during conflict resolution if Bison states. A state can become unreachable during conflict resolution if Bison
disables a shift action leading to it from a predecessor state. Bison now: disables a shift action leading to it from a predecessor state. Bison now:
@@ -23,7 +51,9 @@ Changes in version 2.3a+ (????-??-??):
See the %define entry in the `Bison Declaration Summary' in the Bison manual See the %define entry in the `Bison Declaration Summary' in the Bison manual
for further discussion. for further discussion.
* When instructed to generate a `.output' file including lookahead sets * Lookahead Set Correction in the `.output' Report
When instructed to generate a `.output' file including lookahead sets
(using `--report=lookahead', for example), Bison now prints each reduction's (using `--report=lookahead', for example), Bison now prints each reduction's
lookahead set only next to the associated state's one item that (1) is lookahead set only next to the associated state's one item that (1) is
associated with the same rule as the reduction and (2) has its dot at the end associated with the same rule as the reduction and (2) has its dot at the end
@@ -32,19 +62,6 @@ Changes in version 2.3a+ (????-??-??):
bug affected only the `.output' file and not the generated parser source bug affected only the `.output' file and not the generated parser source
code. code.
* The -g and --graph options now output graphs in Graphviz DOT format,
not VCG format.
* An experimental directive %language specifies the language of the
generated parser, which can be C (the default) or C++. This
directive affects the skeleton used, and the names of the generated
files if the grammar file's name ends in ".y".
* The grammar file may now specify the name of the parser header file using
%defines. For example:
%defines "parser.h"
* The `=' that used to be required in the following directives is now * The `=' that used to be required in the following directives is now
deprecated: deprecated:
@@ -57,7 +74,9 @@ Changes in version 2.3a+ (????-??-??):
%define NAME "VALUE" %define NAME "VALUE"
* Bison 2.3a provided a new set of directives as a more flexible alternative to * An Alternative to `%{...%}' -- `%code QUALIFIER {CODE}'
Bison 2.3a provided a new set of directives as a more flexible alternative to
the traditional Yacc prologue blocks. Those have now been consolidated into the traditional Yacc prologue blocks. Those have now been consolidated into
a single %code directive with an optional qualifier field, which identifies a single %code directive with an optional qualifier field, which identifies
the purpose of the code and thus the location(s) where Bison should generate the purpose of the code and thus the location(s) where Bison should generate
@@ -96,7 +115,9 @@ Changes in version 2.3a+ (????-??-??):
To enable these warnings, specify the flag `--warnings=midrule-values' or To enable these warnings, specify the flag `--warnings=midrule-values' or
`-W', which is a synonym for `--warnings=all'. `-W', which is a synonym for `--warnings=all'.
* Bison now recognizes two separate kinds of default %destructor's and * Default %destructor or %printer with `<*>' or `<>'
Bison now recognizes two separate kinds of default %destructor's and
%printer's: %printer's:
1. Place `<*>' in a %destructor/%printer symbol list to define a default 1. Place `<*>' in a %destructor/%printer symbol list to define a default

View File

@@ -18,12 +18,13 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# Check the value of %define push_pull. # Check the value of %define api.push_pull.
b4_percent_define_default([[push_pull]], [[pull]]) b4_percent_define_default([[api.push_pull]], [[pull]])
b4_percent_define_check_values([[[[push_pull]], [[pull]], [[push]], [[both]]]]) b4_percent_define_check_values([[[[api.push_pull]],
[[pull]], [[push]], [[both]]]])
b4_define_flag_if([pull]) m4_define([b4_pull_flag], [[1]]) b4_define_flag_if([pull]) m4_define([b4_pull_flag], [[1]])
b4_define_flag_if([push]) m4_define([b4_push_flag], [[1]]) b4_define_flag_if([push]) m4_define([b4_push_flag], [[1]])
m4_case(b4_percent_define_get([[push_pull]]), m4_case(b4_percent_define_get([[api.push_pull]]),
[pull], [m4_define([b4_push_flag], [[0]])], [pull], [m4_define([b4_push_flag], [[0]])],
[push], [m4_define([b4_pull_flag], [[0]])]) [push], [m4_define([b4_pull_flag], [[0]])])

View File

@@ -19,7 +19,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# This hack will go away when we mv push.c yacc.c. # This hack will go away when we mv push.c yacc.c.
m4_ifndef([b4_percent_define(push_pull)], m4_ifndef([b4_percent_define(api.push_pull)],
[m4_if(b4_use_push_for_pull_flag, [0], [ [m4_if(b4_use_push_for_pull_flag, [0], [
m4_include(b4_pkgdatadir/[c.m4]) m4_include(b4_pkgdatadir/[c.m4])

View File

@@ -4528,7 +4528,7 @@ valid grammar.
@subsection A Push Parser @subsection A Push Parser
@cindex push parser @cindex push parser
@cindex push parser @cindex push parser
@findex %define push_pull @findex %define api.push_pull
A pull parser is called once and it takes control until all its input 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 is completely parsed. A push parser, on the other hand, is called
@@ -4541,10 +4541,10 @@ within a certain time period.
Normally, Bison generates a pull parser. Normally, Bison generates a pull parser.
The following Bison declaration says that you want the parser to be a push The following Bison declaration says that you want the parser to be a push
parser (@pxref{Decl Summary,,%define push_pull}): parser (@pxref{Decl Summary,,%define api.push_pull}):
@example @example
%define push_pull "push" %define api.push_pull "push"
@end example @end example
In almost all cases, you want to ensure that your push parser is also In almost all cases, you want to ensure that your push parser is also
@@ -4555,7 +4555,7 @@ what you are doing, your declarations should look like this:
@example @example
%pure-parser %pure-parser
%define push_pull "push" %define api.push_pull "push"
@end example @end example
There is a major notable functional difference between the pure push parser There is a major notable functional difference between the pure push parser
@@ -4604,14 +4604,14 @@ for use by the next invocation of the @code{yypush_parse} function.
Bison also supports both the push parser interface along with the pull parser 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, interface in the same generated parser. In order to get this functionality,
you should replace the @code{%define push_pull "push"} declaration with the you should replace the @code{%define api.push_pull "push"} declaration with the
@code{%define push_pull "both"} declaration. Doing this will create all of the @code{%define api.push_pull "both"} declaration. Doing this will create all of
symbols mentioned earlier along with the two extra symbols, @code{yyparse} 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 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 would be used. However, the user should note that it is implemented in the
generated parser by calling @code{yypull_parse}. generated parser by calling @code{yypull_parse}.
This makes the @code{yyparse} function that is generated with the This makes the @code{yyparse} function that is generated with the
@code{%define push_pull "both"} declaration slower than the normal @code{%define api.push_pull "both"} declaration slower than the normal
@code{yyparse} function. If the user @code{yyparse} function. If the user
calls the @code{yypull_parse} function it will parse the rest of the input 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 stream. It is possible to @code{yypush_parse} tokens to select a subgrammar
@@ -4628,8 +4628,8 @@ yypstate_delete (ps);
@end example @end example
Adding the @code{%pure-parser} declaration does exactly the same thing to the Adding the @code{%pure-parser} declaration does exactly the same thing to the
generated parser with @code{%define push_pull "both"} as it did for generated parser with @code{%define api.push_pull "both"} as it did for
@code{%define push_pull "push"}. @code{%define api.push_pull "push"}.
@node Decl Summary @node Decl Summary
@subsection Bison Declaration Summary @subsection Bison Declaration Summary
@@ -4837,8 +4837,8 @@ target language and/or parser skeleton.
Some of the accepted @var{variable}s are: Some of the accepted @var{variable}s are:
@itemize @bullet @itemize @bullet
@item push_pull @item api.push_pull
@findex %define push_pull @findex %define api.push_pull
@itemize @bullet @itemize @bullet
@item Language(s): C (LALR(1) only) @item Language(s): C (LALR(1) only)
@@ -5267,8 +5267,8 @@ exp: @dots{} @{ @dots{}; *randomness += 1; @dots{} @}
@findex yypush_parse @findex yypush_parse
You call the function @code{yypush_parse} to parse a single token. This You call the function @code{yypush_parse} to parse a single token. This
function is available if either the @code{%define push_pull "push"} or function is available if either the @code{%define api.push_pull "push"} or
@code{%define push_pull "both"} declaration is used. @code{%define api.push_pull "both"} declaration is used.
@xref{Push Decl, ,A Push Parser}. @xref{Push Decl, ,A Push Parser}.
@deftypefun int yypush_parse (yypstate *yyps) @deftypefun int yypush_parse (yypstate *yyps)
@@ -5282,7 +5282,7 @@ is required to finish parsing the grammar.
@findex yypull_parse @findex yypull_parse
You call the function @code{yypull_parse} to parse the rest of the input You call the function @code{yypull_parse} to parse the rest of the input
stream. This function is available if the @code{%define push_pull "both"} stream. This function is available if the @code{%define api.push_pull "both"}
declaration is used. declaration is used.
@xref{Push Decl, ,A Push Parser}. @xref{Push Decl, ,A Push Parser}.
@@ -5295,8 +5295,8 @@ The value returned by @code{yypull_parse} is the same as for @code{yyparse}.
@findex yypstate_new @findex yypstate_new
You call the function @code{yypstate_new} to create a new parser instance. You call the function @code{yypstate_new} to create a new parser instance.
This function is available if either the @code{%define push_pull "push"} or This function is available if either the @code{%define api.push_pull "push"} or
@code{%define push_pull "both"} declaration is used. @code{%define api.push_pull "both"} declaration is used.
@xref{Push Decl, ,A Push Parser}. @xref{Push Decl, ,A Push Parser}.
@deftypefun yypstate *yypstate_new (void) @deftypefun yypstate *yypstate_new (void)
@@ -5309,8 +5309,8 @@ or NULL if no memory was available.
@findex yypstate_delete @findex yypstate_delete
You call the function @code{yypstate_delete} to delete a parser instance. You call the function @code{yypstate_delete} to delete a parser instance.
function is available if either the @code{%define push_pull "push"} or function is available if either the @code{%define api.push_pull "push"} or
@code{%define push_pull "both"} declaration is used. @code{%define api.push_pull "both"} declaration is used.
@xref{Push Decl, ,A Push Parser}. @xref{Push Decl, ,A Push Parser}.
@deftypefun void yypstate_delete (yypstate *yyps) @deftypefun void yypstate_delete (yypstate *yyps)

View File

@@ -560,7 +560,7 @@ AT_CHECK_CALC_LALR([%yacc])
AT_CHECK_CALC_LALR([%error-verbose]) AT_CHECK_CALC_LALR([%error-verbose])
AT_CHECK_CALC_LALR([%pure-parser %locations]) AT_CHECK_CALC_LALR([%pure-parser %locations])
AT_CHECK_CALC_LALR([%define push_pull "both" %pure-parser %locations]) AT_CHECK_CALC_LALR([%define api.push_pull "both" %pure-parser %locations])
AT_CHECK_CALC_LALR([%error-verbose %locations]) AT_CHECK_CALC_LALR([%error-verbose %locations])
AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix "calc" %verbose %yacc]) 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([%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([%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([%define api.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}]) 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}])

View File

@@ -848,13 +848,13 @@ AT_CLEANUP
AT_SETUP([[%define enum variables]]) AT_SETUP([[%define enum variables]])
AT_DATA([[input.y]], AT_DATA([[input.y]],
[[%define push_pull "neither" [[%define api.push_pull "neither"
%% %%
start: ; start: ;
]]) ]])
AT_CHECK([[bison input.y]], [1], [], AT_CHECK([[bison input.y]], [1], [],
[[input.y:1.9-17: invalid value for %define variable `push_pull': `neither' [[input.y:1.9-21: invalid value for %define variable `api.push_pull': `neither'
]]) ]])
AT_CLEANUP AT_CLEANUP

View File

@@ -33,7 +33,7 @@ AT_DATA_GRAMMAR([[input.y]],
void yyerror (char const *msg); void yyerror (char const *msg);
%} %}
%pure-parser %define push_pull "push" %pure-parser %define api.push_pull "push"
%% %%
@@ -92,7 +92,7 @@ AT_DATA_GRAMMAR([[input.y]],
int yylex (void); int yylex (void);
%} %}
%define push_pull "both" %define api.push_pull "both"
%% %%
@@ -158,13 +158,13 @@ AT_SETUP([[Push Parsing: Unsupported Skeletons]])
AT_DATA([[input.y]], AT_DATA([[input.y]],
[[%glr-parser [[%glr-parser
%define push_pull "push" %define api.push_pull "push"
%% %%
start: ; start: ;
]]) ]])
AT_CHECK([[bison input.y]], [0], [], AT_CHECK([[bison input.y]], [0], [],
[[input.y:2.9-17: warning: %define variable `push_pull' is not used [[input.y:2.9-21: warning: %define variable `api.push_pull' is not used
]]) ]])
AT_CLEANUP AT_CLEANUP

View File

@@ -496,7 +496,7 @@ AT_PARSER_CHECK([./input 10000], 2, [], [ignore],
# just helps guarantee we don't let the YYSTACK_USE_ALLOCA feature affect # just helps guarantee we don't let the YYSTACK_USE_ALLOCA feature affect
# push parsers. # push parsers.
AT_DATA_STACK_TORTURE([AT_USE_ALLOCA], AT_DATA_STACK_TORTURE([AT_USE_ALLOCA],
[[%define push_pull "both" [[%define api.push_pull "both"
]]) ]])
AT_PARSER_CHECK([./input 20], 0, [], [ignore], AT_PARSER_CHECK([./input 20], 0, [], [ignore],
[[VALGRIND_OPTS="$VALGRIND_OPTS --log-fd=1"]]) [[VALGRIND_OPTS="$VALGRIND_OPTS --log-fd=1"]])
@@ -534,7 +534,7 @@ AT_PARSER_CHECK([./input 10000], 2, [], [ignore],
[[VALGRIND_OPTS="$VALGRIND_OPTS --log-fd=1"]]) [[VALGRIND_OPTS="$VALGRIND_OPTS --log-fd=1"]])
AT_DATA_STACK_TORTURE([AT_USE_ALLOCA], AT_DATA_STACK_TORTURE([AT_USE_ALLOCA],
[[%define push_pull "both" [[%define api.push_pull "both"
]]) ]])
AT_PARSER_CHECK([./input 20], 0, [], [ignore], AT_PARSER_CHECK([./input 20], 0, [], [ignore],
[[VALGRIND_OPTS="$VALGRIND_OPTS --log-fd=1"]]) [[VALGRIND_OPTS="$VALGRIND_OPTS --log-fd=1"]])