/* Generate the nondeterministic finite state machine for bison,
- Copyright 1984, 1986, 1989, 2000, 2001, 2002 Free Software Foundation, Inc.
+
+ Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002 Free Software
+ Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
state_list_t *node = XMALLOC (state_list_t, 1);
state_t *state = state_new (symbol, core_size, core);
- if (trace_flag)
+ if (trace_flag & trace_automaton)
fprintf (stderr, "state_list_append (state = %d, symbol = %d (%s))\n",
nstates, symbol, symbols[symbol]->tag);
- /* If this is the eoftoken, and this is not the initial state, then
+ /* If this is the endtoken, and this is not the initial state, then
this is the final state. */
if (symbol == 0 && first_state)
final_state = state;
static int nshifts;
static symbol_number_t *shift_symbol = NULL;
-static short *redset = NULL;
-static state_number_t *shiftset = NULL;
+static rule_t **redset = NULL;
+static state_t **shiftset = NULL;
static item_number_t **kernel_base = NULL;
static int *kernel_size = NULL;
{
allocate_itemsets ();
- shiftset = XCALLOC (state_number_t, nsyms);
- redset = XCALLOC (short, nrules);
+ shiftset = XCALLOC (state_t *, nsyms);
+ redset = XCALLOC (rule_t *, nrules);
state_hash_new ();
shift_symbol = XCALLOC (symbol_number_t, nsyms);
}
{
int i;
- if (trace_flag)
+ if (trace_flag & trace_automaton)
fprintf (stderr, "Entering new_itemsets, state = %d\n",
state->number);
-/*--------------------------------------------------------------.
-| Find the state number for the state we would get to (from the |
-| current state) by shifting symbol. Create a new state if no |
-| equivalent one exists already. Used by append_states. |
-`--------------------------------------------------------------*/
+/*-----------------------------------------------------------------.
+| Find the state we would get to (from the current state) by |
+| shifting SYMBOL. Create a new state if no equivalent one exists |
+| already. Used by append_states. |
+`-----------------------------------------------------------------*/
-static state_number_t
+static state_t *
get_state (symbol_number_t symbol, size_t core_size, item_number_t *core)
{
state_t *sp;
- if (trace_flag)
+ if (trace_flag & trace_automaton)
fprintf (stderr, "Entering get_state, symbol = %d (%s)\n",
symbol, symbols[symbol]->tag);
if (!sp)
sp = state_list_append (symbol, core_size, core);
- if (trace_flag)
+ if (trace_flag & trace_automaton)
fprintf (stderr, "Exiting get_state => %d\n", sp->number);
- return sp->number;
+ return sp;
}
-/*------------------------------------------------------------------.
-| Use the information computed by new_itemsets to find the state |
-| numbers reached by each shift transition from STATE. |
-| |
-| SHIFTSET is set up as a vector of state numbers of those states. |
-`------------------------------------------------------------------*/
+/*---------------------------------------------------------------.
+| Use the information computed by new_itemsets to find the state |
+| numbers reached by each shift transition from STATE. |
+| |
+| SHIFTSET is set up as a vector of those states. |
+`---------------------------------------------------------------*/
static void
append_states (state_t *state)
int j;
symbol_number_t symbol;
- if (trace_flag)
+ if (trace_flag & trace_automaton)
fprintf (stderr, "Entering append_states, state = %d\n",
state->number);
int count = 0;
int i;
- /* If this is the final state, we want it to have no reductions at
- all, although it has one for `START_SYMBOL EOF .'. */
- if (final_state && state->number == final_state->number)
- return;
-
/* Find and count the active items that represent ends of rules. */
for (i = 0; i < nritemset; ++i)
{
int item = ritem[itemset[i]];
if (item < 0)
- redset[count++] = item_number_as_rule_number (item);
+ redset[count++] = &rules[item_number_as_rule_number (item)];
}
/* Make a reductions structure and copy the data into it. */
while (list)
{
state_t *state = list->state;
- if (trace_flag)
+ if (trace_flag & trace_automaton)
fprintf (stderr, "Processing state %d (reached by %s)\n",
state->number,
symbols[state->accessing_symbol]->tag);