/*************************************************************** * Function: reset * Description: Resets CMakeNfa member variables. **************************************************************/ private void reset ( ) { m_input = null; m_lexGen = null; m_spec = null; }
/*************************************************************** * Function: thompson * Description: High level access function to module. * Deposits result in input CSpec. **************************************************************/ public void thompson ( CLexGen lexGen, CSpec spec, CInput input ) { int i; CNfa elem; int size; /* Set member variables. */ reset(); Set(lexGen, spec, input); size = m_spec.m_states.Count; m_spec.m_state_rules = new Vector[size]; for (i = 0; i < size; ++i) { m_spec.m_state_rules[i] = new Vector(); } /* Initialize current token variable * and create nfa. */ /*m_spec.m_current_token = m_lexGen.EOS; * m_lexGen.advance();*/ m_spec.m_nfa_start = machine(); /* Set labels in created nfa machine. */ size = m_spec.m_nfa_states.size(); for (i = 0; i < size; ++i) { elem = (CNfa)m_spec.m_nfa_states.elementAt(i); elem.m_label = i; } /* Debugging output. */ #if (DO_DEBUG) { m_lexGen.print_nfa(); } #endif if (m_spec.m_verbose) { System.Console.WriteLine("NFA comprised of " + (m_spec.m_nfa_states.Count + 1) + " states."); } reset(); }
/*************************************************************** * Function: Set * Description: Sets CMakeNfa member variables. **************************************************************/ private void Set ( CLexGen lexGen, CSpec spec, CInput input ) { #if (DEBUG) { CUtility.ASSERT(null != input); CUtility.ASSERT(null != lexGen); CUtility.ASSERT(null != spec); } #endif m_input = input; m_lexGen = lexGen; m_spec = spec; }