static void get_states(StateMachinePtr sm, NodePtr root, StateSet& states) { assert(root->get_op() == Op::sm_state_condition); if (root->size() == 2) { get_states(sm, root->get_operand(0), states); root = root->get_operand(1); } else { root = root->get_operand(0); } std::string statename = root->get_token().get_text(); int index = sm->get_state_by_name(statename); if (index < 0) { throw Exception(root->get_location(), "unknown state: " + statename); } states.set(index); }