mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
* src/closure.c, src/print.c, src/reader.c, src/reduce.c:
Normalize loops to using `< nrules + 1', not `<= nrules'.
This commit is contained in:
@@ -91,7 +91,7 @@ print_fderives (void)
|
||||
for (i = ntokens; i < nsyms; i++)
|
||||
{
|
||||
fprintf (stderr, "\t%s derives\n", symbols[i]->tag);
|
||||
for (j = 0; j <= nrules; j++)
|
||||
for (j = 0; j < nrules + 1; j++)
|
||||
if (bitset_test (FDERIVES (i), j))
|
||||
{
|
||||
short *rhsp;
|
||||
|
||||
14
src/print.c
14
src/print.c
@@ -365,7 +365,7 @@ print_grammar (FILE *out)
|
||||
/* rule # : LHS -> RHS */
|
||||
fprintf (out, "%s\n\n", _("Grammar"));
|
||||
fprintf (out, " %s\n", _("Number, Line, Rule"));
|
||||
for (i = 1; i <= nrules; i++)
|
||||
for (i = 1; i < nrules + 1; i++)
|
||||
/* Don't print rules disabled in reduce_grammar_tables. */
|
||||
if (rules[i].useful)
|
||||
{
|
||||
@@ -384,7 +384,7 @@ print_grammar (FILE *out)
|
||||
|
||||
/* TERMINAL (type #) : rule #s terminal is on RHS */
|
||||
fprintf (out, "%s\n\n", _("Terminals, with rules where they appear"));
|
||||
for (i = 0; i <= max_user_token_number; i++)
|
||||
for (i = 0; i < max_user_token_number + 1; i++)
|
||||
if (token_translations[i] != 2)
|
||||
{
|
||||
buffer[0] = 0;
|
||||
@@ -393,7 +393,7 @@ print_grammar (FILE *out)
|
||||
END_TEST (50);
|
||||
sprintf (buffer, " (%d)", i);
|
||||
|
||||
for (j = 1; j <= nrules; j++)
|
||||
for (j = 1; j < nrules + 1; j++)
|
||||
for (rule = rules[j].rhs; *rule >= 0; rule++)
|
||||
if (*rule == token_translations[i])
|
||||
{
|
||||
@@ -407,11 +407,11 @@ print_grammar (FILE *out)
|
||||
|
||||
|
||||
fprintf (out, "%s\n\n", _("Nonterminals, with rules where they appear"));
|
||||
for (i = ntokens; i <= nsyms - 1; i++)
|
||||
for (i = ntokens; i < nsyms; i++)
|
||||
{
|
||||
int left_count = 0, right_count = 0;
|
||||
|
||||
for (j = 1; j <= nrules; j++)
|
||||
for (j = 1; j < nrules + 1; j++)
|
||||
{
|
||||
if (rules[j].lhs == i)
|
||||
left_count++;
|
||||
@@ -434,7 +434,7 @@ print_grammar (FILE *out)
|
||||
END_TEST (50);
|
||||
sprintf (buffer + strlen (buffer), _(" on left:"));
|
||||
|
||||
for (j = 1; j <= nrules; j++)
|
||||
for (j = 1; j < nrules + 1; j++)
|
||||
{
|
||||
END_TEST (65);
|
||||
if (rules[j].lhs == i)
|
||||
@@ -448,7 +448,7 @@ print_grammar (FILE *out)
|
||||
sprintf (buffer + strlen (buffer), ",");
|
||||
END_TEST (50);
|
||||
sprintf (buffer + strlen (buffer), _(" on right:"));
|
||||
for (j = 1; j <= nrules; j++)
|
||||
for (j = 1; j < nrules + 1; j++)
|
||||
{
|
||||
for (rule = rules[j].rhs; *rule >= 0; rule++)
|
||||
if (*rule == i)
|
||||
|
||||
@@ -1538,7 +1538,7 @@ token_translations_init (void)
|
||||
/* Initialize all entries for literal tokens to 2, the internal
|
||||
token number for $undefined., which represents all invalid
|
||||
inputs. */
|
||||
for (i = 0; i <= max_user_token_number; i++)
|
||||
for (i = 0; i < max_user_token_number + 1; i++)
|
||||
token_translations[i] = 2;
|
||||
|
||||
for (bp = firstsymbol; bp; bp = bp->next)
|
||||
|
||||
16
src/reduce.c
16
src/reduce.c
@@ -114,7 +114,7 @@ useless_nonterminals (void)
|
||||
while (1)
|
||||
{
|
||||
bitset_copy (Np, N);
|
||||
for (i = 1; i <= nrules; i++)
|
||||
for (i = 1; i < nrules + 1; i++)
|
||||
if (!bitset_test (P, i)
|
||||
&& useful_production (i, N))
|
||||
{
|
||||
@@ -174,7 +174,7 @@ inaccessable_symbols (void)
|
||||
while (1)
|
||||
{
|
||||
bitset_copy (Vp, V);
|
||||
for (i = 1; i <= nrules; i++)
|
||||
for (i = 1; i < nrules + 1; i++)
|
||||
{
|
||||
if (!bitset_test (Pp, i)
|
||||
&& bitset_test (P, i)
|
||||
@@ -241,7 +241,7 @@ reduce_grammar_tables (void)
|
||||
|
||||
np = 0;
|
||||
ni = 0;
|
||||
for (pn = 1; pn <= nrules; pn++)
|
||||
for (pn = 1; pn < nrules + 1; pn++)
|
||||
if (bitset_test (P, pn))
|
||||
{
|
||||
np++;
|
||||
@@ -281,7 +281,7 @@ reduce_grammar_tables (void)
|
||||
if (nuseless_productions > 0)
|
||||
{
|
||||
int pn;
|
||||
for (pn = 1; pn <= nrules; pn++)
|
||||
for (pn = 1; pn < nrules + 1; pn++)
|
||||
rules[pn].useful = bitset_test (P, pn);
|
||||
}
|
||||
}
|
||||
@@ -322,7 +322,7 @@ nonterminals_reduce (void)
|
||||
|
||||
/* Replace all symbol numbers in valid data structures. */
|
||||
|
||||
for (i = 1; i <= nrules; i++)
|
||||
for (i = 1; i < nrules + 1; i++)
|
||||
{
|
||||
rules[i].lhs = nontermmap[rules[i].lhs];
|
||||
if (ISVAR (rules[i].precsym))
|
||||
@@ -378,7 +378,7 @@ reduce_output (FILE *out)
|
||||
{
|
||||
int i;
|
||||
fprintf (out, "%s\n\n", _("Useless rules:"));
|
||||
for (i = 1; i <= nrules; i++)
|
||||
for (i = 1; i < nrules + 1; i++)
|
||||
if (!rules[i].useful)
|
||||
{
|
||||
rule r;
|
||||
@@ -411,7 +411,7 @@ dump_grammar (FILE *out)
|
||||
fprintf (out, "\n\n");
|
||||
fprintf (out, "Rules\n-----\n\n");
|
||||
fprintf (out, "Num (Prec, Assoc, Useful, Ritem Range) Lhs -> Rhs (Ritem range) [Num]\n");
|
||||
for (i = 1; i <= nrules; i++)
|
||||
for (i = 1; i < nrules + 1; i++)
|
||||
{
|
||||
int rhs_count = 0;
|
||||
/* Find the last RHS index in ritems. */
|
||||
@@ -429,7 +429,7 @@ dump_grammar (FILE *out)
|
||||
}
|
||||
fprintf (out, "\n\n");
|
||||
fprintf (out, "Rules interpreted\n-----------------\n\n");
|
||||
for (i = 1; i <= nrules; i++)
|
||||
for (i = 1; i < nrules + 1; i++)
|
||||
{
|
||||
fprintf (out, "%-5d %s :", i, symbols[rules[i].lhs]->tag);
|
||||
for (r = rules[i].rhs; *r >= 0; r++)
|
||||
|
||||
Reference in New Issue
Block a user