nritems.
Adjust dependencies.
+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>
* src/reader.c: Normalize increments to prefix form.
2002-04-07 Akim Demaille <akim@epita.fr>
* src/reader.c: Normalize increments to prefix form.
- for (i = 0; i < nitemset; ++i)
+ for (i = 0; i < nritemset; ++i)
{
int symbol = ritem[itemset[i]];
if (symbol >= 0)
{
int symbol = ritem[itemset[i]];
if (symbol >= 0)
return;
/* Find and count the active items that represent ends of rules. */
return;
/* 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]];
if (item < 0)
{
int item = ritem[itemset[i]];
if (item < 0)
/* NITEMSET is the size of the array ITEMSET. */
short *itemset;
/* NITEMSET is the size of the array ITEMSET. */
short *itemset;
if (ISVAR (ritem[core[c]]))
bitset_or (ruleset, ruleset, FDERIVES (ritem[core[c]]));
if (ISVAR (ritem[core[c]]))
bitset_or (ruleset, ruleset, FDERIVES (ritem[core[c]]));
c = 0;
for (ruleno = 0; ruleno < nrules + 1; ++ruleno)
if (bitset_test (ruleset, ruleno))
c = 0;
for (ruleno = 0; ruleno < nrules + 1; ++ruleno)
if (bitset_test (ruleset, ruleno))
int itemno = rules[ruleno].rhs - ritem;
while (c < n && core[c] < itemno)
{
int itemno = rules[ruleno].rhs - ritem;
while (c < n && core[c] < itemno)
{
- itemset[nitemset] = core[c];
- nitemset++;
+ itemset[nritemset] = core[c];
+ nritemset++;
- itemset[nitemset] = itemno;
- nitemset++;
+ itemset[nritemset] = itemno;
+ nritemset++;
- itemset[nitemset] = core[c];
- nitemset++;
+ itemset[nritemset] = core[c];
+ nritemset++;
- print_closure ("output", itemset, nitemset);
+ print_closure ("output", itemset, nritemset);
void free_closure PARAMS ((void));
extern short *itemset;
void free_closure PARAMS ((void));
extern short *itemset;
/* 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;
int nritems = 0;
rule_t *rules = NULL;
short *ritem = NULL;
int nritems = 0;
rule_t *rules = NULL;
symbol_t **symbols = NULL;
symbol_t **symbols = NULL;
+int nsyms = 0;
+int ntokens = 1;
+int nvars = 0;
+
short *token_translations = NULL;
int start_symbol = 0;
short *token_translations = NULL;
int start_symbol = 0;
says which rule it is for.
The portions of RITEM come in order of increasing rule number and
says which rule it is for.
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
element of RITEM is called an "item" and its index in RITEM is an
item number.
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
item number.
#define ISTOKEN(s) ((s) < ntokens)
#define ISVAR(s) ((s) >= ntokens)
#define ISTOKEN(s) ((s) < ntokens)
#define ISVAR(s) ((s) >= ntokens)
extern int nrules;
extern int nsyms;
extern int ntokens;
extern int nrules;
extern int nsyms;
extern int ntokens;
{
int i;
short *sitems = state->items;
{
int i;
short *sitems = state->items;
- int snitems = state->nitems;
+ int snritems = state->nitems;
/* New experimental feature: if TRACE_FLAGS output all the items of
a state, not only its kernel. */
if (trace_flag)
{
/* New experimental feature: if TRACE_FLAGS output all the items of
a state, not only its kernel. */
if (trace_flag)
{
- closure (sitems, snitems);
+ closure (sitems, snritems);
- for (i = 0; i < snitems; i++)
+ for (i = 0; i < snritems; i++)
{
int i;
short *sitems = state->items;
{
int i;
short *sitems = state->items;
- int snitems = state->nitems;
+ int snritems = state->nitems;
/* Output all the items of a state, not only its kernel. */
if (trace_flag)
{
/* Output all the items of a state, not only its kernel. */
if (trace_flag)
{
- closure (sitems, snitems);
+ closure (sitems, snritems);
}
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++)
/* start a new rule and record its lhs. */
++nrules;
/* start a new rule and record its lhs. */
++nrules;
p = symbol_list_new (lhs);
p = symbol_list_new (lhs);
current one, so that the action just read can
belong to it. */
++nrules;
current one, so that the action just read can
belong to it. */
++nrules;
p = symbol_list_new (sdummy);
/* Attach its lineno to that of the host rule. */
p->line = crule->line;
p = symbol_list_new (sdummy);
/* Attach its lineno to that of the host rule. */
p->line = crule->line;
/* Insert the dummy generated by that rule into this
rule. */
/* Insert the dummy generated by that rule into this
rule. */
p = symbol_list_new (sdummy);
p1->next = p;
p1 = p;
p = symbol_list_new (sdummy);
p1->next = p;
p1 = p;
if (t == tok_identifier)
{
if (t == tok_identifier)
{
p = symbol_list_new (symval);
p1->next = p;
p1 = p;
p = symbol_list_new (symval);
p1->next = p;
p1 = p;
p->next->next->next = symbol_list_new (NULL);
p->next->next->next->next = grammar;
nrules += 1;
p->next->next->next = symbol_list_new (NULL);
p->next->next->next->next = grammar;
nrules += 1;
grammar = p;
startval = axiom;
grammar = p;
startval = axiom;
symbol_list *p;
/* We use short to index items. */
symbol_list *p;
/* 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;
itemno = 0;
rules = XCALLOC (rule_t, nrules) - 1;
itemno = 0;
- nritems = itemno;
- assert (nritems == nitems);
+ assert (itemno == nritems);
if (trace_flag)
ritem_print (stderr);
if (trace_flag)
ritem_print (stderr);
{
length = rule_rhs_length (&rules[r]);
nritems -= length + 1;
{
length = rule_rhs_length (&rules[r]);
nritems -= length + 1;
fprintf (out, "REDUCED GRAMMAR\n\n");
fprintf (out,
fprintf (out, "REDUCED GRAMMAR\n\n");
fprintf (out,
- "ntokens = %d, nvars = %d, nsyms = %d, nrules = %d, nitems = %d\n\n",
- ntokens, nvars, nsyms, nrules, nitems);
+ "ntokens = %d, nvars = %d, nsyms = %d, nrules = %d, nritems = %d\n\n",
+ ntokens, nvars, nsyms, nrules, nritems);
fprintf (out, "Variables\n---------\n\n");
fprintf (out, "Value Sprec Sassoc Tag\n");
for (i = ntokens; i < nsyms; i++)
fprintf (out, "Variables\n---------\n\n");
fprintf (out, "Value Sprec Sassoc Tag\n");
for (i = ntokens; i < nsyms; i++)
the last thing accepted to reach that state. It is the
accessing_symbol of the core.
the last thing accepted to reach that state. It is the
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.
The link field is used for chaining symbols that hash states by
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