-state_number_t nstates = 0;
-/* FINAL_STATE is properly set by new_state when it recognizes its
- accessing symbol: EOF. */
-state_t *final_state = NULL;
-static state_t *first_state = NULL;
+typedef struct state_list_s
+{
+ struct state_list_s *next;
+ state_t *state;
+} state_list_t;
+
+static state_list_t *first_state = NULL;
+static state_list_t *last_state = NULL;
+
+
+/*------------------------------------------------------------------.
+| A state was just discovered from another state. Queue it for |
+| later examination, in order to find its transitions. Return it. |
+`------------------------------------------------------------------*/
+
+static state_t *
+state_list_append (symbol_number_t symbol,
+ size_t core_size, item_number_t *core)
+{
+ state_list_t *node = XMALLOC (state_list_t, 1);
+ state_t *state = state_new (symbol, core_size, core);
+
+ 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 endtoken, and this is not the initial state, then
+ this is the final state. */
+ if (symbol == 0 && first_state)
+ final_state = state;