[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
10-fyi-ritem-loops.patch
From: |
Akim Demaille |
Subject: |
10-fyi-ritem-loops.patch |
Date: |
Sun, 07 Apr 2002 17:23:35 +0200 |
Index: ChangeLog
from Akim Demaille <address@hidden>
* src/LR0.c (allocate_itemsets): Don't loop over ritem: loop over
the RHS of the rules.
* src/output.c (output_gram): Likewise.
Index: src/LR0.c
--- src/LR0.c Fri, 01 Mar 2002 15:24:29 +0100 akim
+++ src/LR0.c Sat, 30 Mar 2002 00:04:16 +0100 akim
@@ -68,7 +68,8 @@
static void
allocate_itemsets (void)
{
- int i;
+ int i, r;
+ short *rhsp;
/* Count the number of occurrences of all the symbols in RITEMS.
Note that useless productions (hence useless nonterminals) are
@@ -77,11 +78,11 @@
int count = 0;
short *symbol_count = XCALLOC (short, nsyms + nuseless_nonterminals);
- for (i = 0; i < nritems; ++i)
- if (ritem[i] >= 0)
+ for (r = 1; r < nrules + 1; ++r)
+ for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
{
count++;
- symbol_count[ritem[i]]++;
+ symbol_count[*rhsp]++;
}
/* See comments before new_itemsets. All the vectors of items
Index: src/output.c
--- src/output.c Mon, 25 Mar 2002 21:34:54 +0100 akim
+++ src/output.c Sat, 30 Mar 2002 00:04:35 +0100 akim
@@ -202,14 +202,18 @@
muscle_insert ("prhs", obstack_finish (&format_obstack));
{
- short *yyrhs;
- int i;
-
- yyrhs = XMALLOC (short, nritems);
-
- for (i = 1; i < nritems; ++i)
- yyrhs[i] = ritem[i] >= 0 ? ritem[i] : -1;
+ short *rhsp;
+ int r;
+ int i = 0;
+ short *yyrhs = XMALLOC (short, nritems);
+ for (r = 1; r < nrules + 1; ++r)
+ {
+ for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
+ yyrhs[i++] = *rhsp;
+ yyrhs[i++] = -1;
+ }
+ assert (i == nritems);
output_table_data (&format_obstack, yyrhs,
ritem[0], 1, nritems);
muscle_insert ("rhs", obstack_finish (&format_obstack));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- 10-fyi-ritem-loops.patch,
Akim Demaille <=