bison-patches
[Top][All Lists]
Advanced

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

Re: more %define front-end support


From: Joel E. Denny
Subject: Re: more %define front-end support
Date: Mon, 28 May 2007 23:06:37 -0400 (EDT)

On Sun, 20 May 2007, Joel E. Denny wrote:

> I committed the following.  I'm using it in my LR(1) work, and I believe 
> it'll prove useful in general.

Here's some more.  Committed.

Index: ChangeLog
===================================================================
RCS file: /sources/bison/bison/ChangeLog,v
retrieving revision 1.1704
diff -p -u -r1.1704 ChangeLog
--- ChangeLog   28 May 2007 04:14:18 -0000      1.1704
+++ ChangeLog   29 May 2007 02:58:06 -0000
@@ -1,3 +1,11 @@
+2007-05-29  Joel E. Denny  <address@hidden>
+
+       * src/muscle_tab.c (muscle_percent_define_invalid_value): Replace
+       with...
+       (muscle_percent_define_check_values): ... this more helpful function.
+       Again, it's not used yet, but it will be.
+       * src/muscle_tab.h: Likewise.
+
 2007-05-28  Joel E. Denny  <address@hidden>
 
        * src/lalr.c (state_lookahead_tokens_count): For code readability,
Index: src/muscle_tab.c
===================================================================
RCS file: /sources/bison/bison/src/muscle_tab.c,v
retrieving revision 1.48
diff -p -u -r1.48 muscle_tab.c
--- src/muscle_tab.c    20 May 2007 05:01:53 -0000      1.48
+++ src/muscle_tab.c    29 May 2007 02:58:06 -0000
@@ -507,15 +507,44 @@ muscle_percent_define_default (char cons
 }
 
 void
-muscle_percent_define_invalid_value (char const *variable)
+muscle_percent_define_check_values (char const * const *values)
 {
-  char const *loc_name;
-  MUSCLE_USER_NAME_CONVERT (loc_name, "percent_define_loc(", variable, ")");
-  complain_at(muscle_location_decode (loc_name),
-              _("invalid value for %%define variable `%s'"), variable);
+  for (; *values; ++values)
+    {
+      char const *variable = *values;
+      char const *name;
+      char const *loc_name;
+      char *value;
+
+      MUSCLE_USER_NAME_CONVERT (name, "percent_define(", variable, ")");
+      MUSCLE_USER_NAME_CONVERT (loc_name, "percent_define_loc(", variable, 
")");
+
+      value = muscle_string_decode (name);
+      if (value)
+        {
+          bool valid = false;
+          for (++values; *values; ++values)
+            {
+              if (0 == strcmp (value, *values))
+                {
+                  valid = true;
+                  while (*values)
+                    ++values;
+                  break;
+                }
+            }
+          if (!valid)
+            complain_at(muscle_location_decode (loc_name),
+                        _("invalid value for %%define variable `%s': `%s'"),
+                        variable, value);
+          free (value);
+        }
+      else
+        fatal(_("undefined %%define variable `%s' passed to 
muscle_percent_define_check_values"),
+              variable);
+    }
 }
 
-
 void
 muscle_percent_code_grow (char const *qualifier, location qualifier_loc,
                           char const *code, location code_loc)
Index: src/muscle_tab.h
===================================================================
RCS file: /sources/bison/bison/src/muscle_tab.h,v
retrieving revision 1.26
diff -p -u -r1.26 muscle_tab.h
--- src/muscle_tab.h    20 May 2007 05:01:53 -0000      1.26
+++ src/muscle_tab.h    29 May 2007 02:58:06 -0000
@@ -158,9 +158,16 @@ bool muscle_percent_define_flag_if (char
    suspect that the value has yet influenced the output.  */
 void muscle_percent_define_default (char const *variable, char const *value);
 
-/* Complain that the value set for the %define variable VARIABLE is
-   invalid.  */
-void muscle_percent_define_invalid_value (char const *variable);
+/* VALUES points to a sequence of strings that is partitioned into
+   subsequences by NULL's, one terminating each subsequence.  The last
+   subsequence is followed by a second NULL.  For each subsequence, the first
+   string is the name of a %define variable, and all remaining strings in that
+   subsequence are the valid values for that variable.  Complain if such a
+   variable is undefined (a Bison error since the default value should have
+   been set already) or defined to any other value (possibly a user error).
+   Don't record this as a Bison usage of the variable as there's no reason to
+   suspect that the value has yet influenced the output.  */
+void muscle_percent_define_check_values (char const * const *values);
 
 /* Grow the muscle for the %code qualifier QUALIFIER appearing at QUALIFIER_LOC
    in the grammar file with code CODE appearing at CODE_LOC.  Record this as a




reply via email to

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