mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
style: scope reduction in tables.c
* src/tables.c: here. * src/lalr.c: Prefer < to >.
This commit is contained in:
@@ -77,7 +77,7 @@ set_goto_map (void)
|
|||||||
for (state_number s = 0; s < nstates; ++s)
|
for (state_number s = 0; s < nstates; ++s)
|
||||||
{
|
{
|
||||||
transitions *sp = states[s]->transitions;
|
transitions *sp = states[s]->transitions;
|
||||||
for (int i = sp->num - 1; i >= 0 && TRANSITION_IS_GOTO (sp, i); --i)
|
for (int i = sp->num - 1; 0 <= i && TRANSITION_IS_GOTO (sp, i); --i)
|
||||||
{
|
{
|
||||||
ngotos++;
|
ngotos++;
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ set_goto_map (void)
|
|||||||
for (state_number s = 0; s < nstates; ++s)
|
for (state_number s = 0; s < nstates; ++s)
|
||||||
{
|
{
|
||||||
const transitions *sp = states[s]->transitions;
|
const transitions *sp = states[s]->transitions;
|
||||||
for (int i = sp->num - 1; i >= 0 && TRANSITION_IS_GOTO (sp, i); --i)
|
for (int i = sp->num - 1; 0 <= i && TRANSITION_IS_GOTO (sp, i); --i)
|
||||||
{
|
{
|
||||||
goto_number k = temp_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
|
goto_number k = temp_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
|
||||||
from_state[k] = s;
|
from_state[k] = s;
|
||||||
|
|||||||
35
src/tables.c
35
src/tables.c
@@ -236,22 +236,16 @@ conflict_row (state *s)
|
|||||||
static rule *
|
static rule *
|
||||||
action_row (state *s)
|
action_row (state *s)
|
||||||
{
|
{
|
||||||
rule *default_reduction = NULL;
|
|
||||||
reductions *reds = s->reductions;
|
|
||||||
transitions *trans = s->transitions;
|
|
||||||
errs *errp = s->errs;
|
|
||||||
/* Set to nonzero to inhibit having any default reduction. */
|
|
||||||
bool nodefault = false;
|
|
||||||
bool conflicted = false;
|
|
||||||
|
|
||||||
for (state_number i = 0; i < ntokens; i++)
|
for (state_number i = 0; i < ntokens; i++)
|
||||||
actrow[i] = conflrow[i] = 0;
|
actrow[i] = conflrow[i] = 0;
|
||||||
|
|
||||||
|
reductions *reds = s->reductions;
|
||||||
|
bool conflicted = false;
|
||||||
if (reds->lookahead_tokens)
|
if (reds->lookahead_tokens)
|
||||||
/* loop over all the rules available here which require
|
/* loop over all the rules available here which require
|
||||||
lookahead (in reverse order to give precedence to the first
|
lookahead (in reverse order to give precedence to the first
|
||||||
rule) */
|
rule) */
|
||||||
for (int i = reds->num - 1; i >= 0; --i)
|
for (int i = reds->num - 1; 0 <= i; --i)
|
||||||
/* and find each token which the rule finds acceptable
|
/* and find each token which the rule finds acceptable
|
||||||
to come next */
|
to come next */
|
||||||
{
|
{
|
||||||
@@ -273,6 +267,9 @@ action_row (state *s)
|
|||||||
/* Now see which tokens are allowed for shifts in this state. For
|
/* Now see which tokens are allowed for shifts in this state. For
|
||||||
them, record the shift as the thing to do. So shift is preferred
|
them, record the shift as the thing to do. So shift is preferred
|
||||||
to reduce. */
|
to reduce. */
|
||||||
|
transitions *trans = s->transitions;
|
||||||
|
/* Set to nonzero to inhibit having any default reduction. */
|
||||||
|
bool nodefault = false;
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
FOR_EACH_SHIFT (trans, i)
|
FOR_EACH_SHIFT (trans, i)
|
||||||
@@ -297,6 +294,7 @@ action_row (state *s)
|
|||||||
/* See which tokens are an explicit error in this state (due to
|
/* See which tokens are an explicit error in this state (due to
|
||||||
%nonassoc). For them, record ACTION_NUMBER_MINIMUM as the
|
%nonassoc). For them, record ACTION_NUMBER_MINIMUM as the
|
||||||
action. */
|
action. */
|
||||||
|
errs *errp = s->errs;
|
||||||
for (int i = 0; i < errp->num; i++)
|
for (int i = 0; i < errp->num; i++)
|
||||||
{
|
{
|
||||||
symbol *sym = errp->symbols[i];
|
symbol *sym = errp->symbols[i];
|
||||||
@@ -316,7 +314,7 @@ action_row (state *s)
|
|||||||
|
|
||||||
/* Now find the most common reduction and make it the default action
|
/* Now find the most common reduction and make it the default action
|
||||||
for this state. */
|
for this state. */
|
||||||
|
rule *default_reduction = NULL;
|
||||||
if (reds->num >= 1 && !nodefault)
|
if (reds->num >= 1 && !nodefault)
|
||||||
{
|
{
|
||||||
if (s->consistent)
|
if (s->consistent)
|
||||||
@@ -345,14 +343,12 @@ action_row (state *s)
|
|||||||
actions that match the default are replaced with zero,
|
actions that match the default are replaced with zero,
|
||||||
which means "use the default". */
|
which means "use the default". */
|
||||||
|
|
||||||
if (max > 0)
|
if (0 < max)
|
||||||
{
|
for (symbol_number j = 0; j < ntokens; j++)
|
||||||
for (symbol_number j = 0; j < ntokens; j++)
|
if (actrow[j]
|
||||||
if (actrow[j]
|
== rule_number_as_item_number (default_reduction->number)
|
||||||
== rule_number_as_item_number (default_reduction->number)
|
&& ! (nondeterministic_parser && conflrow[j]))
|
||||||
&& ! (nondeterministic_parser && conflrow[j]))
|
actrow[j] = 0;
|
||||||
actrow[j] = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -606,7 +602,6 @@ matching_state (vector_number vector)
|
|||||||
{
|
{
|
||||||
size_t t = tally[i];
|
size_t t = tally[i];
|
||||||
int w = width[i];
|
int w = width[i];
|
||||||
int prev;
|
|
||||||
|
|
||||||
/* If VECTOR has GLR conflicts, return -1 */
|
/* If VECTOR has GLR conflicts, return -1 */
|
||||||
if (conflict_tos[i] != NULL)
|
if (conflict_tos[i] != NULL)
|
||||||
@@ -614,7 +609,7 @@ matching_state (vector_number vector)
|
|||||||
if (conflict_tos[i][j] != 0)
|
if (conflict_tos[i][j] != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
for (prev = vector - 1; 0 <= prev; prev--)
|
for (int prev = vector - 1; 0 <= prev; prev--)
|
||||||
{
|
{
|
||||||
vector_number j = order[prev];
|
vector_number j = order[prev];
|
||||||
/* Given how ORDER was computed, if the WIDTH or TALLY is
|
/* Given how ORDER was computed, if the WIDTH or TALLY is
|
||||||
|
|||||||
Reference in New Issue
Block a user