* src/scan-gram.l: Move the "add a trailing ; to actions" code

to...
* src/scan-code.l: here.
* tests/input.at (Torturing the Scanner): Fix another location
error.
This commit is contained in:
Akim Demaille
2006-06-07 07:09:32 +00:00
parent 4862bdfd61
commit 2346344a08
4 changed files with 39 additions and 22 deletions

View File

@@ -75,6 +75,9 @@ splice (\\[ \f\t\v]*\n)*
%%
%{
/* Nesting level of the current code in braces. */
int braces_level IF_LINT (= 0);
/* This scanner is special: it is invoked only once, henceforth
is expected to return only once. This initialization is
therefore done once per action to translate. */
@@ -157,6 +160,30 @@ splice (\\[ \f\t\v]*\n)*
warn_at (*loc, _("stray `@'"));
obstack_sgrow (&obstack_for_string, "@@");
}
"{" STRING_GROW; ++braces_level;
"}" {
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, ';');
STRING_GROW;
}
}
<SC_SYMBOL_ACTION>