bison-patches
[Top][All Lists]
Advanced

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

Re: too many gotos


From: Akim Demaille
Subject: Re: too many gotos
Date: Fri, 22 Oct 2004 10:56:01 +0200
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Hi!

Does this patch fix your problems?  What is the license of the grammar
you work on?  If GPL, would it be possible to include it in our test
suite?

Unless someone knows a means to generate a grammar with arbitrarily
many gotos.  That would allow us to test the output.

Index: src/lalr.h
===================================================================
RCS file: /cvsroot/bison/bison/src/lalr.h,v
retrieving revision 1.28
diff -u -u -r1.28 lalr.h
--- src/lalr.h 21 Jun 2004 20:20:31 -0000 1.28
+++ src/lalr.h 22 Oct 2004 08:56:03 -0000
@@ -56,7 +56,7 @@
    together and GOTO_MAP[I - NTOKENS] is the index in FROM_STATE and
    TO_STATE of the first of them.  */
 
-typedef short int goto_number;
+typedef unsigned int goto_number;
 # define GOTO_NUMBER_MAXIMUM SHRT_MAX
 
 extern goto_number *goto_map;
Index: src/relation.c
===================================================================
RCS file: /cvsroot/bison/bison/src/relation.c,v
retrieving revision 1.7
diff -u -u -r1.7 relation.c
--- src/relation.c 31 Mar 2004 00:37:21 -0000 1.7
+++ src/relation.c 22 Oct 2004 08:56:03 -0000
@@ -35,7 +35,7 @@
     {
       fprintf (out, "%3d: ", i);
       if (r[i])
-       for (j = 0; r[i][j] != -1; ++j)
+       for (j = 0; r[i][j] != END_NODE; ++j)
          fprintf (out, "%3d ", r[i][j]);
       fputc ('\n', out);
     }
@@ -67,7 +67,7 @@
   INDEX[i] = height = top;
 
   if (R[i])
-    for (j = 0; R[i][j] >= 0; ++j)
+    for (j = 0; R[i][j] != END_NODE; ++j)
       {
        if (INDEX[R[i][j]] == 0)
          traverse (R[i][j]);
@@ -143,7 +143,7 @@
   /* Count. */
   for (i = 0; i < n; i++)
     if ((*R_arg)[i])
-      for (j = 0; (*R_arg)[i][j] >= 0; ++j)
+      for (j = 0; (*R_arg)[i][j] != END_NODE; ++j)
        ++nedges[(*R_arg)[i][j]];
 
   /* Allocate. */
@@ -151,7 +151,7 @@
     if (nedges[i] > 0)
       {
        relation_node *sp = CALLOC (sp, nedges[i] + 1);
-       sp[nedges[i]] = -1;
+       sp[nedges[i]] = END_NODE;
        new_R[i] = sp;
        end_R[i] = sp;
       }
@@ -159,7 +159,7 @@
   /* Store. */
   for (i = 0; i < n; i++)
     if ((*R_arg)[i])
-      for (j = 0; (*R_arg)[i][j] >= 0; ++j)
+      for (j = 0; (*R_arg)[i][j] != END_NODE; ++j)
        {
          *end_R[(*R_arg)[i][j]] = i;
          ++end_R[(*R_arg)[i][j]];
Index: src/relation.h
===================================================================
RCS file: /cvsroot/bison/bison/src/relation.h,v
retrieving revision 1.4
diff -u -u -r1.4 relation.h
--- src/relation.h 31 Mar 2004 00:37:21 -0000 1.4
+++ src/relation.h 22 Oct 2004 08:56:03 -0000
@@ -25,9 +25,11 @@
 /* Performing operations on graphs coded as list of adjacency.
 
    If GRAPH is a relation, then GRAPH[Node] is a list of adjacent
-   nodes, ended with -1.  */
+   nodes, ended with END_NODE.  */
 
-typedef short int relation_node;
+#define END_NODE ((relation_node) -1)
+
+typedef unsigned int relation_node;
 typedef relation_node *relation_nodes;
 typedef relation_nodes *relation;
 




reply via email to

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