mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 17:23:02 +00:00
* src/gram.h, src/gram.c (nitems): Remove, it is an alias of
nritems. Adjust dependencies.
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
2002-04-07 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
* src/gram.h, src/gram.c (nitems): Remove, it is an alias of
|
||||||
|
nritems.
|
||||||
|
Adjust dependencies.
|
||||||
|
|
||||||
|
|
||||||
2002-04-07 Akim Demaille <akim@epita.fr>
|
2002-04-07 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* src/reader.c: Normalize increments to prefix form.
|
* src/reader.c: Normalize increments to prefix form.
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ new_itemsets (void)
|
|||||||
|
|
||||||
nshifts = 0;
|
nshifts = 0;
|
||||||
|
|
||||||
for (i = 0; i < nitemset; ++i)
|
for (i = 0; i < nritemset; ++i)
|
||||||
{
|
{
|
||||||
int symbol = ritem[itemset[i]];
|
int symbol = ritem[itemset[i]];
|
||||||
if (symbol >= 0)
|
if (symbol >= 0)
|
||||||
@@ -363,7 +363,7 @@ save_reductions (void)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* 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 < nitemset; ++i)
|
for (i = 0; i < nritemset; ++i)
|
||||||
{
|
{
|
||||||
int item = ritem[itemset[i]];
|
int item = ritem[itemset[i]];
|
||||||
if (item < 0)
|
if (item < 0)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
/* NITEMSET is the size of the array ITEMSET. */
|
/* NITEMSET is the size of the array ITEMSET. */
|
||||||
short *itemset;
|
short *itemset;
|
||||||
int nitemset;
|
int nritemset;
|
||||||
|
|
||||||
static bitset ruleset;
|
static bitset ruleset;
|
||||||
|
|
||||||
@@ -258,7 +258,7 @@ closure (short *core, int 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]]));
|
||||||
|
|
||||||
nitemset = 0;
|
nritemset = 0;
|
||||||
c = 0;
|
c = 0;
|
||||||
for (ruleno = 0; ruleno < nrules + 1; ++ruleno)
|
for (ruleno = 0; ruleno < nrules + 1; ++ruleno)
|
||||||
if (bitset_test (ruleset, ruleno))
|
if (bitset_test (ruleset, ruleno))
|
||||||
@@ -266,23 +266,23 @@ closure (short *core, int n)
|
|||||||
int itemno = rules[ruleno].rhs - ritem;
|
int itemno = rules[ruleno].rhs - ritem;
|
||||||
while (c < n && core[c] < itemno)
|
while (c < n && core[c] < itemno)
|
||||||
{
|
{
|
||||||
itemset[nitemset] = core[c];
|
itemset[nritemset] = core[c];
|
||||||
nitemset++;
|
nritemset++;
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
itemset[nitemset] = itemno;
|
itemset[nritemset] = itemno;
|
||||||
nitemset++;
|
nritemset++;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (c < n)
|
while (c < n)
|
||||||
{
|
{
|
||||||
itemset[nitemset] = core[c];
|
itemset[nritemset] = core[c];
|
||||||
nitemset++;
|
nritemset++;
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trace_flag)
|
if (trace_flag)
|
||||||
print_closure ("output", itemset, nitemset);
|
print_closure ("output", itemset, nritemset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,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 nitemset;
|
extern int nritemset;
|
||||||
|
|
||||||
#endif /* !CLOSURE_H_ */
|
#endif /* !CLOSURE_H_ */
|
||||||
|
|||||||
11
src/gram.c
11
src/gram.c
@@ -27,18 +27,17 @@
|
|||||||
|
|
||||||
/* comments for these variables are in gram.h */
|
/* comments for these variables are in gram.h */
|
||||||
|
|
||||||
int nitems = 0;
|
|
||||||
int nrules = 0;
|
|
||||||
int nsyms = 0;
|
|
||||||
int ntokens = 1;
|
|
||||||
int nvars = 0;
|
|
||||||
|
|
||||||
short *ritem = NULL;
|
short *ritem = NULL;
|
||||||
int nritems = 0;
|
int nritems = 0;
|
||||||
|
|
||||||
rule_t *rules = NULL;
|
rule_t *rules = NULL;
|
||||||
|
int nrules = 0;
|
||||||
|
|
||||||
symbol_t **symbols = NULL;
|
symbol_t **symbols = NULL;
|
||||||
|
int nsyms = 0;
|
||||||
|
int ntokens = 1;
|
||||||
|
int nvars = 0;
|
||||||
|
|
||||||
short *token_translations = NULL;
|
short *token_translations = NULL;
|
||||||
|
|
||||||
int start_symbol = 0;
|
int start_symbol = 0;
|
||||||
|
|||||||
@@ -82,7 +82,7 @@
|
|||||||
says which rule it is for.
|
says which rule it is for.
|
||||||
|
|
||||||
The portions of RITEM come in order of increasing rule number and
|
The portions of RITEM come in order of increasing rule number and
|
||||||
are followed by an element which is zero to mark the end. nitems
|
are followed by an element which is zero to mark the end. nritems
|
||||||
is the total length of ritem, not counting the final zero. Each
|
is the total length of ritem, not counting the final zero. Each
|
||||||
element of RITEM is called an "item" and its index in RITEM is an
|
element of RITEM is called an "item" and its index in RITEM is an
|
||||||
item number.
|
item number.
|
||||||
@@ -104,7 +104,6 @@
|
|||||||
#define ISTOKEN(s) ((s) < ntokens)
|
#define ISTOKEN(s) ((s) < ntokens)
|
||||||
#define ISVAR(s) ((s) >= ntokens)
|
#define ISVAR(s) ((s) >= ntokens)
|
||||||
|
|
||||||
extern int nitems;
|
|
||||||
extern int nrules;
|
extern int nrules;
|
||||||
extern int nsyms;
|
extern int nsyms;
|
||||||
extern int ntokens;
|
extern int ntokens;
|
||||||
|
|||||||
10
src/print.c
10
src/print.c
@@ -70,20 +70,20 @@ print_core (FILE *out, state_t *state)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
short *sitems = state->items;
|
short *sitems = state->items;
|
||||||
int snitems = state->nitems;
|
int snritems = state->nitems;
|
||||||
|
|
||||||
/* New experimental feature: if TRACE_FLAGS output all the items of
|
/* New experimental feature: if TRACE_FLAGS output all the items of
|
||||||
a state, not only its kernel. */
|
a state, not only its kernel. */
|
||||||
if (trace_flag)
|
if (trace_flag)
|
||||||
{
|
{
|
||||||
closure (sitems, snitems);
|
closure (sitems, snritems);
|
||||||
sitems = itemset;
|
sitems = itemset;
|
||||||
snitems = nitemset;
|
snritems = nritemset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (snitems)
|
if (snritems)
|
||||||
{
|
{
|
||||||
for (i = 0; i < snitems; i++)
|
for (i = 0; i < snritems; i++)
|
||||||
{
|
{
|
||||||
short *sp;
|
short *sp;
|
||||||
short *sp1;
|
short *sp1;
|
||||||
|
|||||||
@@ -51,18 +51,18 @@ print_core (state_t *state, struct obstack *node_obstack)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
short *sitems = state->items;
|
short *sitems = state->items;
|
||||||
int snitems = state->nitems;
|
int snritems = state->nitems;
|
||||||
|
|
||||||
/* Output all the items of a state, not only its kernel. */
|
/* Output all the items of a state, not only its kernel. */
|
||||||
if (trace_flag)
|
if (trace_flag)
|
||||||
{
|
{
|
||||||
closure (sitems, snitems);
|
closure (sitems, snritems);
|
||||||
sitems = itemset;
|
sitems = itemset;
|
||||||
snitems = nitemset;
|
snritems = nritemset;
|
||||||
}
|
}
|
||||||
|
|
||||||
obstack_fgrow1 (node_obstack, "state %2d\n", state->number);
|
obstack_fgrow1 (node_obstack, "state %2d\n", state->number);
|
||||||
for (i = 0; i < snitems; i++)
|
for (i = 0; i < snritems; i++)
|
||||||
{
|
{
|
||||||
short *sp;
|
short *sp;
|
||||||
short *sp1;
|
short *sp1;
|
||||||
|
|||||||
17
src/reader.c
17
src/reader.c
@@ -1433,7 +1433,7 @@ readgram (void)
|
|||||||
/* start a new rule and record its lhs. */
|
/* start a new rule and record its lhs. */
|
||||||
|
|
||||||
++nrules;
|
++nrules;
|
||||||
++nitems;
|
++nritems;
|
||||||
|
|
||||||
p = symbol_list_new (lhs);
|
p = symbol_list_new (lhs);
|
||||||
|
|
||||||
@@ -1511,7 +1511,7 @@ readgram (void)
|
|||||||
current one, so that the action just read can
|
current one, so that the action just read can
|
||||||
belong to it. */
|
belong to it. */
|
||||||
++nrules;
|
++nrules;
|
||||||
++nitems;
|
++nritems;
|
||||||
p = symbol_list_new (sdummy);
|
p = symbol_list_new (sdummy);
|
||||||
/* Attach its lineno to that of the host rule. */
|
/* Attach its lineno to that of the host rule. */
|
||||||
p->line = crule->line;
|
p->line = crule->line;
|
||||||
@@ -1532,7 +1532,7 @@ readgram (void)
|
|||||||
|
|
||||||
/* Insert the dummy generated by that rule into this
|
/* Insert the dummy generated by that rule into this
|
||||||
rule. */
|
rule. */
|
||||||
++nitems;
|
++nritems;
|
||||||
p = symbol_list_new (sdummy);
|
p = symbol_list_new (sdummy);
|
||||||
p1->next = p;
|
p1->next = p;
|
||||||
p1 = p;
|
p1 = p;
|
||||||
@@ -1542,7 +1542,7 @@ readgram (void)
|
|||||||
|
|
||||||
if (t == tok_identifier)
|
if (t == tok_identifier)
|
||||||
{
|
{
|
||||||
++nitems;
|
++nritems;
|
||||||
p = symbol_list_new (symval);
|
p = symbol_list_new (symval);
|
||||||
p1->next = p;
|
p1->next = p;
|
||||||
p1 = p;
|
p1 = p;
|
||||||
@@ -1633,7 +1633,7 @@ readgram (void)
|
|||||||
p->next->next->next = symbol_list_new (NULL);
|
p->next->next->next = symbol_list_new (NULL);
|
||||||
p->next->next->next->next = grammar;
|
p->next->next->next->next = grammar;
|
||||||
nrules += 1;
|
nrules += 1;
|
||||||
nitems += 3;
|
nritems += 3;
|
||||||
grammar = p;
|
grammar = p;
|
||||||
startval = axiom;
|
startval = axiom;
|
||||||
|
|
||||||
@@ -1742,10 +1742,10 @@ packgram (void)
|
|||||||
symbol_list *p;
|
symbol_list *p;
|
||||||
|
|
||||||
/* We use short to index items. */
|
/* We use short to index items. */
|
||||||
if (nitems >= MAXSHORT)
|
if (nritems >= MAXSHORT)
|
||||||
fatal (_("too many items (max %d)"), MAXSHORT);
|
fatal (_("too many items (max %d)"), MAXSHORT);
|
||||||
|
|
||||||
ritem = XCALLOC (short, nitems + 1);
|
ritem = XCALLOC (short, nritems + 1);
|
||||||
rules = XCALLOC (rule_t, nrules) - 1;
|
rules = XCALLOC (rule_t, nrules) - 1;
|
||||||
|
|
||||||
itemno = 0;
|
itemno = 0;
|
||||||
@@ -1793,8 +1793,7 @@ packgram (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ritem[itemno] = 0;
|
ritem[itemno] = 0;
|
||||||
nritems = itemno;
|
assert (itemno == nritems);
|
||||||
assert (nritems == nitems);
|
|
||||||
|
|
||||||
if (trace_flag)
|
if (trace_flag)
|
||||||
ritem_print (stderr);
|
ritem_print (stderr);
|
||||||
|
|||||||
@@ -269,7 +269,6 @@ reduce_grammar_tables (void)
|
|||||||
{
|
{
|
||||||
length = rule_rhs_length (&rules[r]);
|
length = rule_rhs_length (&rules[r]);
|
||||||
nritems -= length + 1;
|
nritems -= length + 1;
|
||||||
nitems -= length + 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -383,8 +382,8 @@ dump_grammar (FILE *out)
|
|||||||
|
|
||||||
fprintf (out, "REDUCED GRAMMAR\n\n");
|
fprintf (out, "REDUCED GRAMMAR\n\n");
|
||||||
fprintf (out,
|
fprintf (out,
|
||||||
"ntokens = %d, nvars = %d, nsyms = %d, nrules = %d, nitems = %d\n\n",
|
"ntokens = %d, nvars = %d, nsyms = %d, nrules = %d, nritems = %d\n\n",
|
||||||
ntokens, nvars, nsyms, nrules, nitems);
|
ntokens, nvars, nsyms, nrules, nritems);
|
||||||
fprintf (out, "Variables\n---------\n\n");
|
fprintf (out, "Variables\n---------\n\n");
|
||||||
fprintf (out, "Value Sprec Sassoc Tag\n");
|
fprintf (out, "Value Sprec Sassoc Tag\n");
|
||||||
for (i = ntokens; i < nsyms; i++)
|
for (i = ntokens; i < nsyms; i++)
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
the last thing accepted to reach that state. It is the
|
the last thing accepted to reach that state. It is the
|
||||||
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 ritems vector of the items that are selected in this state.
|
||||||
|
|
||||||
The link field is used for chaining symbols that hash states by
|
The link field is used for chaining symbols that hash states by
|
||||||
|
|||||||
Reference in New Issue
Block a user