bison-patches
[Top][All Lists]
Advanced

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

[RFA] muscle changes for Java support


From: Paolo Bonzini
Subject: [RFA] muscle changes for Java support
Date: Tue, 12 Sep 2006 11:13:53 +0200
User-agent: Thunderbird 1.5.0.5 (Macintosh/20060719)

This patch, which I'd ask you to apply as uncopyrightable (7 changed lines in output.c, 8 new lines in c.m4), changes slightly the output so that different skeletons may cope with the differences between C/C++ and Java. I don't know how close Bison is to the next release, but if it's not particularly close, I think the patch is worthwhile on its own.

In particular, it replaces the final "0" in the token name arrays with b4_null, and defines a new macro b4_case to be used in the switch statement for actions. The latter is needed because Java has a braindead unreachable code detection which we need to fool^Wcope with.

Tested with no regressions.

Paolo
2006-09-12  Paolo Bonzini  <address@hidden>

        * data/c.m4 (b4_null, b4_case): Define.
        * src/output.c (prepare_symbols): Use b4_null.
        (user_actions_output): Use b4_case.

Index: data/c.m4
===================================================================
RCS file: /sources/bison/bison/data/c.m4,v
retrieving revision 1.64
diff -u -p -r1.64 c.m4
--- data/c.m4   11 Aug 2006 19:50:14 -0000      1.64
+++ data/c.m4   12 Sep 2006 08:15:27 -0000
@@ -172,6 +172,7 @@ m4_define([b4_int_type],
 m4_define([b4_int_type_for],
 [b4_int_type($1_min, $1_max)])
 
+m4_define([b4_null], [0])
 
 ## ------------------ ##
 ## Decoding options.  ##
@@ -458,6 +459,13 @@ b4_define_user_code([stype])
 ## User actions.  ##
 ## -------------- ##
 
+# b4_case(ID, CODE)
+# -----------------
+m4_define([b4_case], [  case $1:
+$2;
+    break;
+    ])
+
 # b4_symbol_actions(FILENAME, LINENO,
 #                   SYMBOL-TAG, SYMBOL-NUM,
 #                   SYMBOL-ACTION, SYMBOL-TYPENAME)
Index: src/output.c
===================================================================
RCS file: /sources/bison/bison/src/output.c,v
retrieving revision 1.252
diff -u -p -r1.252 output.c
--- src/output.c        29 Jul 2006 05:53:41 -0000      1.252
+++ src/output.c        12 Sep 2006 08:15:26 -0000
@@ -178,7 +178,7 @@ prepare_symbols (void)
       }
     /* Add a NULL entry to list of tokens (well, 0, as NULL might not be
        defined).  */
-    obstack_sgrow (&format_obstack, " 0");
+    obstack_sgrow (&format_obstack, " ]b4_null[");
 
     /* Finish table and store. */
     obstack_1grow (&format_obstack, 0);
@@ -290,20 +290,19 @@ user_actions_output (FILE *out)
 {
   rule_number r;
 
-  fputs ("m4_define([b4_actions], \n[[", out);
+  fputs ("m4_define([b4_actions], \n[\n", out);
   for (r = 0; r < nrules; ++r)
     if (rules[r].action)
       {
-       fprintf (out, "  case %d:\n", r + 1);
+       fprintf (out, "b4_case([%d], ", r + 1);
 
-       fprintf (out, "]b4_syncline(%d, ",
+       fprintf (out, "[b4_syncline(%d, ",
                 rules[r].action_location.start.line);
        escaped_output (out, rules[r].action_location.start.file);
-       fprintf (out, ")[\n");
-       fprintf (out, "    %s\n    break;\n\n",
-                rules[r].action);
+       fprintf (out, ")\n");
+       fprintf (out, "    [%s]])\n\n", rules[r].action);
       }
-  fputs ("]])\n\n", out);
+  fputs ("])\n\n", out);
 }
 
 /*--------------------------------------.

reply via email to

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