/*************************************************************** Function: main **************************************************************/ public static void main ( string[] arg ) { CLexGen lg; if (arg.Length < 1) { System.Console.WriteLine("Usage: JLex.Main <filename>"); return; } /* Note: For debuging, it may be helpful to remove the try/catch block and permit the Exception to propagate to the top level. This gives more information. */ try { lg = new CLexGen(arg[0]); lg.generate(); } catch (System.Exception e) { System.Console.WriteLine(e.Message); } }
/*************************************************************** * Function: main **************************************************************/ public static void Main ( string[] arg ) { CLexGen lg; //arg=new string[]{"c:\\minimal.lex"}; if (arg.Length < 1) { System.Console.WriteLine("Usage: JLex.Main <filename>"); return; } /* Note: For debuging, it may be helpful to remove the try/catch * block and permit the Exception to propagate to the top level. * This gives more information. */ /* try * {*/ lg = new CLexGen(arg[0]); lg.generate(); /* } * catch (System.Exception e) * { * System.Console.WriteLine(e.Message); * }*/ }
/*************************************************************** * Function: reset * Description: Resets CMakeNfa member variables. **************************************************************/ private void reset ( ) { m_input = null; m_lexGen = null; m_spec = null; }
/*************************************************************** * Function: reset * Description: **************************************************************/ private void reset ( ) { m_lexGen = null; m_spec = null; m_unmarked_dfa = 0; }
/*************************************************************** * Function: Set * Description: **************************************************************/ private void Set ( CLexGen lexGen, CSpec spec ) { m_lexGen = lexGen; m_spec = spec; m_unmarked_dfa = 0; }
/*************************************************************** * 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 (CUtility.DEBUG) { CUtility.ASSERT(null != input); CUtility.ASSERT(null != lexGen); CUtility.ASSERT(null != spec); } m_input = input; m_lexGen = lexGen; m_spec = spec; }
/*************************************************************** * Function: main **************************************************************/ public static int Main ( string[] arg ) { Console.WriteLine("cs_lex {0}", string.Join(" ", arg)); #if !DEBUG try { #endif CLexGen lg; if (arg.Length < 1) { Console.WriteLine("Usage: JLex.Main <filename>"); return(1); } string outfile = arg[0] + ".cs"; if (File.GetLastWriteTime(typeof(CS_Lex).Assembly.Location) > File.GetLastWriteTime(outfile)) { } else if (File.Exists(outfile) && new FileInfo(outfile).Length > 0) { if (File.GetLastWriteTime(arg[0]) < File.GetLastWriteTime(outfile)) { return(0); } } lg = new CLexGen(arg[0]); lg.generate(); #if !DEBUG } catch (Exception ex) { Console.Error.WriteLine(ex.Message); return(1); } #endif return(0); }
/*************************************************************** * Function: make_dfa * Description: High-level access function to module. **************************************************************/ public void make_dfa ( CLexGen lexGen, CSpec spec ) { // int i; reset(); Set(lexGen, spec); make_dtrans(); free_nfa_states(); if (m_spec.m_verbose && true == CUtility.OLD_DUMP_DEBUG) { System.Console.WriteLine(m_spec.m_dfa_states.size() + " DFA states in original machine."); } free_dfa_states(); }
/*************************************************************** * Function: CSpec * Description: Constructor. **************************************************************/ public CSpec ( CLexGen lexGen ) { m_lexGen = lexGen; /* Initialize regular expression token variables. */ m_current_token = CLexGen.EOS; m_lexeme = '\0'; m_in_quote = false; m_in_ccl = false; /* Initialize hashtable for lexer states. */ m_states = new Hashtable(); m_states.Add("YYINITIAL", m_states.Count); /* Initialize hashtable for lexical macros. */ m_macros = new Hashtable(); /* Initialize variables for lexer options. */ m_integer_type = false; m_intwrap_type = false; m_count_lines = false; m_count_chars = false; m_cup_compatible = false; m_unix = true; m_public = false; m_yyeof = false; m_ignorecase = false; /* Initialize variables for JLex runtime options. */ m_verbose = true; m_nfa_start = null; m_nfa_states = new Vector(); m_dfa_states = new Vector(); m_dfa_sets = new Hashtable(); m_dtrans_vector = new Vector(); m_dtrans_ncols = CUtility.MAX_SEVEN_BIT + 1; m_row_map = null; m_col_map = null; m_accept_vector = null; m_anchor_array = null; m_init_code = null; m_init_read = 0; m_init_throw_code = null; m_init_throw_read = 0; m_yylex_throw_code = null; m_yylex_throw_read = 0; m_class_code = null; m_class_read = 0; m_eof_code = null; m_eof_read = 0; m_eof_value_code = null; m_eof_value_read = 0; m_eof_throw_code = null; m_eof_throw_read = 0; m_state_dtrans = null; m_state_rules = null; }