to...
* src/scan-code.l: here.
* tests/input.at (Torturing the Scanner): Fix another location
error.
+2006-06-07  Akim Demaille  <akim@epita.fr>
+
+       * 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.
+
 2006-06-07  Akim Demaille  <akim@epita.fr>
 
        * src/Makefile.am (BUILT_SOURCES): Fix the trailing backslash.
 
 %%
 
 %{
+  /* 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. */
     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>
 
 #include "scan-gram.h"
 
 #define YY_DECL GRAM_LEX_DECL
-   
+
 #define YY_USER_INIT                                   \
    code_start = scanner_cursor = loc->start;           \
 
   "{"|"<"{splice}"%"  STRING_GROW; braces_level++;
   "%"{splice}">"      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 && token_type == BRACED_CODE && ! yacc_flag)
-      obstack_1grow (&obstack_for_string, ';');
-
     obstack_1grow (&obstack_for_string, '}');
 
-    if (outer_brace)
+    --braces_level;
+    if (braces_level < 0)
       {
        STRING_FINISH;
        loc->start = code_start;
 
 [{}
 ])
 AT_CHECK([bison input.y], [1], [],
-[[input.y:1.1-2: syntax error, unexpected {...}
+[[input.y:1.0-1: syntax error, unexpected {...}
 ]])