* src/LR0.c (new_itemsets): Use nshifts only, not shiftcount.

* src/closure.c, src/closure.h (itemsetsize): Rename as...
(nitemset): for consistency with the rest of the project.
This commit is contained in:
Akim Demaille
2001-12-05 09:23:52 +00:00
parent 66d35de779
commit b6a70d99a6
4 changed files with 31 additions and 26 deletions

View File

@@ -1,3 +1,10 @@
2001-12-05 Akim Demaille <akim@epita.fr>
* src/LR0.c (new_itemsets): Use nshifts only, not shiftcount.
* src/closure.c, src/closure.h (itemsetsize): Rename as...
(nitemset): for consistency with the rest of the project.
2001-12-05 Akim Demaille <akim@epita.fr> 2001-12-05 Akim Demaille <akim@epita.fr>
* src/closure.c (print_closure): Improve. * src/closure.c (print_closure): Improve.

View File

@@ -141,7 +141,6 @@ static void
new_itemsets (void) new_itemsets (void)
{ {
int i; int i;
int shiftcount;
if (trace_flag) if (trace_flag)
fprintf (stderr, "Entering new_itemsets, state = %d\n", fprintf (stderr, "Entering new_itemsets, state = %d\n",
@@ -151,25 +150,23 @@ new_itemsets (void)
kernel_size[i] = 0; kernel_size[i] = 0;
shift_symbol = XCALLOC (short, nsyms); shift_symbol = XCALLOC (short, nsyms);
shiftcount = 0; nshifts = 0;
for (i = 0; i < itemsetsize; ++i) for (i = 0; i < nitemset; ++i)
{ {
int symbol = ritem[itemset[i]]; int symbol = ritem[itemset[i]];
if (symbol > 0) if (symbol > 0)
{ {
if (!kernel_size[symbol]) if (!kernel_size[symbol])
{ {
shift_symbol[shiftcount] = symbol; shift_symbol[nshifts] = symbol;
shiftcount++; nshifts++;
} }
kernel_base[symbol][kernel_size[symbol]] = itemset[i] + 1; kernel_base[symbol][kernel_size[symbol]] = itemset[i] + 1;
kernel_size[symbol]++; kernel_size[symbol]++;
} }
} }
nshifts = shiftcount;
} }
@@ -542,7 +539,7 @@ save_reductions (void)
/* Find and count the active items that represent ends of rules. */ /* Find and count the active items that represent ends of rules. */
count = 0; count = 0;
for (i = 0; i < itemsetsize; ++i) for (i = 0; i < nitemset; ++i)
{ {
int item = ritem[itemset[i]]; int item = ritem[itemset[i]];
if (item < 0) if (item < 0)

View File

@@ -26,9 +26,9 @@
#include "derives.h" #include "derives.h"
#include "warshall.h" #include "warshall.h"
/* ITEMSETSIZE is the size of the array ITEMSET. */ /* NITEMSET is the size of the array ITEMSET. */
short *itemset; short *itemset;
int itemsetsize; int nitemset;
static unsigned *ruleset; static unsigned *ruleset;
@@ -218,7 +218,7 @@ closure (short *core, int n)
ruleset[r] |= FDERIVES (ritem[core[c]])[r]; ruleset[r] |= FDERIVES (ritem[core[c]])[r];
} }
itemsetsize = 0; nitemset = 0;
c = 0; c = 0;
for (ruleno = 0; ruleno < rulesetsize * BITS_PER_WORD; ++ruleno) for (ruleno = 0; ruleno < rulesetsize * BITS_PER_WORD; ++ruleno)
if (BITISSET (ruleset, ruleno)) if (BITISSET (ruleset, ruleno))
@@ -226,23 +226,23 @@ closure (short *core, int n)
int itemno = rule_table[ruleno].rhs; int itemno = rule_table[ruleno].rhs;
while (c < n && core[c] < itemno) while (c < n && core[c] < itemno)
{ {
itemset[itemsetsize] = core[c]; itemset[nitemset] = core[c];
itemsetsize++; nitemset++;
c++; c++;
} }
itemset[itemsetsize] = itemno; itemset[nitemset] = itemno;
itemsetsize++; nitemset++;
} }
while (c < n) while (c < n)
{ {
itemset[itemsetsize] = core[c]; itemset[nitemset] = core[c];
itemsetsize++; nitemset++;
c++; c++;
} }
if (trace_flag) if (trace_flag)
print_closure ("output", itemset, itemsetsize); print_closure ("output", itemset, nitemset);
} }

View File

@@ -30,18 +30,19 @@
void new_closure PARAMS ((int n)); void new_closure PARAMS ((int n));
/* Given a vector of item numbers ITEMS, of length N, set up ruleset /* Given the kernel (aka core) of a state (a vector of item numbers
and itemset to indicate what rules could be run and which items ITEMS, of length N), set up ruleset and itemset to indicate what
could be accepted when those items are the active ones. rules could be run and which items could be accepted when those
items are the active ones.
ruleset contains a bit for each rule. closure sets the bits for ruleset contains a bit for each rule. closure sets the bits for
all rules which could potentially describe the next input to be all rules which could potentially describe the next input to be
read. read.
itemset is a vector of item numbers; itemsetend points to just ITEMSET is a vector of item numbers; NITEMSET is its size
beyond the end of the part of it that is significant. closure 9actually, points to just beyond the end of the part of it that is
places there the indices of all items which represent units of significant). closure places there the indices of all items which
input that could arrive next. */ represent units of input that could arrive next. */
void closure PARAMS ((short *items, int n)); void closure PARAMS ((short *items, int n));
@@ -51,6 +52,6 @@ void closure PARAMS ((short *items, int n));
void free_closure PARAMS ((void)); void free_closure PARAMS ((void));
extern short *itemset; extern short *itemset;
extern int itemsetsize; extern int nitemset;
#endif /* !CLOSURE_H_ */ #endif /* !CLOSURE_H_ */