mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
Remove restrictions on expanding GLR stacks in C++.
* data/glr.c: Remove tests for __cplusplus related to definition of
YYSTACKEXPANDABLE.
* doc/bison.texinfo: Rewrite paragraph saying C++ stacks are not
expandable to instead indicate conditions that prevent their expansion
in C++. Reorganize section on GLR semantic values a bit. Remove
discussion of YYLLOC_DEFAULT. Mention restrictions to POD data.
This commit is contained in:
@@ -576,13 +576,7 @@ int yydebug;
|
|||||||
#define YYHEADROOM 2
|
#define YYHEADROOM 2
|
||||||
|
|
||||||
#ifndef YYSTACKEXPANDABLE
|
#ifndef YYSTACKEXPANDABLE
|
||||||
# if (! defined __cplusplus \
|
|
||||||
|| (]b4_locations_if([[defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
|
|
||||||
&& ]])[defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))
|
|
||||||
# define YYSTACKEXPANDABLE 1
|
# define YYSTACKEXPANDABLE 1
|
||||||
# else
|
|
||||||
# define YYSTACKEXPANDABLE 0
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if YYSTACKEXPANDABLE
|
#if YYSTACKEXPANDABLE
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ Writing @acronym{GLR} Parsers
|
|||||||
|
|
||||||
* Simple GLR Parsers:: Using @acronym{GLR} parsers on unambiguous grammars.
|
* Simple GLR Parsers:: Using @acronym{GLR} parsers on unambiguous grammars.
|
||||||
* Merging GLR Parses:: Using @acronym{GLR} parsers to resolve ambiguities.
|
* Merging GLR Parses:: Using @acronym{GLR} parsers to resolve ambiguities.
|
||||||
* GLR Semantic Actions:: Deferred semantic actions have special concerns.
|
* GLR Semantic Actions:: Considerations for semantic values and deferred actions.
|
||||||
* Semantic Predicates:: Controlling a parse with arbitrary computations.
|
* Semantic Predicates:: Controlling a parse with arbitrary computations.
|
||||||
* Compiler Requirements:: @acronym{GLR} parsers require a modern C compiler.
|
* Compiler Requirements:: @acronym{GLR} parsers require a modern C compiler.
|
||||||
|
|
||||||
@@ -758,7 +758,7 @@ merged result.
|
|||||||
@menu
|
@menu
|
||||||
* Simple GLR Parsers:: Using @acronym{GLR} parsers on unambiguous grammars.
|
* Simple GLR Parsers:: Using @acronym{GLR} parsers on unambiguous grammars.
|
||||||
* Merging GLR Parses:: Using @acronym{GLR} parsers to resolve ambiguities.
|
* Merging GLR Parses:: Using @acronym{GLR} parsers to resolve ambiguities.
|
||||||
* GLR Semantic Actions:: Deferred semantic actions have special concerns.
|
* GLR Semantic Actions:: Considerations for semantic values and deferred actions.
|
||||||
* Semantic Predicates:: Controlling a parse with arbitrary computations.
|
* Semantic Predicates:: Controlling a parse with arbitrary computations.
|
||||||
* Compiler Requirements:: @acronym{GLR} parsers require a modern C compiler.
|
* Compiler Requirements:: @acronym{GLR} parsers require a modern C compiler.
|
||||||
@end menu
|
@end menu
|
||||||
@@ -1119,6 +1119,10 @@ the offending merge.
|
|||||||
@node GLR Semantic Actions
|
@node GLR Semantic Actions
|
||||||
@subsection GLR Semantic Actions
|
@subsection GLR Semantic Actions
|
||||||
|
|
||||||
|
The nature of @acronym{GLR} parsing and the structure of the generated
|
||||||
|
parsers give rise to certain restrictions on semantic values and actions.
|
||||||
|
|
||||||
|
@subsubsection Deferred semantic actions
|
||||||
@cindex deferred semantic actions
|
@cindex deferred semantic actions
|
||||||
By definition, a deferred semantic action is not performed at the same time as
|
By definition, a deferred semantic action is not performed at the same time as
|
||||||
the associated reduction.
|
the associated reduction.
|
||||||
@@ -1152,6 +1156,7 @@ For example, if a semantic action might be deferred, you should never write it
|
|||||||
to invoke @code{yyclearin} (@pxref{Action Features}) or to attempt to free
|
to invoke @code{yyclearin} (@pxref{Action Features}) or to attempt to free
|
||||||
memory referenced by @code{yylval}.
|
memory referenced by @code{yylval}.
|
||||||
|
|
||||||
|
@subsubsection YYERROR
|
||||||
@findex YYERROR
|
@findex YYERROR
|
||||||
@cindex @acronym{GLR} parsers and @code{YYERROR}
|
@cindex @acronym{GLR} parsers and @code{YYERROR}
|
||||||
Another Bison feature requiring special consideration is @code{YYERROR}
|
Another Bison feature requiring special consideration is @code{YYERROR}
|
||||||
@@ -1159,11 +1164,17 @@ Another Bison feature requiring special consideration is @code{YYERROR}
|
|||||||
initiate error recovery.
|
initiate error recovery.
|
||||||
During deterministic @acronym{GLR} operation, the effect of @code{YYERROR} is
|
During deterministic @acronym{GLR} operation, the effect of @code{YYERROR} is
|
||||||
the same as its effect in a deterministic parser.
|
the same as its effect in a deterministic parser.
|
||||||
In a deferred semantic action, its effect is undefined.
|
The effect in a deferred action is similar, but the precise point of the
|
||||||
@c The effect is probably a syntax error at the split point.
|
error is undefined; instead, the parser reverts to deterministic operation,
|
||||||
|
selecting an unspecified stack on which to continue with a syntax error.
|
||||||
|
In a semantic predicate (see @ref{Semantic Predicates}) during nondeterministic
|
||||||
|
parsing, @code{YYERROR} silently prunes
|
||||||
|
the parse that invoked the test.
|
||||||
|
|
||||||
Also, see @ref{Location Default Action, ,Default Action for Locations}, which
|
@subsubsection Restrictions on semantic values and locations
|
||||||
describes a special usage of @code{YYLLOC_DEFAULT} in @acronym{GLR} parsers.
|
@acronym{GLR} parsers require that you use POD (Plain Old Data) types for
|
||||||
|
semantic values and location types when using the generated parsers as
|
||||||
|
C++ code.
|
||||||
|
|
||||||
@node Semantic Predicates
|
@node Semantic Predicates
|
||||||
@subsection Controlling a Parse with Arbitrary Predicates
|
@subsection Controlling a Parse with Arbitrary Predicates
|
||||||
@@ -7388,12 +7399,14 @@ that allows variable-length arrays. The default is 200.
|
|||||||
|
|
||||||
Do not allow @code{YYINITDEPTH} to be greater than @code{YYMAXDEPTH}.
|
Do not allow @code{YYINITDEPTH} to be greater than @code{YYMAXDEPTH}.
|
||||||
|
|
||||||
@c FIXME: C++ output.
|
You can generate a deterministic parser containing C++ user code from
|
||||||
Because of semantic differences between C and C++, the deterministic
|
the default (C) skeleton, as well as from the C++ skeleton
|
||||||
parsers in C produced by Bison cannot grow when compiled
|
(@pxref{C++ Parsers}). However, if you do use the default skeleton
|
||||||
by C++ compilers. In this precise case (compiling a C parser as C++) you are
|
and want to allow the parsing stack to grow,
|
||||||
suggested to grow @code{YYINITDEPTH}. The Bison maintainers hope to fix
|
be careful not to use semantic types or location types that require
|
||||||
this deficiency in a future release.
|
non-trivial copy constructors.
|
||||||
|
The C skeleton bypasses these constructors when copying data to
|
||||||
|
new, larger stacks.
|
||||||
|
|
||||||
@node Error Recovery
|
@node Error Recovery
|
||||||
@chapter Error Recovery
|
@chapter Error Recovery
|
||||||
|
|||||||
Reference in New Issue
Block a user