mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-22 02:33:03 +00:00
* src/print.c: Convert to use bitset.h, not hand coded iterations
over ints.
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
2002-03-04 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
* src/print.c: Convert to use bitset.h, not hand coded iterations
|
||||||
|
over ints.
|
||||||
|
|
||||||
|
|
||||||
2002-03-04 Akim Demaille <akim@epita.fr>
|
2002-03-04 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* src/reduce.c: Convert to use bitset.h, not hand coded BSet.
|
* src/reduce.c: Convert to use bitset.h, not hand coded BSet.
|
||||||
|
|||||||
55
src/print.c
55
src/print.c
@@ -1,5 +1,5 @@
|
|||||||
/* Print information on generated parser, for bison,
|
/* Print information on generated parser, for bison,
|
||||||
Copyright 1984, 1986, 1989, 2000, 2001 Free Software Foundation, Inc.
|
Copyright 1984, 1986, 1989, 2000, 2001, 2002 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
@@ -33,9 +33,10 @@
|
|||||||
#include "print.h"
|
#include "print.h"
|
||||||
#include "reduce.h"
|
#include "reduce.h"
|
||||||
#include "closure.h"
|
#include "closure.h"
|
||||||
|
#include "bitset.h"
|
||||||
|
|
||||||
static unsigned *shiftset = NULL;
|
static bitset shiftset;
|
||||||
static unsigned *lookaheadset = NULL;
|
static bitset lookaheadset;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static void
|
static void
|
||||||
@@ -194,8 +195,7 @@ print_reductions (FILE *out, state_t *state)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < tokensetsize; i++)
|
bitset_zero (shiftset);
|
||||||
shiftset[i] = 0;
|
|
||||||
|
|
||||||
for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++)
|
for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++)
|
||||||
if (!SHIFT_IS_DISABLED (shiftp, i))
|
if (!SHIFT_IS_DISABLED (shiftp, i))
|
||||||
@@ -204,23 +204,26 @@ print_reductions (FILE *out, state_t *state)
|
|||||||
default rule. */
|
default rule. */
|
||||||
if (SHIFT_IS_ERROR (shiftp, i))
|
if (SHIFT_IS_ERROR (shiftp, i))
|
||||||
nodefault = 1;
|
nodefault = 1;
|
||||||
SETBIT (shiftset, SHIFT_SYMBOL (shiftp, i));
|
bitset_set (shiftset, SHIFT_SYMBOL (shiftp, i));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < errp->nerrs; i++)
|
for (i = 0; i < errp->nerrs; i++)
|
||||||
if (errp->errs[i])
|
if (errp->errs[i])
|
||||||
SETBIT (shiftset, errp->errs[i]);
|
bitset_set (shiftset, errp->errs[i]);
|
||||||
|
|
||||||
if (state->nlookaheads == 1 && !nodefault)
|
if (state->nlookaheads == 1 && !nodefault)
|
||||||
{
|
{
|
||||||
int k;
|
|
||||||
int default_rule = LAruleno[state->lookaheadsp];
|
int default_rule = LAruleno[state->lookaheadsp];
|
||||||
|
|
||||||
for (k = 0; k < tokensetsize; ++k)
|
for (i = 0; i < ntokens; ++i)
|
||||||
lookaheadset[k] = LA (state->lookaheadsp)[k] & shiftset[k];
|
if (BITISSET (LA (state->lookaheadsp), i)
|
||||||
|
&& bitset_test (shiftset, i))
|
||||||
|
bitset_set (lookaheadset, i);
|
||||||
|
else
|
||||||
|
bitset_reset (lookaheadset, i);
|
||||||
|
|
||||||
for (i = 0; i < ntokens; i++)
|
for (i = 0; i < ntokens; i++)
|
||||||
if (BITISSET (lookaheadset, i))
|
if (bitset_test (lookaheadset, i))
|
||||||
fprintf (out, _(" %-4s\t[reduce using rule %d (%s)]\n"),
|
fprintf (out, _(" %-4s\t[reduce using rule %d (%s)]\n"),
|
||||||
escape (symbols[i]->tag), default_rule - 1,
|
escape (symbols[i]->tag), default_rule - 1,
|
||||||
escape2 (symbols[rules[default_rule].lhs]->tag));
|
escape2 (symbols[rules[default_rule].lhs]->tag));
|
||||||
@@ -240,11 +243,15 @@ print_reductions (FILE *out, state_t *state)
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
int j, k;
|
int j, k;
|
||||||
|
|
||||||
for (k = 0; k < tokensetsize; ++k)
|
for (k = 0; k < ntokens; ++k)
|
||||||
lookaheadset[k] = LA (state->lookaheadsp + i)[k] & ~shiftset[k];
|
if (BITISSET (LA (state->lookaheadsp + i), k)
|
||||||
|
&& ! bitset_test (shiftset, k))
|
||||||
|
bitset_set (lookaheadset, k);
|
||||||
|
else
|
||||||
|
bitset_reset (lookaheadset, k);
|
||||||
|
|
||||||
for (j = 0; j < ntokens; j++)
|
for (j = 0; j < ntokens; j++)
|
||||||
if (BITISSET (lookaheadset, j))
|
if (bitset_test (lookaheadset, j))
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
if (count > cmax)
|
if (count > cmax)
|
||||||
@@ -254,22 +261,20 @@ print_reductions (FILE *out, state_t *state)
|
|||||||
default_rule = LAruleno[state->lookaheadsp + i];
|
default_rule = LAruleno[state->lookaheadsp + i];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (k = 0; k < tokensetsize; ++k)
|
bitset_or (shiftset, shiftset, lookaheadset);
|
||||||
shiftset[k] |= lookaheadset[k];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < tokensetsize; i++)
|
bitset_zero (shiftset);
|
||||||
shiftset[i] = 0;
|
|
||||||
|
|
||||||
for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++)
|
for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++)
|
||||||
if (!SHIFT_IS_DISABLED (shiftp, i))
|
if (!SHIFT_IS_DISABLED (shiftp, i))
|
||||||
SETBIT (shiftset, SHIFT_SYMBOL (shiftp, i));
|
bitset_set (shiftset, SHIFT_SYMBOL (shiftp, i));
|
||||||
|
|
||||||
for (i = 0; i < ntokens; i++)
|
for (i = 0; i < ntokens; i++)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
int defaulted = 0;
|
int defaulted = 0;
|
||||||
int count = BITISSET (shiftset, i);
|
int count = bitset_test (shiftset, i);
|
||||||
|
|
||||||
for (j = 0; j < state->nlookaheads; ++j)
|
for (j = 0; j < state->nlookaheads; ++j)
|
||||||
{
|
{
|
||||||
@@ -498,12 +503,14 @@ print_results (void)
|
|||||||
if (trace_flag)
|
if (trace_flag)
|
||||||
new_closure (nritems);
|
new_closure (nritems);
|
||||||
/* Storage for print_reductions. */
|
/* Storage for print_reductions. */
|
||||||
shiftset = XCALLOC (unsigned, tokensetsize);
|
shiftset = bitset_create (ntokens, BITSET_FIXED);
|
||||||
lookaheadset = XCALLOC (unsigned, tokensetsize);
|
bitset_zero (shiftset);
|
||||||
|
lookaheadset = bitset_create (ntokens, BITSET_FIXED);
|
||||||
|
bitset_zero (lookaheadset);
|
||||||
for (i = 0; i < nstates; i++)
|
for (i = 0; i < nstates; i++)
|
||||||
print_state (out, states[i]);
|
print_state (out, states[i]);
|
||||||
free (shiftset);
|
bitset_free (shiftset);
|
||||||
free (lookaheadset);
|
bitset_free (lookaheadset);
|
||||||
if (trace_flag)
|
if (trace_flag)
|
||||||
free_closure ();
|
free_closure ();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user