5 * Created by Jason Allen on 6/23/06.
6 * Copyright 2006 Ohloh. All rights reserved.
13 * polyglot_state_count
15 * Returns the number of states a polyglot contains
18 int polyglot_state_count(Polyglot *polyglot) {
20 for ( ; polyglot->states[count] != NULL; count++) {}
25 * polyglot_compile_states
27 * creates an associated CompiledState for every State
28 * contained in a polyglot. CompiledStates are used by
29 * the parser to avoid doing expensive lookups and avoid
30 * redundant processing.
33 void polyglot_compile_states(Polyglot *polyglot) {
34 if (polyglot->compiled_states == NULL) {
36 int state_count = polyglot_state_count(polyglot);
37 polyglot->compiled_states = malloc(sizeof(CompiledState) * state_count);
38 polyglot->compiled_state_count = state_count;
40 for (; i < state_count; i++) {
41 compiled_state_initialize(&polyglot->compiled_states[i], polyglot->states[i], polyglot->transitions);