mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-20 17:53:02 +00:00
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:
16
ChangeLog
16
ChangeLog
@@ -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>
|
2007-04-04 Paul Eggert <eggert@cs.ucla.edu>
|
||||||
|
|
||||||
* THANKS: Use ASCII for Sebastien Fricker's name. Bison source
|
* THANKS: Use ASCII for Sebastien Fricker's name. Bison source
|
||||||
|
|||||||
@@ -183,8 +183,8 @@ new_itemsets (state *s)
|
|||||||
|
|
||||||
nshifts = 0;
|
nshifts = 0;
|
||||||
|
|
||||||
for (i = 0; i < nritemset; ++i)
|
for (i = 0; i < nitemset; ++i)
|
||||||
if (ritem[itemset[i]] >= 0)
|
if (item_number_is_symbol_number (ritem[itemset[i]]))
|
||||||
{
|
{
|
||||||
symbol_number sym = item_number_as_symbol_number (ritem[itemset[i]]);
|
symbol_number sym = item_number_as_symbol_number (ritem[itemset[i]]);
|
||||||
if (!kernel_size[sym])
|
if (!kernel_size[sym])
|
||||||
@@ -272,7 +272,7 @@ save_reductions (state *s)
|
|||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
/* Find and count the active items that represent ends of rules. */
|
/* 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]];
|
item_number item = ritem[itemset[i]];
|
||||||
if (item_number_is_rule_number (item))
|
if (item_number_is_rule_number (item))
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
/* NITEMSET is the size of the array ITEMSET. */
|
/* NITEMSET is the size of the array ITEMSET. */
|
||||||
item_number *itemset;
|
item_number *itemset;
|
||||||
size_t nritemset;
|
size_t nitemset;
|
||||||
|
|
||||||
static bitset ruleset;
|
static bitset ruleset;
|
||||||
|
|
||||||
@@ -213,30 +213,30 @@ closure (item_number *core, size_t n)
|
|||||||
if (ISVAR (ritem[core[c]]))
|
if (ISVAR (ritem[core[c]]))
|
||||||
bitset_or (ruleset, ruleset, FDERIVES (ritem[core[c]]));
|
bitset_or (ruleset, ruleset, FDERIVES (ritem[core[c]]));
|
||||||
|
|
||||||
nritemset = 0;
|
nitemset = 0;
|
||||||
c = 0;
|
c = 0;
|
||||||
BITSET_FOR_EACH (iter, ruleset, ruleno, 0)
|
BITSET_FOR_EACH (iter, ruleset, ruleno, 0)
|
||||||
{
|
{
|
||||||
item_number itemno = rules[ruleno].rhs - ritem;
|
item_number itemno = rules[ruleno].rhs - ritem;
|
||||||
while (c < n && core[c] < itemno)
|
while (c < n && core[c] < itemno)
|
||||||
{
|
{
|
||||||
itemset[nritemset] = core[c];
|
itemset[nitemset] = core[c];
|
||||||
nritemset++;
|
nitemset++;
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
itemset[nritemset] = itemno;
|
itemset[nitemset] = itemno;
|
||||||
nritemset++;
|
nitemset++;
|
||||||
};
|
};
|
||||||
|
|
||||||
while (c < n)
|
while (c < n)
|
||||||
{
|
{
|
||||||
itemset[nritemset] = core[c];
|
itemset[nitemset] = core[c];
|
||||||
nritemset++;
|
nitemset++;
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trace_flag & trace_sets)
|
if (trace_flag & trace_sets)
|
||||||
print_closure ("output", itemset, nritemset);
|
print_closure ("output", itemset, nitemset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,6 @@ void closure (item_number *items, size_t n);
|
|||||||
void free_closure (void);
|
void free_closure (void);
|
||||||
|
|
||||||
extern item_number *itemset;
|
extern item_number *itemset;
|
||||||
extern size_t nritemset;
|
extern size_t nitemset;
|
||||||
|
|
||||||
#endif /* !CLOSURE_H_ */
|
#endif /* !CLOSURE_H_ */
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ typedef struct goto_list
|
|||||||
} 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
|
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,
|
token is symbol i. If LA[l, i] and LA[l, j] are both 1 for i != j,
|
||||||
it is a conflict. */
|
it is a conflict. */
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ print_core (FILE *out, state *s)
|
|||||||
{
|
{
|
||||||
closure (sitems, snritems);
|
closure (sitems, snritems);
|
||||||
sitems = itemset;
|
sitems = itemset;
|
||||||
snritems = nritemset;
|
snritems = nitemset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!snritems)
|
if (!snritems)
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ print_core (struct obstack *oout, state *s)
|
|||||||
{
|
{
|
||||||
closure (sitems, snritems);
|
closure (sitems, snritems);
|
||||||
sitems = itemset;
|
sitems = itemset;
|
||||||
snritems = nritemset;
|
snritems = nitemset;
|
||||||
}
|
}
|
||||||
|
|
||||||
obstack_fgrow1 (oout, "%d", s->number);
|
obstack_fgrow1 (oout, "%d", s->number);
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
ACCESSING_SYMBOL of the core.
|
ACCESSING_SYMBOL of the core.
|
||||||
|
|
||||||
Each core contains a vector of NITEMS items which are the indices
|
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
|
The two types of actions are shifts/gotos (push the lookahead token
|
||||||
and read another/goto to the state designated by a nterm) and
|
and read another/goto to the state designated by a nterm) and
|
||||||
@@ -63,9 +63,8 @@
|
|||||||
deletes transitions by having them point to zero.
|
deletes transitions by having them point to zero.
|
||||||
|
|
||||||
Each reductions structure describes the possible reductions at the
|
Each reductions structure describes the possible reductions at the
|
||||||
state whose number is in the number field. The data is a list of
|
state whose number is in the number field. rules is an array of
|
||||||
nreds rules, represented by their rule numbers. first_reduction
|
num rules. lookahead_tokens is an array of bitsets, one per rule.
|
||||||
points to the list of these structures.
|
|
||||||
|
|
||||||
Conflict resolution can decide that certain tokens in certain
|
Conflict resolution can decide that certain tokens in certain
|
||||||
states should explicitly be errors (for implementing %nonassoc).
|
states should explicitly be errors (for implementing %nonassoc).
|
||||||
|
|||||||
Reference in New Issue
Block a user