📄 lexgen.java
字号:
} if (hasMore) { if (hasMoreActions) ostr.println(prefix + " MoreLexicalActions();"); else if (hasSkipActions || hasTokenActions) ostr.println(prefix + " jjimageLen += jjmatchedPos + 1;"); if (maxLexStates > 1) { ostr.println(" if (jjnewLexState[jjmatchedKind] != -1)"); ostr.println(prefix + " curLexState = jjnewLexState[jjmatchedKind];"); } ostr.println(prefix + " curPos = 0;"); ostr.println(prefix + " jjmatchedKind = 0x" + Integer.toHexString(Integer.MAX_VALUE) + ";"); ostr.println(prefix + " try {"); ostr.println(prefix + " curChar = input_stream.readChar();"); if (Options.B("DEBUG_TOKEN_MANAGER")) ostr.println(" debugStream.println(" + (maxLexStates > 1 ? "\"<\" + lexStateNames[curLexState] + \">\" + " : "") + "\"Current character : \" + " + "TokenMgrError.addEscapes(String.valueOf(curChar)) + \" (\" + (int)curChar + \")\");"); ostr.println(prefix + " continue;"); ostr.println(prefix + " }"); ostr.println(prefix + " catch (java.io.IOException e1) { }"); } } ostr.println(prefix + " }"); ostr.println(prefix + " int error_line = input_stream.getEndLine();"); ostr.println(prefix + " int error_column = input_stream.getEndColumn();"); ostr.println(prefix + " String error_after = null;"); ostr.println(prefix + " boolean EOFSeen = false;"); ostr.println(prefix + " try { input_stream.readChar(); input_stream.backup(1); }"); ostr.println(prefix + " catch (java.io.IOException e1) {"); ostr.println(prefix + " EOFSeen = true;"); ostr.println(prefix + " error_after = curPos <= 1 ? \"\" : input_stream.GetImage();"); ostr.println(prefix + " if (curChar == '\\n' || curChar == '\\r') {"); ostr.println(prefix + " error_line++;"); ostr.println(prefix + " error_column = 0;"); ostr.println(prefix + " }"); ostr.println(prefix + " else"); ostr.println(prefix + " error_column++;"); ostr.println(prefix + " }"); ostr.println(prefix + " if (!EOFSeen) {"); ostr.println(prefix + " input_stream.backup(1);"); ostr.println(prefix + " error_after = curPos <= 1 ? \"\" : input_stream.GetImage();"); ostr.println(prefix + " }"); ostr.println(prefix + " throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);"); } if (hasMore) ostr.println(prefix + " }"); ostr.println(" }"); ostr.println("}"); ostr.println(""); } public static void DumpSkipActions() { Action act; ostr.println(staticString + "void SkipLexicalActions(Token matchedToken)"); ostr.println("{"); ostr.println(" switch(jjmatchedKind)"); ostr.println(" {"); Outer: for (int i = 0; i < maxOrdinal; i++) { if ((toSkip[i / 64] & (1L << (i % 64))) == 0L) continue; for (;;) { if (((act = (Action)actions[i]) == null || act.action_tokens == null || act.action_tokens.size() == 0) && !canLoop[lexStates[i]]) continue Outer; ostr.println(" case " + i + " :"); if (initMatch[lexStates[i]] == i && canLoop[lexStates[i]]) { ostr.println(" if (jjmatchedPos == -1)"); ostr.println(" {"); ostr.println(" if (jjbeenHere[" + lexStates[i] + "] &&"); ostr.println(" jjemptyLineNo[" + lexStates[i] + "] == input_stream.getBeginLine() && "); ostr.println(" jjemptyColNo[" + lexStates[i] + "] == input_stream.getBeginColumn())"); ostr.println(" throw new TokenMgrError((\"Error: Bailing out of infinite loop caused by repeated empty string matches at line \" + input_stream.getBeginLine() + \", column \" + input_stream.getBeginColumn() + \".\"), TokenMgrError.LOOP_DETECTED);"); ostr.println(" jjemptyLineNo[" + lexStates[i] + "] = input_stream.getBeginLine();"); ostr.println(" jjemptyColNo[" + lexStates[i] + "] = input_stream.getBeginColumn();"); ostr.println(" jjbeenHere[" + lexStates[i] + "] = true;"); ostr.println(" }"); } if ((act = (Action)actions[i]) == null || act.action_tokens.size() == 0) break; ostr.println(" if (image == null)"); ostr.print(" image = "); if (RStringLiteral.allImages[i] != null) ostr.println("new StringBuffer(jjstrLiteralImages[" + i + "]);"); else { if (Options.B("JAVA_UNICODE_ESCAPE") || Options.B("USER_CHAR_STREAM")) ostr.println("new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));"); else ostr.println("new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));"); } ostr.println(" else"); ostr.print(" image.append"); if (RStringLiteral.allImages[i] != null) ostr.println("(jjstrLiteralImages[" + i + "]);"); else if (Options.B("JAVA_UNICODE_ESCAPE") || Options.B("USER_CHAR_STREAM")) ostr.println("(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1)));"); else ostr.println("(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));"); printTokenSetup((Token)act.action_tokens.elementAt(0)); ccol = 1; for (int j = 0; j < act.action_tokens.size(); j++) printToken((Token)act.action_tokens.elementAt(j), ostr); ostr.println(""); break; } ostr.println(" break;"); } ostr.println(" default :"); ostr.println(" break;"); ostr.println(" }"); ostr.println("}"); } public static void DumpMoreActions() { Action act; ostr.println(staticString + "void MoreLexicalActions()"); ostr.println("{"); ostr.println(" jjimageLen += (lengthOfMatch = jjmatchedPos + 1);"); ostr.println(" switch(jjmatchedKind)"); ostr.println(" {"); Outer: for (int i = 0; i < maxOrdinal; i++) { if ((toMore[i / 64] & (1L << (i % 64))) == 0L) continue; for (;;) { if (((act = (Action)actions[i]) == null || act.action_tokens == null || act.action_tokens.size() == 0) && !canLoop[lexStates[i]]) continue Outer; ostr.println(" case " + i + " :"); if (initMatch[lexStates[i]] == i && canLoop[lexStates[i]]) { ostr.println(" if (jjmatchedPos == -1)"); ostr.println(" {"); ostr.println(" if (jjbeenHere[" + lexStates[i] + "] &&"); ostr.println(" jjemptyLineNo[" + lexStates[i] + "] == input_stream.getBeginLine() && "); ostr.println(" jjemptyColNo[" + lexStates[i] + "] == input_stream.getBeginColumn())"); ostr.println(" throw new TokenMgrError((\"Error: Bailing out of infinite loop caused by repeated empty string matches at line \" + input_stream.getBeginLine() + \", column \" + input_stream.getBeginColumn() + \".\"), TokenMgrError.LOOP_DETECTED);"); ostr.println(" jjemptyLineNo[" + lexStates[i] + "] = input_stream.getBeginLine();"); ostr.println(" jjemptyColNo[" + lexStates[i] + "] = input_stream.getBeginColumn();"); ostr.println(" jjbeenHere[" + lexStates[i] + "] = true;"); ostr.println(" }"); } if ((act = (Action)actions[i]) == null || act.action_tokens.size() == 0) { break; } ostr.println(" if (image == null)"); ostr.print(" image = "); if (RStringLiteral.allImages[i] != null) ostr.println("new StringBuffer(jjstrLiteralImages[" + i + "]);"); else { if (Options.B("JAVA_UNICODE_ESCAPE") || Options.B("USER_CHAR_STREAM")) ostr.println("new StringBuffer(new String(input_stream.GetSuffix(jjimageLen)));"); else ostr.println("new StringBuffer(new String(input_stream.GetSuffix(jjimageLen)));"); } ostr.println(" else"); ostr.print(" image.append"); if (RStringLiteral.allImages[i] != null) ostr.println("(jjstrLiteralImages[" + i + "]);"); else if (Options.B("JAVA_UNICODE_ESCAPE") || Options.B("USER_CHAR_STREAM")) ostr.println("(input_stream.GetSuffix(jjimageLen));"); else ostr.println("(new String(input_stream.GetSuffix(jjimageLen)));"); ostr.println(" jjimageLen = 0;"); printTokenSetup((Token)act.action_tokens.elementAt(0)); ccol = 1; for (int j = 0; j < act.action_tokens.size(); j++) printToken((Token)act.action_tokens.elementAt(j), ostr); ostr.println(""); break; } ostr.println(" break;"); } ostr.println(" default : "); ostr.println(" break;"); ostr.println(" }"); ostr.println("}"); } public static void DumpTokenActions() { Action act; int i; boolean initPrinted[] = new boolean[maxLexStates]; ostr.println(staticString + "void TokenLexicalActions(Token matchedToken)"); ostr.println("{"); ostr.println(" switch(jjmatchedKind)"); ostr.println(" {"); Outer: for (i = 0; i < maxOrdinal; i++) { if ((toToken[i / 64] & (1L << (i % 64))) == 0L) continue; for (;;) { if (((act = (Action)actions[i]) == null || act.action_tokens == null || act.action_tokens.size() == 0) && !canLoop[lexStates[i]]) continue Outer; ostr.println(" case " + i + " :"); initPrinted[lexStates[i]] = true; if (initMatch[lexStates[i]] == i && canLoop[lexStates[i]]) { ostr.println(" if (jjmatchedPos == -1)"); ostr.println(" {"); ostr.println(" if (jjbeenHere[" + lexStates[i] + "] &&"); ostr.println(" jjemptyLineNo[" + lexStates[i] + "] == input_stream.getBeginLine() && "); ostr.println(" jjemptyColNo[" + lexStates[i] + "] == input_stream.getBeginColumn())"); ostr.println(" throw new TokenMgrError((\"Error: Bailing out of infinite loop caused by repeated empty string matches at line \" + input_stream.getBeginLine() + \", column \" + input_stream.getBeginColumn() + \".\"), TokenMgrError.LOOP_DETECTED);"); ostr.println(" jjemptyLineNo[" + lexStates[i] + "] = input_stream.getBeginLine();"); ostr.println(" jjemptyColNo[" + lexStates[i] + "] = input_stream.getBeginColumn();"); ostr.println(" jjbeenHere[" + lexStates[i] + "] = true;"); ostr.println(" }"); } if ((act = (Action)actions[i]) == null || act.action_tokens.size() == 0) break; if (i == 0) { ostr.println(" image = null;"); // For EOF no image is there } else { ostr.println(" if (image == null)"); ostr.print(" image = "); if (RStringLiteral.allImages[i] != null) ostr.println("new StringBuffer(jjstrLiteralImages[" + i + "]);"); else { if (Options.B("JAVA_UNICODE_ESCAPE") || Options.B("USER_CHAR_STREAM")) ostr.println("new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));"); else ostr.println("new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));"); } ostr.println(" else"); ostr.print(" image.append"); if (RStringLiteral.allImages[i] != null) ostr.println("(jjstrLiteralImages[" + i + "]);"); else if (Options.B("JAVA_UNICODE_ESCAPE") || Options.B("USER_CHAR_STREAM")) ostr.println("(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1)));"); else ostr.println("(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));"); } printTokenSetup((Token)act.action_tokens.elementAt(0)); ccol = 1; for (int j = 0; j < act.action_tokens.size(); j++) printToken((Token)act.action_tokens.elementAt(j), ostr); ostr.println(""); break; } ostr.println(" break;"); } ostr.println(" default : "); ostr.println(" break;"); ostr.println(" }"); ostr.println("}"); } public static void reInit() { ostr = null; staticString = null; tokMgrClassName = null; allTpsForState = new Hashtable(); lexStateIndex = 0; kinds = null; maxOrdinal = 1; lexStateSuffix = null; newLexState = null; lexStates = null; ignoreCase = null; actions = null; initStates = new Hashtable(); stateSetSize = (int)0; maxLexStates = (int)0; lexStateName = null; singlesToSkip = null; toSkip = null; toSpecial = null; toMore = null; toToken = null; defaultLexState = (int)0; rexprs = null; maxLongsReqd = null; initMatch = null; canMatchAnyChar = null; hasEmptyMatch = false; canLoop = null; stateHasActions = null; hasLoop = false; canReachOnMore = null; hasNfa = null; mixed = null; initialState = null; curKind = (int)0; hasSkipActions = false; hasMoreActions = false; hasTokenActions = false; hasSpecial = false; hasSkip = false; hasMore = false; hasToken = false; curRE = null; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -