- int key;
- size_t i;
- state_t *sp;
-
- if (trace_flag)
- fprintf (stderr, "Entering get_state, state = %d, symbol = %d (%s)\n",
- this_state->number, symbol,
- symbol_tag_get (symbols[symbol]));
-
- /* Add up the target state's active item numbers to get a hash key.
- */
- key = 0;
- for (i = 0; i < core_size; ++i)
- key += core[i];
- key = key % STATE_HASH_SIZE;
- sp = state_hash[key];
-
- if (sp)
- {
- int found = 0;
- while (!found)
- {
- if (sp->nitems == core_size)
- {
- found = 1;
- for (i = 0; i < core_size; ++i)
- if (core[i] != sp->items[i])
- found = 0;
- }
-
- if (!found)
- {
- if (sp->link)
- {
- sp = sp->link;
- }
- else /* bucket exhausted and no match */
- {
- sp = sp->link = new_state (symbol, core_size, core);
- found = 1;
- }
- }
- }
- }
- else /* bucket is empty */
- {
- state_hash[key] = sp = new_state (symbol, core_size, core);
- }
+ state *s;
+
+ if (trace_flag & trace_automaton)
+ fprintf (stderr, "Entering get_state, symbol = %d (%s)\n",
+ sym, symbols[sym]->tag);