Minor code cleanup in parser table construction.

* src/LR0.c (new_itemsets): Use item_number_is_symbol_number.
(new_itemsets, save_reductions): Update for rename to nitemset.
* src/closure.c (nritemset): Rename to...
(nitemset): ... this since the "r" appears to meaningless and isn't
used in the comments.
(closure): Update for rename.
* src/closure.h (nritemset): Update extern to...
(nitemset): ... this.
* src/lalr.c (LA): Fix a typo in comments.
* src/print.c (print_core): Update for rename to nitemset.
* src/print_graph.c (print_graph): Likewise.
* src/state.h: Fix some typos in header comments.
This commit is contained in:
Joel E. Denny
2007-05-07 02:28:42 +00:00
parent 9b33de72cd
commit b09f4f4851
8 changed files with 35 additions and 20 deletions

View File

@@ -1,3 +1,19 @@
2007-05-06 Joel E. Denny <jdenny@ces.clemson.edu>
Minor code cleanup in parser table construction.
* src/LR0.c (new_itemsets): Use item_number_is_symbol_number.
(new_itemsets, save_reductions): Update for rename to nitemset.
* src/closure.c (nritemset): Rename to...
(nitemset): ... this since the "r" appears to meaningless and isn't
used in the comments.
(closure): Update for rename.
* src/closure.h (nritemset): Update extern to...
(nitemset): ... this.
* src/lalr.c (LA): Fix a typo in comments.
* src/print.c (print_core): Update for rename to nitemset.
* src/print_graph.c (print_graph): Likewise.
* src/state.h: Fix some typos in header comments.
2007-04-04 Paul Eggert <eggert@cs.ucla.edu>
* THANKS: Use ASCII for Sebastien Fricker's name. Bison source

View File

@@ -183,8 +183,8 @@ new_itemsets (state *s)
nshifts = 0;
for (i = 0; i < nritemset; ++i)
if (ritem[itemset[i]] >= 0)
for (i = 0; i < nitemset; ++i)
if (item_number_is_symbol_number (ritem[itemset[i]]))
{
symbol_number sym = item_number_as_symbol_number (ritem[itemset[i]]);
if (!kernel_size[sym])
@@ -272,7 +272,7 @@ save_reductions (state *s)
size_t i;
/* Find and count the active items that represent ends of rules. */
for (i = 0; i < nritemset; ++i)
for (i = 0; i < nitemset; ++i)
{
item_number item = ritem[itemset[i]];
if (item_number_is_rule_number (item))

View File

@@ -37,7 +37,7 @@
/* NITEMSET is the size of the array ITEMSET. */
item_number *itemset;
size_t nritemset;
size_t nitemset;
static bitset ruleset;
@@ -213,30 +213,30 @@ closure (item_number *core, size_t n)
if (ISVAR (ritem[core[c]]))
bitset_or (ruleset, ruleset, FDERIVES (ritem[core[c]]));
nritemset = 0;
nitemset = 0;
c = 0;
BITSET_FOR_EACH (iter, ruleset, ruleno, 0)
{
item_number itemno = rules[ruleno].rhs - ritem;
while (c < n && core[c] < itemno)
{
itemset[nritemset] = core[c];
nritemset++;
itemset[nitemset] = core[c];
nitemset++;
c++;
}
itemset[nritemset] = itemno;
nritemset++;
itemset[nitemset] = itemno;
nitemset++;
};
while (c < n)
{
itemset[nritemset] = core[c];
nritemset++;
itemset[nitemset] = core[c];
nitemset++;
c++;
}
if (trace_flag & trace_sets)
print_closure ("output", itemset, nritemset);
print_closure ("output", itemset, nitemset);
}

View File

@@ -54,6 +54,6 @@ void closure (item_number *items, size_t n);
void free_closure (void);
extern item_number *itemset;
extern size_t nritemset;
extern size_t nitemset;
#endif /* !CLOSURE_H_ */

View File

@@ -56,7 +56,7 @@ typedef struct goto_list
} goto_list;
/* LA is a LR by NTOKENS matrix of bits. LA[l, i] is 1 if the rule
/* LA is an NLA by NTOKENS matrix of bits. LA[l, i] is 1 if the rule
LArule[l] is applicable in the appropriate state when the next
token is symbol i. If LA[l, i] and LA[l, j] are both 1 for i != j,
it is a conflict. */

View File

@@ -81,7 +81,7 @@ print_core (FILE *out, state *s)
{
closure (sitems, snritems);
sitems = itemset;
snritems = nritemset;
snritems = nitemset;
}
if (!snritems)

View File

@@ -56,7 +56,7 @@ print_core (struct obstack *oout, state *s)
{
closure (sitems, snritems);
sitems = itemset;
snritems = nritemset;
snritems = nitemset;
}
obstack_fgrow1 (oout, "%d", s->number);

View File

@@ -44,7 +44,7 @@
ACCESSING_SYMBOL of the core.
Each core contains a vector of NITEMS items which are the indices
in the RITEMS vector of the items that are selected in this state.
in the RITEM vector of the items that are selected in this state.
The two types of actions are shifts/gotos (push the lookahead token
and read another/goto to the state designated by a nterm) and
@@ -63,9 +63,8 @@
deletes transitions by having them point to zero.
Each reductions structure describes the possible reductions at the
state whose number is in the number field. The data is a list of
nreds rules, represented by their rule numbers. first_reduction
points to the list of these structures.
state whose number is in the number field. rules is an array of
num rules. lookahead_tokens is an array of bitsets, one per rule.
Conflict resolution can decide that certain tokens in certain
states should explicitly be errors (for implementing %nonassoc).