[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
append-semicolon-to-action backward compatibility patch
From: |
Paul Eggert |
Subject: |
append-semicolon-to-action backward compatibility patch |
Date: |
Mon, 30 Dec 2002 14:50:11 -0800 |
I installed this backward-compatibility patch. This fixes the last
remaining compatibility issue that I know of, for CVS Bison compared
to Bison 1.35.
2002-12-30 Paul Eggert <address@hidden>
* src/scan-gram.l (<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.
Index: scan-gram.l
===================================================================
RCS file: /cvsroot/bison/bison/src/scan-gram.l,v
retrieving revision 1.51
retrieving revision 1.52
diff -p -u -r1.51 -r1.52
--- scan-gram.l 24 Dec 2002 07:46:49 -0000 1.51
+++ scan-gram.l 30 Dec 2002 22:40:52 -0000 1.52
@@ -542,9 +542,28 @@ splice (\\[ \f\t\v]*\n)*
"{"|"<"{splice}"%" STRING_GROW; braces_level++;
"%"{splice}">" STRING_GROW; braces_level--;
"}" {
- STRING_GROW;
- braces_level--;
- if (braces_level < 0)
+ bool outer_brace = --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;
rule_length++;
- append-semicolon-to-action backward compatibility patch,
Paul Eggert <=