- fprintf (stderr, "Entering get_state, state = %d, symbol = %d (%s)\n",
- this_state->number, symbol, symbols[symbol]->tag);
-
- /* Add up the target state's active item numbers to get a hash key.
- */
- key = 0;
- for (i = 0; i < kernel_size[symbol]; ++i)
- key += kernel_base[symbol][i];
- key = key % STATE_HASH_SIZE;
- sp = state_hash[key];
-
- if (sp)
- {
- int found = 0;
- while (!found)
- {
- if (sp->nitems == kernel_size[symbol])
- {
- found = 1;
- for (i = 0; i < kernel_size[symbol]; ++i)
- if (kernel_base[symbol][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);
- found = 1;
- }
- }
- }
- }
- else /* bucket is empty */
- {
- state_hash[key] = sp = new_state (symbol);
- }
+ fprintf (stderr, "Entering get_state, symbol = %d (%s)\n",
+ symbol, symbol_tag_get (symbols[symbol]));
+
+ sp = state_hash_lookup (core_size, core);
+ if (!sp)
+ sp = new_state (symbol, core_size, core);