mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-18 00:33:03 +00:00
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:
45
ChangeLog
45
ChangeLog
@@ -1,3 +1,48 @@
|
|||||||
|
2007-10-28 Joel E. Denny <jdenny@ces.clemson.edu>
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
2007-10-28 Joel E. Denny <jdenny@ces.clemson.edu>
|
2007-10-28 Joel E. Denny <jdenny@ces.clemson.edu>
|
||||||
|
|
||||||
%define push_pull -> %define api.push_pull. Discussed starting at
|
%define push_pull -> %define api.push_pull. Discussed starting at
|
||||||
|
|||||||
17
NEWS
17
NEWS
@@ -3,6 +3,18 @@ Bison News
|
|||||||
|
|
||||||
Changes in version 2.3a+ (????-??-??):
|
Changes in version 2.3a+ (????-??-??):
|
||||||
|
|
||||||
|
* The quotes around NAME that used to be required in the following directive
|
||||||
|
are now deprecated:
|
||||||
|
|
||||||
|
%define NAME "VALUE"
|
||||||
|
|
||||||
|
* The directive `%pure-parser' is now deprecated in favor of:
|
||||||
|
|
||||||
|
%define api.pure
|
||||||
|
|
||||||
|
which has the same effect except that Bison is more careful to warn about
|
||||||
|
unreasonable usage in the latter case.
|
||||||
|
|
||||||
* Push Parsing
|
* Push Parsing
|
||||||
|
|
||||||
Bison can now generate an LALR(1) parser in C with a push interface. That
|
Bison can now generate an LALR(1) parser in C with a push interface. That
|
||||||
@@ -69,11 +81,6 @@ Changes in version 2.3a+ (????-??-??):
|
|||||||
%name-prefix "c_"
|
%name-prefix "c_"
|
||||||
%output "parser.c"
|
%output "parser.c"
|
||||||
|
|
||||||
* The quotes around NAME that used to be required in the following directive
|
|
||||||
are now deprecated:
|
|
||||||
|
|
||||||
%define NAME "VALUE"
|
|
||||||
|
|
||||||
* An Alternative to `%{...%}' -- `%code QUALIFIER {CODE}'
|
* An Alternative to `%{...%}' -- `%code QUALIFIER {CODE}'
|
||||||
|
|
||||||
Bison 2.3a provided a new set of directives as a more flexible alternative to
|
Bison 2.3a provided a new set of directives as a more flexible alternative to
|
||||||
|
|||||||
@@ -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([glr]) # Whether a GLR parser is requested.
|
||||||
b4_define_flag_if([locations]) # Whether locations are tracked.
|
b4_define_flag_if([locations]) # Whether locations are tracked.
|
||||||
b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled.
|
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.
|
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
23
data/c.m4
23
data/c.m4
@@ -28,22 +28,31 @@ m4_define([b4_comment], [/* m4_bpatsubst([$1], [
|
|||||||
|
|
||||||
# b4_identification
|
# 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],
|
m4_define([b4_identification],
|
||||||
[/* Identify Bison output. */
|
[[/* Identify Bison output. */
|
||||||
[#]define YYBISON 1
|
#define YYBISON 1
|
||||||
|
|
||||||
/* Bison version. */
|
/* Bison version. */
|
||||||
[#]define YYBISON_VERSION "b4_version"
|
#define YYBISON_VERSION "]b4_version["
|
||||||
|
|
||||||
/* Skeleton name. */
|
/* Skeleton name. */
|
||||||
[#]define YYSKELETON_NAME b4_skeleton
|
#define YYSKELETON_NAME ]b4_skeleton[]m4_ifdef([b4_pure_flag], [[
|
||||||
|
|
||||||
/* Pure parsers. */
|
/* 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. */
|
/* Using locations. */
|
||||||
[#]define YYLSP_NEEDED b4_locations_flag
|
#define YYLSP_NEEDED ]b4_locations_flag[
|
||||||
])
|
]])
|
||||||
|
|
||||||
|
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
|
|||||||
@@ -34,6 +34,13 @@ m4_define_default([b4_stack_depth_init], [200])
|
|||||||
## Pure/impure interfaces. ##
|
## 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
|
# b4_user_formals
|
||||||
# ---------------
|
# ---------------
|
||||||
|
|||||||
13
data/push.c
13
data/push.c
@@ -51,6 +51,10 @@ m4_define_default([b4_stack_depth_init], [200])
|
|||||||
## Pure/impure interfaces. ##
|
## 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)
|
# 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
|
define necessary library symbols; they are noted "INFRINGES ON
|
||||||
USER NAME SPACE" below. */
|
USER NAME SPACE" below. */
|
||||||
|
|
||||||
]b4_identification[
|
]b4_identification
|
||||||
/* Push parsers. */
|
|
||||||
#define YYPUSH ]b4_push_flag[
|
|
||||||
|
|
||||||
/* Pull parsers. */
|
b4_percent_code_get([[top]])[]dnl
|
||||||
#define YYPULL ]b4_pull_flag[
|
|
||||||
|
|
||||||
]b4_percent_code_get([[top]])[]dnl
|
|
||||||
m4_if(b4_prefix, [yy], [],
|
m4_if(b4_prefix, [yy], [],
|
||||||
[[/* Substitute the variable and function names. */
|
[[/* Substitute the variable and function names. */
|
||||||
]b4_pull_if([[#define yyparse ]b4_prefix[parse
|
]b4_pull_if([[#define yyparse ]b4_prefix[parse
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ m4_define_default([b4_stack_depth_init], [200])
|
|||||||
## Pure/impure interfaces. ##
|
## 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)
|
# b4_yacc_pure_if(IF-TRUE, IF-FALSE)
|
||||||
# ----------------------------------
|
# ----------------------------------
|
||||||
|
|||||||
@@ -4487,7 +4487,7 @@ may override this restriction with the @code{%start} declaration as follows:
|
|||||||
@subsection A Pure (Reentrant) Parser
|
@subsection A Pure (Reentrant) Parser
|
||||||
@cindex reentrant parser
|
@cindex reentrant parser
|
||||||
@cindex pure parser
|
@cindex pure parser
|
||||||
@findex %pure-parser
|
@findex %define api.pure
|
||||||
|
|
||||||
A @dfn{reentrant} program is one which does not alter in the course of
|
A @dfn{reentrant} program is one which does not alter in the course of
|
||||||
execution; in other words, it consists entirely of @dfn{pure} (read-only)
|
execution; in other words, it consists entirely of @dfn{pure} (read-only)
|
||||||
@@ -4503,11 +4503,11 @@ statically allocated variables for communication with @code{yylex},
|
|||||||
including @code{yylval} and @code{yylloc}.)
|
including @code{yylval} and @code{yylloc}.)
|
||||||
|
|
||||||
Alternatively, you can generate a pure, reentrant parser. The Bison
|
Alternatively, you can generate a pure, reentrant parser. The Bison
|
||||||
declaration @code{%pure-parser} says that you want the parser to be
|
declaration @code{%define api.pure} says that you want the parser to be
|
||||||
reentrant. It looks like this:
|
reentrant. It looks like this:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
%pure-parser
|
%define api.pure
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
The result is that the communication variables @code{yylval} and
|
The result is that the communication variables @code{yylval} and
|
||||||
@@ -4554,7 +4554,7 @@ compatibility with the impure Yacc pull mode interface. Unless you know
|
|||||||
what you are doing, your declarations should look like this:
|
what you are doing, your declarations should look like this:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
%pure-parser
|
%define api.pure
|
||||||
%define api.push_pull "push"
|
%define api.push_pull "push"
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@@ -4627,8 +4627,8 @@ yypull_parse (ps); /* Will call the lexer */
|
|||||||
yypstate_delete (ps);
|
yypstate_delete (ps);
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
Adding the @code{%pure-parser} declaration does exactly the same thing to the
|
Adding the @code{%define api.pure} declaration does exactly the same thing to
|
||||||
generated parser with @code{%define api.push_pull "both"} as it did for
|
the generated parser with @code{%define api.push_pull "both"} as it did for
|
||||||
@code{%define api.push_pull "push"}.
|
@code{%define api.push_pull "push"}.
|
||||||
|
|
||||||
@node Decl Summary
|
@node Decl Summary
|
||||||
@@ -4837,6 +4837,20 @@ 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 api.pure
|
||||||
|
@findex %define api.pure
|
||||||
|
|
||||||
|
@itemize @bullet
|
||||||
|
@item Language(s): C
|
||||||
|
|
||||||
|
@item Purpose: Request a pure (reentrant) parser program.
|
||||||
|
@xref{Pure Decl, ,A Pure (Reentrant) Parser}.
|
||||||
|
|
||||||
|
@item Accepted Values: Boolean
|
||||||
|
|
||||||
|
@item Default Value: @code{"false"}
|
||||||
|
@end itemize
|
||||||
|
|
||||||
@item api.push_pull
|
@item api.push_pull
|
||||||
@findex %define api.push_pull
|
@findex %define api.push_pull
|
||||||
|
|
||||||
@@ -5054,8 +5068,8 @@ Specify @var{file} for the parser file.
|
|||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn {Directive} %pure-parser
|
@deffn {Directive} %pure-parser
|
||||||
Request a pure (reentrant) parser program (@pxref{Pure Decl, ,A Pure
|
Deprecated version of @code{%define api.pure} (@pxref{Decl Summary, ,%define}),
|
||||||
(Reentrant) Parser}).
|
for which Bison is more careful to warn about unreasonable usage.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn {Directive} %require "@var{version}"
|
@deffn {Directive} %require "@var{version}"
|
||||||
@@ -5498,7 +5512,7 @@ The data type of @code{yylloc} has the name @code{YYLTYPE}.
|
|||||||
@node Pure Calling
|
@node Pure Calling
|
||||||
@subsection Calling Conventions for Pure Parsers
|
@subsection Calling Conventions for Pure Parsers
|
||||||
|
|
||||||
When you use the Bison declaration @code{%pure-parser} to request a
|
When you use the Bison declaration @code{%define api.pure} to request a
|
||||||
pure, reentrant parser, the global communication variables @code{yylval}
|
pure, reentrant parser, the global communication variables @code{yylval}
|
||||||
and @code{yylloc} cannot be used. (@xref{Pure Decl, ,A Pure (Reentrant)
|
and @code{yylloc} cannot be used. (@xref{Pure Decl, ,A Pure (Reentrant)
|
||||||
Parser}.) In such parsers the two global variables are replaced by
|
Parser}.) In such parsers the two global variables are replaced by
|
||||||
@@ -5549,7 +5563,7 @@ int yylex (int *nastiness);
|
|||||||
int yyparse (int *nastiness, int *randomness);
|
int yyparse (int *nastiness, int *randomness);
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
If @code{%pure-parser} is added:
|
If @code{%define api.pure} is added:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
int yylex (YYSTYPE *lvalp, int *nastiness);
|
int yylex (YYSTYPE *lvalp, int *nastiness);
|
||||||
@@ -5557,7 +5571,7 @@ int yyparse (int *nastiness, int *randomness);
|
|||||||
@end example
|
@end example
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
and finally, if both @code{%pure-parser} and @code{%locations} are used:
|
and finally, if both @code{%define api.pure} and @code{%locations} are used:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
int yylex (YYSTYPE *lvalp, YYLTYPE *llocp, int *nastiness);
|
int yylex (YYSTYPE *lvalp, YYLTYPE *llocp, int *nastiness);
|
||||||
@@ -5623,7 +5637,7 @@ Obviously, in location tracking pure parsers, @code{yyerror} should have
|
|||||||
an access to the current location.
|
an access to the current location.
|
||||||
This is indeed the case for the @acronym{GLR}
|
This is indeed the case for the @acronym{GLR}
|
||||||
parsers, but not for the Yacc parser, for historical reasons. I.e., if
|
parsers, but not for the Yacc parser, for historical reasons. I.e., if
|
||||||
@samp{%locations %pure-parser} is passed then the prototypes for
|
@samp{%locations %define api.pure} is passed then the prototypes for
|
||||||
@code{yyerror} are:
|
@code{yyerror} are:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
@@ -5641,13 +5655,14 @@ void yyerror (int *nastiness, char const *msg); /* GLR parsers. */
|
|||||||
Finally, @acronym{GLR} and Yacc parsers share the same @code{yyerror} calling
|
Finally, @acronym{GLR} and Yacc parsers share the same @code{yyerror} calling
|
||||||
convention for absolutely pure parsers, i.e., when the calling
|
convention for absolutely pure parsers, i.e., when the calling
|
||||||
convention of @code{yylex} @emph{and} the calling convention of
|
convention of @code{yylex} @emph{and} the calling convention of
|
||||||
@code{%pure-parser} are pure. I.e.:
|
@code{%define api.pure} are pure.
|
||||||
|
I.e.:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
/* Location tracking. */
|
/* Location tracking. */
|
||||||
%locations
|
%locations
|
||||||
/* Pure yylex. */
|
/* Pure yylex. */
|
||||||
%pure-parser
|
%define api.pure
|
||||||
%lex-param @{int *nastiness@}
|
%lex-param @{int *nastiness@}
|
||||||
/* Pure yyparse. */
|
/* Pure yyparse. */
|
||||||
%parse-param @{int *nastiness@}
|
%parse-param @{int *nastiness@}
|
||||||
@@ -8108,7 +8123,7 @@ described by @var{m}.
|
|||||||
|
|
||||||
The parser invokes the scanner by calling @code{yylex}. Contrary to C
|
The parser invokes the scanner by calling @code{yylex}. Contrary to C
|
||||||
parsers, C++ parsers are always pure: there is no point in using the
|
parsers, C++ parsers are always pure: there is no point in using the
|
||||||
@code{%pure-parser} directive. Therefore the interface is as follows.
|
@code{%define api.pure} directive. Therefore the interface is as follows.
|
||||||
|
|
||||||
@deftypemethod {parser} {int} yylex (semantic_value_type& @var{yylval}, location_type& @var{yylloc}, @var{type1} @var{arg1}, ...)
|
@deftypemethod {parser} {int} yylex (semantic_value_type& @var{yylval}, location_type& @var{yylloc}, @var{type1} @var{arg1}, ...)
|
||||||
Return the next token. Its type is the return value, its semantic
|
Return the next token. Its type is the return value, its semantic
|
||||||
@@ -8860,10 +8875,9 @@ The return type can be changed using @samp{%define "stype"
|
|||||||
@end deftypemethod
|
@end deftypemethod
|
||||||
|
|
||||||
|
|
||||||
If @code{%pure-parser} is not specified, the lexer interface
|
The lexer interface resides in the same class (@code{YYParser}) as the
|
||||||
resides in the same class (@code{YYParser}) as the Bison-generated
|
Bison-generated parser.
|
||||||
parser. The fields and methods that are provided to
|
The fields and methods that are provided to this end are as follows.
|
||||||
this end are as follows.
|
|
||||||
|
|
||||||
@deftypemethod {YYParser} {void} error (Location @var{l}, String @var{m})
|
@deftypemethod {YYParser} {void} error (Location @var{l}, String @var{m})
|
||||||
As explained in @pxref{Java Parser Interface}, this method is defined
|
As explained in @pxref{Java Parser Interface}, this method is defined
|
||||||
@@ -8996,7 +9010,7 @@ or
|
|||||||
@display
|
@display
|
||||||
My parser includes support for an @samp{#include}-like feature, in
|
My parser includes support for an @samp{#include}-like feature, in
|
||||||
which case I run @code{yyparse} from @code{yyparse}. This fails
|
which case I run @code{yyparse} from @code{yyparse}. This fails
|
||||||
although I did specify I needed a @code{%pure-parser}.
|
although I did specify @code{%define api.pure}.
|
||||||
@end display
|
@end display
|
||||||
|
|
||||||
These problems typically come not from Bison itself, but from
|
These problems typically come not from Bison itself, but from
|
||||||
@@ -9558,8 +9572,8 @@ Bison declaration to assign a precedence to a specific rule.
|
|||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn {Directive} %pure-parser
|
@deffn {Directive} %pure-parser
|
||||||
Bison declaration to request a pure (reentrant) parser.
|
Deprecated version of @code{%define api.pure} (@pxref{Decl Summary, ,%define}),
|
||||||
@xref{Pure Decl, ,A Pure (Reentrant) Parser}.
|
for which Bison is more careful to warn about unreasonable usage.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn {Directive} %require "@var{version}"
|
@deffn {Directive} %require "@var{version}"
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ bool error_verbose = false;
|
|||||||
|
|
||||||
bool nondeterministic_parser = false;
|
bool nondeterministic_parser = false;
|
||||||
bool glr_parser = false;
|
bool glr_parser = false;
|
||||||
bool pure_parser = false;
|
|
||||||
|
|
||||||
int report_flag = report_none;
|
int report_flag = report_none;
|
||||||
int trace_flag = trace_none;
|
int trace_flag = trace_none;
|
||||||
|
|||||||
@@ -51,11 +51,6 @@ extern bool error_verbose;
|
|||||||
|
|
||||||
extern bool glr_parser;
|
extern bool glr_parser;
|
||||||
|
|
||||||
/* PURE_PARSER is true if should generate a parser that is all pure
|
|
||||||
and reentrant. */
|
|
||||||
|
|
||||||
extern bool pure_parser;
|
|
||||||
|
|
||||||
/* NONDETERMINISTIC_PARSER is true iff conflicts are accepted. This
|
/* NONDETERMINISTIC_PARSER is true iff conflicts are accepted. This
|
||||||
is used by the GLR parser, and might be used in BackTracking
|
is used by the GLR parser, and might be used in BackTracking
|
||||||
parsers too. */
|
parsers too. */
|
||||||
|
|||||||
@@ -571,7 +571,6 @@ prepare (void)
|
|||||||
MUSCLE_INSERT_BOOL ("glr_flag", glr_parser);
|
MUSCLE_INSERT_BOOL ("glr_flag", glr_parser);
|
||||||
MUSCLE_INSERT_BOOL ("locations_flag", locations_flag);
|
MUSCLE_INSERT_BOOL ("locations_flag", locations_flag);
|
||||||
MUSCLE_INSERT_BOOL ("nondeterministic_flag", nondeterministic_parser);
|
MUSCLE_INSERT_BOOL ("nondeterministic_flag", nondeterministic_parser);
|
||||||
MUSCLE_INSERT_BOOL ("pure_flag", pure_parser);
|
|
||||||
MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag);
|
MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag);
|
||||||
MUSCLE_INSERT_BOOL ("tag_seen_flag", tag_seen);
|
MUSCLE_INSERT_BOOL ("tag_seen_flag", tag_seen);
|
||||||
MUSCLE_INSERT_BOOL ("use_push_for_pull_flag", use_push_for_pull_flag);
|
MUSCLE_INSERT_BOOL ("use_push_for_pull_flag", use_push_for_pull_flag);
|
||||||
|
|||||||
393
src/parse-gram.c
393
src/parse-gram.c
File diff suppressed because it is too large
Load Diff
@@ -160,7 +160,7 @@
|
|||||||
typedef union YYSTYPE
|
typedef union YYSTYPE
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Line 1538 of yacc.c */
|
/* Line 1542 of yacc.c */
|
||||||
#line 94 "parse-gram.y"
|
#line 94 "parse-gram.y"
|
||||||
|
|
||||||
symbol *symbol;
|
symbol *symbol;
|
||||||
@@ -174,7 +174,7 @@ typedef union YYSTYPE
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Line 1538 of yacc.c */
|
/* Line 1542 of yacc.c */
|
||||||
#line 179 "parse-gram.h"
|
#line 179 "parse-gram.h"
|
||||||
} YYSTYPE;
|
} YYSTYPE;
|
||||||
# define YYSTYPE_IS_TRIVIAL 1
|
# define YYSTYPE_IS_TRIVIAL 1
|
||||||
|
|||||||
@@ -266,7 +266,19 @@ prologue_declaration:
|
|||||||
| "%output" STRING { spec_outfile = $2; }
|
| "%output" STRING { spec_outfile = $2; }
|
||||||
| "%output" "=" STRING { spec_outfile = $3; } /* deprecated */
|
| "%output" "=" STRING { spec_outfile = $3; } /* deprecated */
|
||||||
| "%parse-param" "{...}" { add_param ("parse_param", $2, @2); }
|
| "%parse-param" "{...}" { add_param ("parse_param", $2, @2); }
|
||||||
| "%pure-parser" { pure_parser = true; }
|
| "%pure-parser"
|
||||||
|
{
|
||||||
|
/* %pure-parser is deprecated in favor of `%define api.pure', so use
|
||||||
|
`%define api.pure' in a backward-compatible manner here. First, don't
|
||||||
|
complain if %pure-parser is specified multiple times. */
|
||||||
|
if (!muscle_find_const ("percent_define(api.pure)"))
|
||||||
|
muscle_percent_define_insert ("api.pure", @1, "");
|
||||||
|
/* In all cases, use api.pure now so that the backend doesn't complain if
|
||||||
|
the skeleton ignores api.pure, but do warn now if there's a previous
|
||||||
|
conflicting definition from an actual %define. */
|
||||||
|
if (!muscle_percent_define_flag_if ("api.pure"))
|
||||||
|
muscle_percent_define_insert ("api.pure", @1, "");
|
||||||
|
}
|
||||||
| "%require" STRING { version_check (&@2, $2); }
|
| "%require" STRING { version_check (&@2, $2); }
|
||||||
| "%skeleton" STRING
|
| "%skeleton" STRING
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -559,8 +559,8 @@ AT_CHECK_CALC_LALR([%verbose])
|
|||||||
AT_CHECK_CALC_LALR([%yacc])
|
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([%define api.pure %locations])
|
||||||
AT_CHECK_CALC_LALR([%define api.push_pull "both" %pure-parser %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])
|
||||||
|
|
||||||
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])
|
||||||
@@ -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([%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([%define api.pure %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.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([%yacc])
|
||||||
AT_CHECK_CALC_GLR([%error-verbose])
|
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])
|
||||||
|
|
||||||
AT_CHECK_CALC_GLR([%error-verbose %locations %defines %name-prefix "calc" %verbose %yacc])
|
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([%debug])
|
||||||
AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
|
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}])
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------- #
|
# ----------------------------- #
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# Checking GLR Parsing. -*- Autotest -*-
|
# 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
|
# 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
|
# 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_CLEANUP
|
||||||
|
|
||||||
AT_SETUP([GLR: Resolve ambiguity, pure, no locations])
|
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])
|
[%dprec 1], [%dprec 2])
|
||||||
AT_PARSER_CHECK([[./types test-input]], 0,
|
AT_PARSER_CHECK([[./types test-input]], 0,
|
||||||
_AT_RESOLVED_GLR_OUTPUT, _AT_GLR_STDERR)
|
_AT_RESOLVED_GLR_OUTPUT, _AT_GLR_STDERR)
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
AT_SETUP([GLR: Resolve ambiguity, pure, locations])
|
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])
|
[%dprec 1], [%dprec 2])
|
||||||
AT_PARSER_CHECK([[./types test-input]], 0,
|
AT_PARSER_CHECK([[./types test-input]], 0,
|
||||||
_AT_RESOLVED_GLR_OUTPUT_WITH_LOC, _AT_GLR_STDERR)
|
_AT_RESOLVED_GLR_OUTPUT_WITH_LOC, _AT_GLR_STDERR)
|
||||||
@@ -451,13 +452,13 @@ AT_PARSER_CHECK([[./types test-input]], 0,
|
|||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
AT_SETUP([GLR: Merge conflicting parses, pure, no locations])
|
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>])
|
[%merge <stmtMerge>], [%merge <stmtMerge>])
|
||||||
AT_PARSER_CHECK([[./types test-input]], 0,
|
AT_PARSER_CHECK([[./types test-input]], 0,
|
||||||
_AT_AMBIG_GLR_OUTPUT, _AT_GLR_STDERR)
|
_AT_AMBIG_GLR_OUTPUT, _AT_GLR_STDERR)
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
AT_SETUP([GLR: Merge conflicting parses, pure, locations])
|
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>])
|
[%merge <stmtMerge>],[%merge <stmtMerge>])
|
||||||
AT_PARSER_CHECK([[./types test-input]], 0,
|
AT_PARSER_CHECK([[./types test-input]], 0,
|
||||||
_AT_AMBIG_GLR_OUTPUT_WITH_LOC, _AT_GLR_STDERR)
|
_AT_AMBIG_GLR_OUTPUT_WITH_LOC, _AT_GLR_STDERR)
|
||||||
|
|||||||
@@ -1646,7 +1646,7 @@ AT_DATA_GRAMMAR([glr-regr17.y],
|
|||||||
[[
|
[[
|
||||||
%glr-parser
|
%glr-parser
|
||||||
%locations
|
%locations
|
||||||
%pure-parser
|
%define api.pure
|
||||||
%error-verbose
|
%error-verbose
|
||||||
|
|
||||||
%union { int dummy; }
|
%union { int dummy; }
|
||||||
|
|||||||
@@ -859,6 +859,39 @@ AT_CHECK([[bison input.y]], [1], [],
|
|||||||
|
|
||||||
AT_CLEANUP
|
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. ##
|
## C++ namespace reference errors. ##
|
||||||
## -------------------------------- ##
|
## -------------------------------- ##
|
||||||
|
|||||||
@@ -57,10 +57,11 @@ m4_pushdef([AT_PARAM_IF],
|
|||||||
m4_pushdef([AT_LOCATION_IF],
|
m4_pushdef([AT_LOCATION_IF],
|
||||||
[m4_bmatch([$3], [%locations], [$1], [$2])])
|
[m4_bmatch([$3], [%locations], [$1], [$2])])
|
||||||
m4_pushdef([AT_PURE_IF],
|
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_pushdef([AT_PURE_AND_LOC_IF],
|
||||||
[m4_bmatch([$3], [%locations.*%pure-parser\|%pure-parser.*%locations],
|
[m4_bmatch([$3], [%locations], [AT_PURE_IF($@)], [$2])])
|
||||||
[$1], [$2])])
|
|
||||||
m4_pushdef([AT_GLR_OR_PARAM_IF],
|
m4_pushdef([AT_GLR_OR_PARAM_IF],
|
||||||
[m4_bmatch([$3], [%glr-parser\|%parse-param], [$1], [$2])])
|
[m4_bmatch([$3], [%glr-parser\|%parse-param], [$1], [$2])])
|
||||||
m4_pushdef([AT_NAME_PREFIX],
|
m4_pushdef([AT_NAME_PREFIX],
|
||||||
@@ -79,7 +80,7 @@ m4_pushdef([AT_YYERROR_SEES_LOC_IF],
|
|||||||
[$1])],
|
[$1])],
|
||||||
[$2])])
|
[$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.
|
# are using the C++ parsers.
|
||||||
m4_pushdef([AT_PURE_LEX_IF],
|
m4_pushdef([AT_PURE_LEX_IF],
|
||||||
[AT_PURE_IF([$1],
|
[AT_PURE_IF([$1],
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ AT_DATA_GRAMMAR([[input.y]],
|
|||||||
void yyerror (char const *msg);
|
void yyerror (char const *msg);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%pure-parser %define api.push_pull "push"
|
%define api.pure %define api.push_pull "push"
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user