📄 main.java
字号:
} if (m_spec.m_count_lines) { m_outstream.println("\t\tyyline = 0;"); } m_outstream.println("\t\tyy_at_bol = true;"); m_outstream.println("\t\tyy_lexical_state = YYINITIAL;"); /*if (m_spec.m_count_lines || true == m_spec.m_count_chars) { m_outstream.println("\t\tyy_buffer_prev_start = 0;"); }*/ /* User specified constructor code. */ if (null != m_spec.m_init_code) { m_outstream.print(new String(m_spec.m_init_code,0, m_spec.m_init_read)); } m_outstream.println("\t}"); m_outstream.println(); } /*************************************************************** Function: emit_states Description: Emits constants that serve as lexical states, including YYINITIAL. **************************************************************/ private void emit_states ( ) throws java.io.IOException { Enumeration states; String state; int index; states = m_spec.m_states.keys(); /*index = 0;*/ while (states.hasMoreElements()) { state = (String) states.nextElement(); if (CUtility.DEBUG) { CUtility.assert(null != state); } m_outstream.println("\tprivate final int " + state + " = " + (m_spec.m_states.get(state)).toString() + ";"); /*++index;*/ } m_outstream.println("\tprivate final int yy_state_dtrans[] = {"); for (index = 0; index < m_spec.m_state_dtrans.length; ++index) { m_outstream.print("\t\t" + m_spec.m_state_dtrans[index]); if (index < m_spec.m_state_dtrans.length - 1) { m_outstream.println(","); } else { m_outstream.println(); } } m_outstream.println("\t};"); } /*************************************************************** Function: emit_helpers Description: Emits helper functions, particularly error handling and input buffering. **************************************************************/ private void emit_helpers ( ) throws java.io.IOException { if (CUtility.DEBUG) { CUtility.assert(null != m_spec); CUtility.assert(null != m_outstream); } /* Function: yy_do_eof */ m_outstream.println("\tprivate boolean yy_eof_done = false;"); if (null != m_spec.m_eof_code) { m_outstream.print("\tprivate void yy_do_eof ()"); if (null != m_spec.m_eof_throw_code) { m_outstream.println(); m_outstream.print("\t\tthrows "); m_outstream.println(new String(m_spec.m_eof_throw_code,0, m_spec.m_eof_throw_read)); m_outstream.println("\t\t{"); } else { m_outstream.println(" {"); } m_outstream.println("\t\tif (false == yy_eof_done) {"); m_outstream.print(new String(m_spec.m_eof_code,0, m_spec.m_eof_read)); m_outstream.println("\t\t}"); m_outstream.println("\t\tyy_eof_done = true;"); m_outstream.println("\t}"); } emit_states(); /* Function: yybegin */ m_outstream.println("\tprivate void yybegin (int state) {"); m_outstream.println("\t\tyy_lexical_state = state;"); m_outstream.println("\t}"); /* Function: yy_initial_dtrans */ /*m_outstream.println("\tprivate int yy_initial_dtrans (int state) {"); m_outstream.println("\t\treturn yy_state_dtrans[state];"); m_outstream.println("\t}");*/ /* Function: yy_advance */ m_outstream.println("\tprivate int yy_advance ()"); m_outstream.println("\t\tthrows java.io.IOException {"); /*m_outstream.println("\t\t{");*/ m_outstream.println("\t\tint next_read;"); m_outstream.println("\t\tint i;"); m_outstream.println("\t\tint j;"); m_outstream.println(); m_outstream.println("\t\tif (yy_buffer_index < yy_buffer_read) {"); m_outstream.println("\t\t\treturn yy_buffer[yy_buffer_index++];"); /*m_outstream.println("\t\t\t++yy_buffer_index;");*/ m_outstream.println("\t\t}"); m_outstream.println(); m_outstream.println("\t\tif (0 != yy_buffer_start) {"); m_outstream.println("\t\t\ti = yy_buffer_start;"); m_outstream.println("\t\t\tj = 0;"); m_outstream.println("\t\t\twhile (i < yy_buffer_read) {"); m_outstream.println("\t\t\t\tyy_buffer[j] = yy_buffer[i];"); m_outstream.println("\t\t\t\t++i;"); m_outstream.println("\t\t\t\t++j;"); m_outstream.println("\t\t\t}"); m_outstream.println("\t\t\tyy_buffer_end = yy_buffer_end - yy_buffer_start;"); m_outstream.println("\t\t\tyy_buffer_start = 0;"); m_outstream.println("\t\t\tyy_buffer_read = j;"); m_outstream.println("\t\t\tyy_buffer_index = j;"); m_outstream.println("\t\t\tnext_read = yy_reader.read(yy_buffer,"); m_outstream.println("\t\t\t\t\tyy_buffer_read,"); m_outstream.println("\t\t\t\t\tyy_buffer.length - yy_buffer_read);"); m_outstream.println("\t\t\tif (-1 == next_read) {"); m_outstream.println("\t\t\t\treturn YY_EOF;"); m_outstream.println("\t\t\t}"); m_outstream.println("\t\t\tyy_buffer_read = yy_buffer_read + next_read;"); m_outstream.println("\t\t}"); m_outstream.println(); m_outstream.println("\t\twhile (yy_buffer_index >= yy_buffer_read) {"); m_outstream.println("\t\t\tif (yy_buffer_index >= yy_buffer.length) {"); m_outstream.println("\t\t\t\tyy_buffer = yy_double(yy_buffer);"); m_outstream.println("\t\t\t}"); m_outstream.println("\t\t\tnext_read = yy_reader.read(yy_buffer,"); m_outstream.println("\t\t\t\t\tyy_buffer_read,"); m_outstream.println("\t\t\t\t\tyy_buffer.length - yy_buffer_read);"); m_outstream.println("\t\t\tif (-1 == next_read) {"); m_outstream.println("\t\t\t\treturn YY_EOF;"); m_outstream.println("\t\t\t}"); m_outstream.println("\t\t\tyy_buffer_read = yy_buffer_read + next_read;"); m_outstream.println("\t\t}"); m_outstream.println("\t\treturn yy_buffer[yy_buffer_index++];"); m_outstream.println("\t}"); /* Function: yy_move_end */ m_outstream.println("\tprivate void yy_move_end () {"); m_outstream.println("\t\tif (yy_buffer_end > yy_buffer_start &&"); m_outstream.println("\t\t '\\n' == yy_buffer[yy_buffer_end-1])"); m_outstream.println("\t\t\tyy_buffer_end--;"); m_outstream.println("\t\tif (yy_buffer_end > yy_buffer_start &&"); m_outstream.println("\t\t '\\r' == yy_buffer[yy_buffer_end-1])"); m_outstream.println("\t\t\tyy_buffer_end--;"); m_outstream.println("\t}"); /* Function: yy_mark_start */ m_outstream.println("\tprivate boolean yy_last_was_cr=false;"); m_outstream.println("\tprivate void yy_mark_start () {"); if (m_spec.m_count_lines || true == m_spec.m_count_chars) { if (m_spec.m_count_lines) { m_outstream.println("\t\tint i;"); m_outstream.println("\t\tfor (i = yy_buffer_start; " + "i < yy_buffer_index; ++i) {"); m_outstream.println("\t\t\tif ('\\n' == yy_buffer[i] && !yy_last_was_cr) {"); m_outstream.println("\t\t\t\t++yyline;"); m_outstream.println("\t\t\t}"); m_outstream.println("\t\t\tif ('\\r' == yy_buffer[i]) {"); m_outstream.println("\t\t\t\t++yyline;"); m_outstream.println("\t\t\t\tyy_last_was_cr=true;"); m_outstream.println("\t\t\t} else yy_last_was_cr=false;"); m_outstream.println("\t\t}"); } if (m_spec.m_count_chars) { m_outstream.println("\t\tyychar = yychar"); m_outstream.println("\t\t\t+ yy_buffer_index - yy_buffer_start;"); } } m_outstream.println("\t\tyy_buffer_start = yy_buffer_index;"); m_outstream.println("\t}"); /* Function: yy_mark_end */ m_outstream.println("\tprivate void yy_mark_end () {"); m_outstream.println("\t\tyy_buffer_end = yy_buffer_index;"); m_outstream.println("\t}"); /* Function: yy_to_mark */ m_outstream.println("\tprivate void yy_to_mark () {"); m_outstream.println("\t\tyy_buffer_index = yy_buffer_end;"); m_outstream.println("\t\tyy_at_bol = "+ "(yy_buffer_end > yy_buffer_start) &&"); m_outstream.println("\t\t "+ "('\\r' == yy_buffer[yy_buffer_end-1] ||"); m_outstream.println("\t\t "+ " '\\n' == yy_buffer[yy_buffer_end-1] ||"); m_outstream.println("\t\t "+ /* unicode LS */ " 2028/*LS*/ == yy_buffer[yy_buffer_end-1] ||"); m_outstream.println("\t\t "+ /* unicode PS */ " 2029/*PS*/ == yy_buffer[yy_buffer_end-1]);"); m_outstream.println("\t}"); /* Function: yytext */ m_outstream.println("\tprivate java.lang.String yytext () {"); m_outstream.println("\t\treturn (new java.lang.String(yy_buffer,"); m_outstream.println("\t\t\tyy_buffer_start,"); m_outstream.println("\t\t\tyy_buffer_end - yy_buffer_start));"); m_outstream.println("\t}"); /* Function: yylength */ m_outstream.println("\tprivate int yylength () {"); m_outstream.println("\t\treturn yy_buffer_end - yy_buffer_start;"); m_outstream.println("\t}"); /* Function: yy_double */ m_outstream.println("\tprivate char[] yy_double (char buf[]) {"); m_outstream.println("\t\tint i;"); m_outstream.println("\t\tchar newbuf[];"); m_outstream.println("\t\tnewbuf = new char[2*buf.length];"); m_outstream.println("\t\tfor (i = 0; i < buf.length; ++i) {"); m_outstream.println("\t\t\tnewbuf[i] = buf[i];"); m_outstream.println("\t\t}"); m_outstream.println("\t\treturn newbuf;"); m_outstream.println("\t}"); /* Function: yy_error */ m_outstream.println("\tprivate final int YY_E_INTERNAL = 0;"); m_outstream.println("\tprivate final int YY_E_MATCH = 1;"); m_outstream.println("\tprivate java.lang.String yy_error_string[] = {"); m_outstream.println("\t\t\"Error: Internal error.\\n\","); m_outstream.println("\t\t\"Error: Unmatched input.\\n\""); m_outstream.println("\t};"); m_outstream.println("\tprivate void yy_error (int code,boolean fatal) {"); m_outstream.println("\t\tjava.lang.System.out.print(yy_error_string[code]);"); m_outstream.println("\t\tjava.lang.System.out.flush();"); m_outstream.println("\t\tif (fatal) {"); m_outstream.println("\t\t\tthrow new Error(\"Fatal Error.\\n\");"); m_outstream.println("\t\t}"); m_outstream.println("\t}"); /* Function: yy_next */ /*m_outstream.println("\tprivate int yy_next (int current,char lookahead) {"); m_outstream.println("\t\treturn yy_nxt[yy_rmap[current]][yy_cmap[lookahead]];"); m_outstream.println("\t}");*/ /* Function: yy_accept */ /*m_outstream.println("\tprivate int yy_accept (int current) {"); m_outstream.println("\t\treturn yy_acpt[current];"); m_outstream.println("\t}");*/ // Function: private int [][] unpackFromString(int size1, int size2, String st) // Added 6/24/98 Raimondas Lencevicius // May be made more efficient by replacing String operations // Assumes correctly formed input String. Performs no error checking m_outstream.println("\tprivate int[][] unpackFromString"+ "(int size1, int size2, String st) {"); m_outstream.println("\t\tint colonIndex = -1;"); m_outstream.println("\t\tString lengthString;"); m_outstream.println("\t\tint sequenceLength = 0;"); m_outstream.println("\t\tint sequenceInteger = 0;"); m_outstream.println(); m_outstream.println("\t\tint commaIndex;"); m_outstream.println("\t\tString workString;"); m_outstream.println(); m_outstream.println("\t\tint res[][] = new int[size1][size2];"); m_outstream.println("\t\tfor (int i= 0; i < size1; i++) {"); m_outstream.println("\t\t\tfor (int j= 0; j < size2; j++) {"); m_outstream.println("\t\t\t\tif (sequenceLength != 0) {"); m_outstream.println("\t\t\t\t\tres[i][j] = sequenceInteger;"); m_outstream.println("\t\t\t\t\tsequenceLength--;"); m_outstream.println("\t\t\t\t\tcontinue;"); m_outstream.println("\t\t\t\t}"); m_outstream.println("\t\t\t\tcommaIndex = st.indexOf(',');"); m_outstream.println("\t\t\t\tworkString = (commaIndex==-1) ? st :"); m_outstream.println("\t\t\t\t\tst.substring(0, commaIndex);"); m_outstream.println("\t\t\t\tst = st.substring(commaIndex+1);"); m_outstream.println("\t\t\t\tcolonIndex = workString.indexOf(':');"); m_outstream.println("\t\t\t\tif (colonIndex == -1) {"); m_outstream.println("\t\t\t\t\tres[i][j]=Integer.parseInt(workString);"); m_outstream.println("\t\t\t\t\tcontinue;"); m_outstream.println("\t\t\t\t}"); m_outstream.println("\t\t\t\tlengthString ="); m_outstream.println("\t\t\t\t\tworkString.substring(colonIndex+1);"); m_outstream.println("\t\t\t\tsequenceLength="+ "Integer.parseInt(lengthString);"); m_outstream.println("\t\t\t\tworkString="+ "workString.substring(0,colonIndex);"); m_outstream.println("\t\t\t\tsequenceInteger="+ "Integer.parseInt(workString);"); m_outstream.println("\t\t\t\tres[i][j] = sequenceInteger;"); m_outstream.println("\t\t\t\tsequenceLength--;"); m_outstream.println("\t\t\t}"); m_outstream.println("\t\t}"); m_outstream.println("\t\treturn res;"); m_outstream.println("\t}"); } /*************************************************************** Function: emit_header Description: Emits class header. **************************************************************/ private void emit_header ( ) throws java.io.IOException { if (CUtility.DEBUG) { CUtility.assert(null != m_spec); CUtility.assert(null != m_outstream); } m_outstream.println(); m_outstream.println(); if (true == m_spec.m_public) { m_outstream.print("public "); } m_outstream.print("class "); m_outstream.print(new String(m_spec.m_class_name,0, m_spec.m_class_name.length)); if (m_spec.m_implements_name.length > 0) { m_outstream.print(" implements "); m_outstream.print(new String(m_spec.m_implements_name,0, m_spec.m_implements_name.length)); } m_outstream.println(" {"); } /*************************************************************** Function: emit_table Description: Emits transition table. **************************************************************/ private void emit_table ( ) throws java.io.IOException { int i; int elem; int size; CDTrans dtrans; boolean is_start; boolean is_end; CAccept accept; if (CUtility.DEBUG) { CUtility.assert(null != m_spec); CUtility.assert(null != m_outstream); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -