mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-22 10:43:02 +00:00
(<SC_BRACED_CODE>"}"): Append ";" before the last brace in braced code
when not in Yacc mode, for compatibility with Bison 1.35. This resurrects the 2001-12-15 patch to src/reader.c.
This commit is contained in:
@@ -542,9 +542,28 @@ splice (\\[ \f\t\v]*\n)*
|
|||||||
"{"|"<"{splice}"%" STRING_GROW; braces_level++;
|
"{"|"<"{splice}"%" STRING_GROW; braces_level++;
|
||||||
"%"{splice}">" STRING_GROW; braces_level--;
|
"%"{splice}">" STRING_GROW; braces_level--;
|
||||||
"}" {
|
"}" {
|
||||||
STRING_GROW;
|
bool outer_brace = --braces_level < 0;
|
||||||
braces_level--;
|
|
||||||
if (braces_level < 0)
|
/* As an undocumented Bison extension, append `;' before the last
|
||||||
|
brace in braced code, so that the user code can omit trailing
|
||||||
|
`;'. But do not append `;' if emulating Yacc, since Yacc does
|
||||||
|
not append one.
|
||||||
|
|
||||||
|
FIXME: Bison should warn if a semicolon seems to be necessary
|
||||||
|
here, and should omit the semicolon if it seems unnecessary
|
||||||
|
(e.g., after ';', '{', or '}', each followed by comments or
|
||||||
|
white space). Such a warning shouldn't depend on --yacc; it
|
||||||
|
should depend on a new --pedantic option, which would cause
|
||||||
|
Bison to warn if it detects an extension to POSIX. --pedantic
|
||||||
|
should also diagnose other Bison extensions like %yacc.
|
||||||
|
Perhaps there should also be a GCC-style --pedantic-errors
|
||||||
|
option, so that such warnings are diagnosed as errors. */
|
||||||
|
if (outer_brace && ! yacc_flag)
|
||||||
|
obstack_1grow (&obstack_for_string, ';');
|
||||||
|
|
||||||
|
obstack_1grow (&obstack_for_string, '}');
|
||||||
|
|
||||||
|
if (outer_brace)
|
||||||
{
|
{
|
||||||
STRING_FINISH;
|
STRING_FINISH;
|
||||||
rule_length++;
|
rule_length++;
|
||||||
|
|||||||
Reference in New Issue
Block a user