bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] parser: handle %locations as %define locations.


From: Akim Demaille
Subject: [PATCH] parser: handle %locations as %define locations.
Date: Sun, 5 Apr 2009 22:05:08 +0200

        * src/getargs.h, src/getargs.c (locations_flag): Remove.
        * src/getargs.c, src/scan-code.l: Use muscle_percent_define_ensure
        to set "locations" to true.
        * src/output.c (prepare): Don't output "locations".
        * src/scan-gram.l (%locations): Handle it as a %<flag>.
        * src/parse-gram.y: It's no longer a token.
        Don't handle it.
        * data/bison.m4 (b4_locations_if): Define it with
        b4_percent_define_if_define.
        * data/c.m4, data/glr.cc: Adjust.
---
 ChangeLog        |   14 ++++++++++++++
 data/bison.m4    |    2 +-
 data/c.m4        |    2 +-
 data/glr.cc      |    4 ++--
 src/getargs.c    |    4 ++--
 src/getargs.h    |    1 -
 src/output.c     |    1 -
 src/parse-gram.y |    2 --
 src/scan-code.l  |   10 +++++-----
 src/scan-gram.l  |    2 +-
 10 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 80aea8b..427b62d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2009-04-06  Akim Demaille  <address@hidden>
 
+       parser: handle %locations as %define locations.
+       * src/getargs.h, src/getargs.c (locations_flag): Remove.
+       * src/getargs.c, src/scan-code.l: Use muscle_percent_define_ensure
+       to set "locations" to true.
+       * src/output.c (prepare): Don't output "locations".
+       * src/scan-gram.l (%locations): Handle it as a %<flag>.
+       * src/parse-gram.y: It's no longer a token.
+       Don't handle it.
+       * data/bison.m4 (b4_locations_if): Define it with
+       b4_percent_define_if_define.
+       * data/c.m4, data/glr.cc: Adjust.
+
+2009-04-06  Akim Demaille  <address@hidden>
+
        Regen.
        * src/parse-gram.c: Regen.
 
diff --git a/data/bison.m4 b/data/bison.m4
index fa8b043..89918ac 100644
--- a/data/bison.m4
+++ b/data/bison.m4
@@ -333,7 +333,6 @@ m4_define([b4_$3_if],
 # Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise.
 b4_define_flag_if([defines])           # Whether headers are requested.
 b4_define_flag_if([glr])               # Whether a GLR parser is requested.
-b4_define_flag_if([locations])         # Whether locations are tracked.
 b4_define_flag_if([nondeterministic])  # Whether conflicts should be handled.
 b4_define_flag_if([yacc])              # Whether POSIX Yacc is emulated.
 
@@ -687,6 +686,7 @@ b4_percent_define_if_define([assert])
 b4_percent_define_if_define([debug])
 b4_percent_define_if_define([error_verbose])
 b4_percent_define_if_define([lex_symbol])
+b4_percent_define_if_define([locations])     # Whether locations are tracked.
 b4_percent_define_if_define([variant])
 
 
diff --git a/data/c.m4 b/data/c.m4
index ffa4a84..5df04cb 100644
--- a/data/c.m4
+++ b/data/c.m4
@@ -75,7 +75,7 @@ m4_define([b4_identification],
 #define YYPULL ]b4_pull_flag])[
 
 /* Using locations.  */
-#define YYLSP_NEEDED ]b4_locations_flag[
+#define YYLSP_NEEDED ]b4_locations_if([1], [0])[
 ]])
 
 
diff --git a/data/glr.cc b/data/glr.cc
index 2d9fc4c..0b4000a 100644
--- a/data/glr.cc
+++ b/data/glr.cc
@@ -44,7 +44,7 @@
 #   filename member).
 
 # We require a pure interface using locations.
-m4_define([b4_locations_flag], [1])
+m4_define([b4_percent_define(locations)], [])
 m4_define([b4_pure_flag],      [1])
 
 # The header is mandatory.
@@ -228,7 +228,7 @@ b4_copyright([Skeleton interface for Bison GLR parsers in 
C++],
 #include <iostream>
 
 /* Using locations.  */
-#define YYLSP_NEEDED ]b4_locations_flag[
+#define YYLSP_NEEDED ]b4_locations_if([1], [0])[
 
 ]b4_namespace_open[
   class position;
diff --git a/src/getargs.c b/src/getargs.c
index 7a67878..d7e4385 100644
--- a/src/getargs.c
+++ b/src/getargs.c
@@ -50,7 +50,6 @@
 bool defines_flag;
 bool graph_flag;
 bool xml_flag;
-bool locations_flag;
 bool no_lines_flag;
 bool token_table_flag;
 bool yacc_flag;        /* for -y */
@@ -635,7 +634,8 @@ getargs (int argc, char *argv[])
        break;
 
       case LOCATIONS_OPTION:
-       locations_flag = true;
+        muscle_percent_define_ensure ("locations",
+                                      command_line_location (), true);
        break;
 
       case PRINT_LOCALEDIR_OPTION:
diff --git a/src/getargs.h b/src/getargs.h
index c85cb5f..13efae2 100644
--- a/src/getargs.h
+++ b/src/getargs.h
@@ -38,7 +38,6 @@ extern char const *include;
 extern bool defines_flag;              /* for -d */
 extern bool graph_flag;                        /* for -g */
 extern bool xml_flag;                  /* for -x */
-extern bool locations_flag;
 extern bool no_lines_flag;             /* for -l */
 extern bool token_table_flag;          /* for -k */
 extern bool yacc_flag;                 /* for -y */
diff --git a/src/output.c b/src/output.c
index a06698c..9da543a 100644
--- a/src/output.c
+++ b/src/output.c
@@ -702,7 +702,6 @@ prepare (void)
   /* Flags. */
   MUSCLE_INSERT_BOOL ("defines_flag", defines_flag);
   MUSCLE_INSERT_BOOL ("glr_flag", glr_parser);
-  MUSCLE_INSERT_BOOL ("locations_flag", locations_flag);
   MUSCLE_INSERT_BOOL ("nondeterministic_flag", nondeterministic_parser);
   MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag);
   MUSCLE_INSERT_BOOL ("tag_seen_flag", tag_seen);
diff --git a/src/parse-gram.y b/src/parse-gram.y
index 7277105..e45f4bc 100644
--- a/src/parse-gram.y
+++ b/src/parse-gram.y
@@ -139,7 +139,6 @@ static int current_prec = 0;
   PERCENT_INITIAL_ACTION  "%initial-action"
   PERCENT_LANGUAGE        "%language"
   PERCENT_LEX_PARAM       "%lex-param"
-  PERCENT_LOCATIONS       "%locations"
   PERCENT_NAME_PREFIX     "%name-prefix"
   PERCENT_NO_DEFAULT_PREC "%no-default-prec"
   PERCENT_NO_LINES        "%no-lines"
@@ -258,7 +257,6 @@ prologue_declaration:
     }
 | "%language" STRING           { language_argmatch ($2, grammar_prio, @1); }
 | "%lex-param" "{...}"         { add_param ("lex_param", $2, @2); }
-| "%locations"                  { locations_flag = true; }
 | "%name-prefix" STRING         { spec_name_prefix = $2; }
 | "%name-prefix" "=" STRING     { spec_name_prefix = $3; } /* deprecated */
 | "%no-lines"                   { no_lines_flag = true; }
diff --git a/src/scan-code.l b/src/scan-code.l
index 7a655fb..913116f 100644
--- a/src/scan-code.l
+++ b/src/scan-code.l
@@ -1,6 +1,6 @@
 /* Bison Action Scanner                             -*- C -*-
 
-   Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 
    This file is part of Bison, the GNU Compiler Compiler.
 
@@ -34,7 +34,7 @@
 #include <src/getargs.h>
 #include <get-errno.h>
 #include <quote.h>
-
+#include <src/muscle_tab.h>
 #include <src/scan-code.h>
 #include <src/symlist.h>
 
@@ -223,7 +223,7 @@ splice       (\\[ \f\t\v]*\n)*
   "#"       STRING_GROW; in_cpp = true;
 
   {splice}  STRING_GROW;
-  [\n\r]    STRING_GROW; if (in_cpp) in_cpp = need_semicolon = false; 
+  [\n\r]    STRING_GROW; if (in_cpp) in_cpp = need_semicolon = false;
   [ \t\f]   STRING_GROW;
   .         STRING_GROW; need_semicolon = true;
 }
@@ -236,7 +236,7 @@ splice       (\\[ \f\t\v]*\n)*
   }
   "@$" {
     obstack_sgrow (&obstack_for_string, "]b4_at_dollar[");
-    locations_flag = true;
+    muscle_percent_define_ensure("locations", the_location, true);
   }
 }
 
@@ -391,7 +391,7 @@ handle_action_at (symbol_list *rule, char *text, location 
at_loc)
      ? rule->midrule_parent_rhs_index - 1
      : symbol_list_length (rule->next));
 
-  locations_flag = true;
+  muscle_percent_define_ensure("locations", at_loc, true);
 
   if (*cp == '$')
     obstack_sgrow (&obstack_for_string, "]b4_lhs_location[");
diff --git a/src/scan-gram.l b/src/scan-gram.l
index 8b5027c..fd600bd 100644
--- a/src/scan-gram.l
+++ b/src/scan-gram.l
@@ -191,7 +191,7 @@ splice       (\\[ \f\t\v]*\n)*
   "%language"                       return PERCENT_LANGUAGE;
   "%left"                           return PERCENT_LEFT;
   "%lex-param"                      return PERCENT_LEX_PARAM;
-  "%locations"                      return PERCENT_LOCATIONS;
+  "%locations"                      RETURN_PERCENT_FLAG("locations");
   "%merge"                          return PERCENT_MERGE;
   "%name"[-_]"prefix"               return PERCENT_NAME_PREFIX;
   "%no"[-_]"default"[-_]"prec"      return PERCENT_NO_DEFAULT_PREC;
-- 
1.6.2.1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]