]> git.saurik.com Git - bison.git/commitdiff
As in semantic actions, make @$ in %initial-action, %destructor, and
authorJoel E. Denny <jdenny@ces.clemson.edu>
Sat, 10 Feb 2007 22:28:23 +0000 (22:28 +0000)
committerJoel E. Denny <jdenny@ces.clemson.edu>
Sat, 10 Feb 2007 22:28:23 +0000 (22:28 +0000)
%printer imply %locations.
* src/scan-code.l (SC_SYMBOL_ACTION): Set locations_flag = true when
scanning @$.
* tests/actions.at (AT_CHECK_ACTION_LOCATIONS): New macro supporting...
(@$ in %initial-action implies %locations,
@$ in %destructor implies %locations,
@$ in %printer implies %locations): ... these new test cases.

ChangeLog
src/scan-code.l
tests/actions.at

index 1adcebcd601bb0dde1663e7b660c9166a2c05660..a4be8fdddb9c8535a23af6a5d2f3da5295d34d7f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-02-10  Joel E. Denny  <jdenny@ces.clemson.edu>
+
+       As in semantic actions, make @$ in %initial-action, %destructor, and
+       %printer imply %locations.
+       * src/scan-code.l (SC_SYMBOL_ACTION): Set locations_flag = true when
+       scanning @$.
+       * tests/actions.at (AT_CHECK_ACTION_LOCATIONS): New macro supporting...
+       (@$ in %initial-action implies %locations,
+       @$ in %destructor implies %locations,
+       @$ in %printer implies %locations): ... these new test cases.
+
 2007-02-07  Paul Eggert  <eggert@cs.ucla.edu>
 
        Undo most of the 2007-02-03 change, switching to the strcase module
index b54f4c9a2d1fbc8109eaf45dc2415221ab86208d..9e51401394fd2f8c32644d03c6832fd84437a4d8 100644 (file)
@@ -202,7 +202,10 @@ splice      (\\[ \f\t\v]*\n)*
     obstack_sgrow (&obstack_for_string, "]b4_dollar_dollar[");
     self->is_value_used = true;
   }
-  "@$"   obstack_sgrow (&obstack_for_string, "]b4_at_dollar[");
+  "@$" {
+    obstack_sgrow (&obstack_for_string, "]b4_at_dollar[");
+    locations_flag = true;
+  }
 }
 
 
index 43b6f7f6e10959517606ab17cf1aa57c3d9f5858..0e833a396b79e9a7404faee5a5051fd40d6add9d 100644 (file)
@@ -1247,3 +1247,62 @@ Stack now 0
 ]])
 
 AT_CLEANUP
+
+
+## ----------------------- ##
+## @$ implies %locations.  ##
+## ----------------------- ##
+
+# Bison once forgot to check for @$ in actions other than semantic actions.
+
+# AT_CHECK_ACTION_LOCATIONS(ACTION-DIRECTIVE)
+# -------------------------------------------------------
+m4_define([AT_CHECK_ACTION_LOCATIONS],
+[AT_SETUP([[@$ in ]$1[ implies %locations]])
+
+AT_DATA_GRAMMAR([[input.y]],
+[[%code {
+  #include <stdio.h>
+  static int yylex (void);
+  static void yyerror (char const *msg);
+}
+
+%debug
+
+]$1[ {
+  printf ("%d\n", @$.first_line);
+} ]m4_if($1, [%initial-action], [], [[start]])[
+
+%%
+
+start:  ;
+
+%%
+
+static int
+yylex (void)
+{
+  return 0;
+}
+
+static void
+yyerror (char const *msg)
+{
+  fprintf (stderr, "%s\n", msg);
+}
+
+int
+main (void)
+{
+  return yyparse ();
+}
+]])
+
+AT_CHECK([[bison -o input.c input.y]])
+AT_COMPILE([[input]])
+
+AT_CLEANUP])
+
+AT_CHECK_ACTION_LOCATIONS([[%initial-action]])
+AT_CHECK_ACTION_LOCATIONS([[%destructor]])
+AT_CHECK_ACTION_LOCATIONS([[%printer]])