public static void start() throws MetaParseException { Token t = null; if (JavaCCErrors.get_error_count() != 0) throw new MetaParseException(); if (Options.getBuildParser()) { try { ostr = new PrintWriter( new BufferedWriter( new FileWriter(new File(Options.getOutputDirectory(), cu_name + ".java")), 8192)); } catch (IOException e) { JavaCCErrors.semantic_error("Could not open file " + cu_name + ".java for writing."); throw new Error(); } List tn = new ArrayList(toolNames); tn.add(toolName); ostr.println("/* " + getIdString(tn, cu_name + ".java") + " */"); boolean implementsExists = false; if (cu_to_insertion_point_1.size() != 0) { boolean printImports = true; printTokenSetup((Token) (cu_to_insertion_point_1.get(0))); ccol = 1; for (Iterator it = cu_to_insertion_point_1.iterator(); it.hasNext(); ) { t = (Token) it.next(); if (printImports && (t.kind == PUBLIC || t.kind == CLASS)) { printImports = false; ostr.println(""); ostr.println("import com.intellij.psi.tree.IElementType;"); ostr.println("import com.intellij.lang.PsiBuilder;"); ostr.println("import java.util.ArrayList;"); } if (t.kind == IMPLEMENTS) { implementsExists = true; } else if (t.kind == CLASS) { implementsExists = false; } printToken(t, ostr); } } if (implementsExists) { ostr.print(", "); } else { ostr.print(" implements "); } ostr.print(cu_name + "Constants "); if (cu_to_insertion_point_2.size() != 0) { printTokenSetup((Token) (cu_to_insertion_point_2.get(0))); for (Iterator it = cu_to_insertion_point_2.iterator(); it.hasNext(); ) { t = (Token) it.next(); printToken(t, ostr); } } ostr.println(""); ostr.println(""); ParseEngine.build(ostr); ostr.println(" private final PsiBuilder builder;"); ostr.println(" public " + cu_name + "(PsiBuilder builder) {"); ostr.println(" this.builder = builder;"); ostr.println(" }"); if (jj2index != 0) { ostr.println(" " + staticOpt() + "private int jj_la;"); ostr.println( " " + staticOpt() + "private ArrayList<IElementType> tokens = new ArrayList<IElementType>();"); ostr.println(" " + staticOpt() + "private int currentIndex = 0;"); ostr.println(" " + staticOpt() + "private int maxIndex = 0;"); if (lookaheadNeeded) { ostr.println(" /** Whether we are looking ahead. */"); ostr.println(" " + staticOpt() + "private boolean jj_lookingAhead = false;"); ostr.println(" " + staticOpt() + "private boolean jj_semLA;"); } } ostr.println(""); ostr.println(" " + staticOpt() + "private void rollbackTo(int scanpos) {"); ostr.println(" currentIndex = scanpos;"); ostr.println(" }"); ostr.println(" " + staticOpt() + "private void init(int la) {"); ostr.println(" jj_la = la;"); ostr.println(" tokens.clear();"); ostr.println(" tokens.add(builder.getTokenType());"); ostr.println(" currentIndex = 0;"); ostr.println(" maxIndex = 0;"); ostr.println(" }"); ostr.println( " " + staticOpt() + "private IElementType jj_consume_token(IElementType type) {"); ostr.println(" IElementType actualType = builder.getTokenType();"); ostr.println(" if (actualType == type) {"); ostr.println(" builder.advanceLexer();"); ostr.println(" } else {"); ostr.println(" builder.error(\"Expected \" + type + \", but get: \" + actualType);"); if (!Options.getAutomaticErrorRecovery()) ostr.println(" throw new ParseException();"); ostr.println(" }"); ostr.println(" return type;"); ostr.println(" }"); ostr.println(""); if (jj2index != 0) { ostr.println(" static private final class LookaheadSuccess extends java.lang.Error { }"); ostr.println( " " + staticOpt() + "final private LookaheadSuccess jj_ls = new LookaheadSuccess();"); ostr.println(" " + staticOpt() + "private void jj_on_la1() {"); ostr.println(" advanceLexer();"); ostr.println(" jj_test_jj_la();"); ostr.println(" }"); ostr.println(""); ostr.println(" " + staticOpt() + "private void jj_test_jj_la() {"); ostr.println(" if (jj_la == 0 && maxIndex == currentIndex)"); ostr.println(" throw jj_ls;"); ostr.println(" }"); ostr.println(""); ostr.println(" " + staticOpt() + "private IElementType advanceLexer() {"); ostr.println(" if (maxIndex == currentIndex) {"); ostr.println(" IElementType result = tokens.get(currentIndex);"); ostr.println(" builder.advanceLexer();"); ostr.println(" tokens.add(builder.getTokenType());"); ostr.println(" maxIndex++;"); ostr.println(" currentIndex++;"); ostr.println(" jj_la--;"); ostr.println(" return result;"); ostr.println(" }"); ostr.println(" return tokens.get(currentIndex++);"); ostr.println(" }"); ostr.println(""); ostr.println(" " + staticOpt() + "private boolean jj_scan_token(IElementType kind) {"); ostr.println(" IElementType nextType = advanceLexer();"); ostr.println(" if (nextType != kind) return true;"); ostr.println(" jj_test_jj_la();"); ostr.println(" return false;"); ostr.println(" }"); ostr.println(""); } ostr.println(""); ostr.println("/** Get the next Token. Use getNextTokenType instead. "); ostr.println(" " + staticOpt() + "final public Token getNextToken() {"); if (Options.getCacheTokens()) { ostr.println(" if ((token = jj_nt).next != null) jj_nt = jj_nt.next;"); ostr.println(" else jj_nt = jj_nt.next = token_source.getNextToken();"); } else { ostr.println(" if (token.next != null) token = token.next;"); ostr.println(" else token = token.next = token_source.getNextToken();"); ostr.println(" jj_ntk = -1;"); } if (Options.getErrorReporting()) { ostr.println(" jj_gen++;"); } if (Options.getDebugParser()) { ostr.println(" trace_token(token, \" (in getNextToken)\");"); } ostr.println(" return token;"); ostr.println(" } */"); ostr.println(""); ostr.println("/** Get the specific Token. */"); ostr.println(" " + staticOpt() + "final public IElementType getTokenType(int index) {"); if (lookaheadNeeded) { // ostr.println(" Token t = jj_lookingAhead ? jj_scanpos : token;"); } else { ostr.println(" IElementType t = null;"); } ostr.println(" for (int i = 0; i < index; i++) {"); ostr.println(" t = builder.getTokenType();"); ostr.println(" }"); ostr.println(" return t;"); ostr.println(" }"); ostr.println(""); ostr.println(" private IElementType getType() {"); ostr.println(" return builder.getTokenType();"); ostr.println(" }"); ostr.println(""); if (Options.getDebugParser()) { ostr.println(" " + staticOpt() + "private int trace_indent = 0;"); ostr.println(" " + staticOpt() + "private boolean trace_enabled = true;"); ostr.println(""); ostr.println("/** Enable tracing. */"); ostr.println(" " + staticOpt() + "final public void enable_tracing() {"); ostr.println(" trace_enabled = true;"); ostr.println(" }"); ostr.println(""); ostr.println("/** Disable tracing. */"); ostr.println(" " + staticOpt() + "final public void disable_tracing() {"); ostr.println(" trace_enabled = false;"); ostr.println(" }"); ostr.println(""); ostr.println(" " + staticOpt() + "private void trace_call(String s) {"); ostr.println(" if (trace_enabled) {"); ostr.println(" for (int i = 0; i < trace_indent; i++) { System.out.print(\" \"); }"); ostr.println(" System.out.println(\"Call: \" + s);"); ostr.println(" }"); ostr.println(" trace_indent = trace_indent + 2;"); ostr.println(" }"); ostr.println(""); ostr.println(" " + staticOpt() + "private void trace_return(String s) {"); ostr.println(" trace_indent = trace_indent - 2;"); ostr.println(" if (trace_enabled) {"); ostr.println(" for (int i = 0; i < trace_indent; i++) { System.out.print(\" \"); }"); ostr.println(" System.out.println(\"Return: \" + s);"); ostr.println(" }"); ostr.println(" }"); ostr.println(""); ostr.println(" " + staticOpt() + "private void trace_token(Token t, String where) {"); ostr.println(" if (trace_enabled) {"); ostr.println(" for (int i = 0; i < trace_indent; i++) { System.out.print(\" \"); }"); ostr.println(" System.out.print(\"Consumed token: <\" + tokenImage[t.kind]);"); ostr.println( " if (t.kind != 0 && !tokenImage[t.kind].equals(\"\\\"\" + t.image + \"\\\"\")) {"); ostr.println(" System.out.print(\": \\\"\" + t.image + \"\\\"\");"); ostr.println(" }"); ostr.println( " System.out.println(\" at line \" + t.beginLine + " + "\" column \" + t.beginColumn + \">\" + where);"); ostr.println(" }"); ostr.println(" }"); ostr.println(""); ostr.println(" " + staticOpt() + "private void trace_scan(Token t1, int t2) {"); ostr.println(" if (trace_enabled) {"); ostr.println(" for (int i = 0; i < trace_indent; i++) { System.out.print(\" \"); }"); ostr.println(" System.out.print(\"Visited token: <\" + tokenImage[t1.kind]);"); ostr.println( " if (t1.kind != 0 && !tokenImage[t1.kind].equals(\"\\\"\" + t1.image + \"\\\"\")) {"); ostr.println(" System.out.print(\": \\\"\" + t1.image + \"\\\"\");"); ostr.println(" }"); ostr.println( " System.out.println(\" at line \" + t1.beginLine + \"" + " column \" + t1.beginColumn + \">; Expected token: <\" + tokenImage[t2] + \">\");"); ostr.println(" }"); ostr.println(" }"); ostr.println(""); } else { ostr.println(" /** Enable tracing. */"); ostr.println(" " + staticOpt() + "final public void enable_tracing() {"); ostr.println(" }"); ostr.println(""); ostr.println(" /** Disable tracing. */"); ostr.println(" " + staticOpt() + "final public void disable_tracing() {"); ostr.println(" }"); ostr.println(""); } if (cu_from_insertion_point_2.size() != 0) { printTokenSetup((Token) (cu_from_insertion_point_2.get(0))); ccol = 1; for (Iterator it = cu_from_insertion_point_2.iterator(); it.hasNext(); ) { t = (Token) it.next(); printToken(t, ostr); } printTrailingComments(t, ostr); } ostr.println(""); ostr.close(); } // matches "if (Options.getBuildParser())" }
private void printBoilerplate(ParseEngine parseEngine, IndentingPrintWriter out) { out.println("/** Either generated or user defined scanner. */"); out.println("protected final Scanner scanner;"); out.println("/** Current token. */"); out.println("private Token token;"); out.println("/** Next token. */"); out.println("private Token jj_nt;"); if (!Options.getCacheTokens()) { out.println("/** Next token kind. */"); out.println("private int jj_ntk;"); } if (parseEngine.jj2index != 0) { out.println("/** Lookahead tokens. */"); out.println("private Token jj_scanPos, jj_lastPos;"); out.println("private int jj_la;"); if (parseEngine.lookaheadNeeded) { out.println("/** Whether we are looking ahead. */"); out.println("private boolean jj_lookingAhead = false;"); out.println("private boolean jj_semLA;"); } } if (Options.getErrorReporting()) { out.println("private int jj_gen;"); out.println("private final int[] jj_la1 = new int[" + parseEngine.maskIndex + "];"); int tokenMaskSize = (state.tokenCount - 1) / 32 + 1; for (int i = 0; i < tokenMaskSize; i++) { out.print("private static final int[] jj_la1_" + i + " = new int[] {"); out.indent(); IndentingPrintWriter.ListPrinter list = out.list(", "); for (int[] tokenMask : parseEngine.maskValues) { list.item("0x" + Integer.toHexString(tokenMask[i])); } out.println("};"); out.unindent(); } } if (parseEngine.jj2index != 0 && Options.getErrorReporting()) { out.println("private final JJCalls[] jj_2_rtns = new JJCalls[" + parseEngine.jj2index + "];"); out.println("private boolean jj_rescan = false;"); out.println("private int jj_gc = 0;"); } out.println(); out.println( "public " + state.parserClass() + "(Scanner s) throws java.io.IOException, ParseException {"); out.indent(); out.println("scanner = s;"); if (Options.getKeepImage()) { out.println("token = new Token(0, 0, 0, null);"); } else { out.println("token = new Token(0, 0, 0);"); } if (Options.getCacheTokens()) { out.println("token.next = jj_nt = scanner.getNextToken();"); } else { out.println("jj_ntk = -1;"); } if (Options.getErrorReporting()) { out.println("jj_gen = 0;"); out.println("for (int i = 0; i < " + parseEngine.maskIndex + "; i++) jj_la1[i] = -1;"); if (parseEngine.jj2index != 0) { out.println("for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();"); } } out.unindent(); out.println("}"); out.println(); out.println( "private Token jj_consume_token(int kind) throws java.io.IOException, ParseException {"); if (Options.getCacheTokens()) { out.println("Token oldToken = token;"); out.println("if ((token = jj_nt).next != null) { jj_nt = jj_nt.next; }"); out.println("else { jj_nt = jj_nt.next = scanner.getNextToken(); }"); } else { out.println("Token oldToken = token;"); out.println("if (token.next != null) { token = token.next; }"); out.println("else { token = token.next = scanner.getNextToken(); }"); out.println("jj_ntk = -1;"); } out.println("if (token.getKind() == kind) {"); if (Options.getErrorReporting()) { out.println("jj_gen++;"); if (parseEngine.jj2index != 0) { out.println("if (++jj_gc > 100) {"); out.println("jj_gc = 0;"); out.println("for (int i = 0; i < jj_2_rtns.length; i++) {"); out.println("JJCalls c = jj_2_rtns[i];"); out.println("while (c != null) {"); out.println("if (c.gen < jj_gen) c.first = null;"); out.println("c = c.next;"); out.println("}"); out.println("}"); out.println("}"); } } if (Options.getDebugParser()) { out.println("trace_token(token, \"\");"); } out.println("return token;"); out.println("}"); if (Options.getCacheTokens()) { out.println("jj_nt = token;"); } out.println("token = oldToken;"); if (Options.getErrorReporting()) { out.println("jj_kind = kind;"); } out.println("throw generateParseException();"); out.println("}"); out.println(); if (parseEngine.jj2index != 0) { out.println("@SuppressWarnings(\"serial\")"); out.println("private static final class LookaheadSuccess extends Error {"); out.println("public Throwable fillInStackTrace() { return null; }"); out.println("public StackTraceElement[] getStackTrace() { return null; }"); out.println("public void setStackTrace(StackTraceElement[] stackTrace) {}"); out.println("}"); out.println("private final LookaheadSuccess jj_ls = new LookaheadSuccess();"); out.println("private boolean jj_scan_token(int kind) throws java.io.IOException {"); out.println("if (jj_scanPos == jj_lastPos) {"); out.println("jj_la--;"); out.println("if (jj_scanPos.next == null) {"); out.println("jj_lastPos = jj_scanPos = jj_scanPos.next = scanner.getNextToken();"); out.println("} else {"); out.println("jj_lastPos = jj_scanPos = jj_scanPos.next;"); out.println("}"); out.println("} else {"); out.println("jj_scanPos = jj_scanPos.next;"); out.println("}"); if (Options.getErrorReporting()) { out.println("if (jj_rescan) {"); out.println("int i = 0; Token t = token;"); out.println("while (t != null && t != jj_scanPos) { i++; t = t.next; }"); out.println("if (t != null) jj_add_error_token(kind, i);"); if (Options.getDebugLookahead()) { out.println("} else {"); out.println("trace_scan(jj_scanPos, kind);"); } out.println("}"); } else if (Options.getDebugLookahead()) { out.println("trace_scan(jj_scanPos, kind);"); } out.println("if (jj_scanPos.getKind() != kind) return true;"); out.println("if (jj_la == 0 && jj_scanPos == jj_lastPos) throw jj_ls;"); out.println("return false;"); out.println("}"); out.println(); } out.println(); out.println("/** Get the next Token. */"); out.println("protected final Token getNextToken() throws java.io.IOException {"); if (Options.getCacheTokens()) { out.println("if ((token = jj_nt).next != null) jj_nt = jj_nt.next;"); out.println("else jj_nt = jj_nt.next = scanner.getNextToken();"); } else { out.println("if (token.next != null) token = token.next;"); out.println("else token = token.next = scanner.getNextToken();"); out.println("jj_ntk = -1;"); } if (Options.getErrorReporting()) { out.println("jj_gen++;"); } if (Options.getDebugParser()) { out.println("trace_token(token, \" (in getNextToken)\");"); } out.println("return token;"); out.println("}"); out.println(); out.println("/** Get the specific Token. */"); out.println("protected final Token getToken(int index) throws java.io.IOException {"); if (parseEngine.lookaheadNeeded) { out.println("Token t = jj_lookingAhead ? jj_scanPos : token;"); } else { out.println("Token t = token;"); } out.println("for (int i = 0; i < index; i++) {"); out.println("if (t.next != null) t = t.next;"); out.println("else t = t.next = scanner.getNextToken();"); out.println("}"); out.println("return t;"); out.println("}"); out.println(); if (!Options.getCacheTokens()) { out.println("private int jj_ntk() throws java.io.IOException {"); out.println("if ((jj_nt = token.next) == null)"); out.println("return (jj_ntk = (token.next = scanner.getNextToken()).getKind());"); out.println("else"); out.println("return (jj_ntk = jj_nt.getKind());"); out.println("}"); out.println(); } if (Options.getErrorReporting()) { if (!Options.getGenerateGenerics()) { out.println("private java.util.List jj_expentries = new java.util.ArrayList();"); } else { out.println( "private final java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>();"); } out.println("private int[] jj_expentry;"); out.println("private int jj_kind = -1;"); if (parseEngine.jj2index != 0) { out.println("private int[] jj_lasttokens = new int[100];"); out.println("private int jj_endpos;"); out.println(); out.println("private void jj_add_error_token(int kind, int pos) {"); out.println("if (pos >= 100) return;"); out.println("if (pos == jj_endpos + 1) {"); out.println("jj_lasttokens[jj_endpos++] = kind;"); out.println("} else if (jj_endpos != 0) {"); out.println("jj_expentry = new int[jj_endpos];"); out.println("for (int i = 0; i < jj_endpos; i++) {"); out.println("jj_expentry[i] = jj_lasttokens[i];"); out.println("}"); if (!Options.getGenerateGenerics()) { out.println( "jj_entries_loop: for (java.util.Iterator it = jj_expentries.iterator(); it.hasNext();) {"); } else { out.println( "jj_entries_loop: for (java.util.Iterator<?> it = jj_expentries.iterator(); it.hasNext();) {"); } out.println("int[] oldentry = (int[])(it.next());"); out.println("if (oldentry.length == jj_expentry.length) {"); out.println("for (int i = 0; i < jj_expentry.length; i++) {"); out.println("if (oldentry[i] != jj_expentry[i]) {"); out.println("continue jj_entries_loop;"); out.println("}"); out.println("}"); out.println("jj_expentries.add(jj_expentry);"); out.println("break jj_entries_loop;"); out.println("}"); out.println("}"); out.println("if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;"); out.println("}"); out.println("}"); } out.println(); out.println("/** Generate ParseException. */"); out.println("public ParseException generateParseException() throws java.io.IOException {"); out.println("jj_expentries.clear();"); out.println("boolean[] la1tokens = new boolean[" + state.tokenCount + "];"); out.println("if (jj_kind >= 0) {"); out.println("la1tokens[jj_kind] = true;"); out.println("jj_kind = -1;"); out.println("}"); out.println("for (int i = 0; i < " + parseEngine.maskIndex + "; i++) {"); out.println("if (jj_la1[i] == jj_gen) {"); out.println("for (int j = 0; j < 32; j++) {"); for (int i = 0; i < (state.tokenCount - 1) / 32 + 1; i++) { out.println("if ((jj_la1_" + i + "[i] & (1<<j)) != 0) {"); out.print("la1tokens["); if (i != 0) { out.print((32 * i) + "+"); } out.println("j] = true;"); out.println("}"); } out.println("}"); out.println("}"); out.println("}"); out.println("for (int i = 0; i < " + state.tokenCount + "; i++) {"); out.println("if (la1tokens[i]) {"); out.println("jj_expentry = new int[1];"); out.println("jj_expentry[0] = i;"); out.println("jj_expentries.add(jj_expentry);"); out.println("}"); out.println("}"); if (parseEngine.jj2index != 0) { out.println("jj_endpos = 0;"); out.println("jj_rescan_token();"); out.println("jj_add_error_token(0, 0);"); } out.println("int[][] exptokseq = new int[jj_expentries.size()][];"); out.println("for (int i = 0; i < jj_expentries.size(); i++) {"); if (!Options.getGenerateGenerics()) { out.println("exptokseq[i] = (int[])jj_expentries.get(i);"); } else { out.println("exptokseq[i] = jj_expentries.get(i);"); } out.println("}"); out.println( "return new ParseException(token, exptokseq, " + state.constantsClass() + ".tokenImage);"); out.println("}"); } else { out.println("/** Generate ParseException. */"); out.println("public ParseException generateParseException() throws java.io.IOException {"); out.println("Token errortok = token.next;"); if (Options.getKeepLineColumn()) { out.println("int line = errortok.getLine(), column = errortok.getColumn();"); } out.println( "String mess = (errortok.getKind() == 0) ? " + state.constantsClass() + ".tokenImage[0] : errortok.image;"); if (Options.getKeepLineColumn()) { out.println( "return new ParseException(" + "\"Parse error at line \" + line + \", column \" + column + \". " + "Encountered: \" + mess);"); } else { out.println( "return new ParseException(\"Parse error at <unknown location>. " + "Encountered: \" + mess);"); } out.println("}"); } out.println(); if (Options.getDebugParser()) { out.println("private int trace_indent = 0;"); out.println("private boolean trace_enabled = true;"); out.println(); out.println("/** Enable tracing. */"); out.println("public final void enable_tracing() {"); out.println("trace_enabled = true;"); out.println("}"); out.println(); out.println("/** Disable tracing. */"); out.println("public final void disable_tracing() {"); out.println("trace_enabled = false;"); out.println("}"); out.println(); out.println("private void trace_call(String s) {"); out.println("if (trace_enabled) {"); out.println("for (int i = 0; i < trace_indent; i++) { System.out.print(\" \"); }"); out.println("System.out.println(\"Call: \" + s);"); out.println("}"); out.println("trace_indent = trace_indent + 2;"); out.println("}"); out.println(); out.println("private void trace_return(String s) {"); out.println("trace_indent = trace_indent - 2;"); out.println("if (trace_enabled) {"); out.println("for (int i = 0; i < trace_indent; i++) { System.out.print(\" \"); }"); out.println("System.out.println(\"Return: \" + s);"); out.println("}"); out.println("}"); out.println(); out.println("private void trace_token(Token t, String where) {"); out.println("if (trace_enabled) {"); out.println("for (int i = 0; i < trace_indent; i++) { System.out.print(\" \"); }"); out.println( "System.out.print(\"Consumed token: <\" + " + state.constantsClass() + ".tokenImage[t.getKind()]);"); out.println( "if (t.getKind() != 0 && !" + state.constantsClass() + ".tokenImage[t.getKind()].equals(\"\\\"\" + t.image + \"\\\"\")) {"); out.println("System.out.print(\": \\\"\" + t.image + \"\\\"\");"); out.println("}"); out.println( "System.out.println(\" at line \" + t.getLine() + " + "\" column \" + t.getColumn() + \">\" + where);"); out.println("}"); out.println("}"); out.println(); out.println("private void trace_scan(Token t1, int t2) {"); out.println("if (trace_enabled) {"); out.println("for (int i = 0; i < trace_indent; i++) { System.out.print(\" \"); }"); out.println( "System.out.print(\"Visited token: <\" + " + state.constantsClass() + ".tokenImage[t1.getKind()]);"); out.println( "if (t1.getKind() != 0 && !" + state.constantsClass() + ".tokenImage[t1.getKind()].equals(\"\\\"\" + t1.image + \"\\\"\")) {"); out.println("System.out.print(\": \\\"\" + t1.image + \"\\\"\");"); out.println("}"); out.println( "System.out.println(\" at line \" + t1.beginLine + \"" + " column \" + t1.beginColumn + \">; Expected token: <\" + " + state.constantsClass() + ".tokenImage[t2] + \">\");"); out.println("}"); out.println("}"); out.println(); } else { out.println("/** Enable tracing. */"); out.println("public final void enable_tracing() {}"); out.println(); out.println("/** Disable tracing. */"); out.println("public final void disable_tracing() {}"); out.println(); } if (parseEngine.jj2index != 0 && Options.getErrorReporting()) { out.println("private void jj_rescan_token() throws java.io.IOException {"); out.println("jj_rescan = true;"); out.println("for (int i = 0; i < " + parseEngine.jj2index + "; i++) {"); out.println("try {"); out.println("JJCalls p = jj_2_rtns[i];"); out.println("do {"); out.println("if (p.gen > jj_gen) {"); out.println("jj_la = p.arg; jj_lastPos = jj_scanPos = p.first;"); out.println("switch (i) {"); for (int i = 0; i < parseEngine.jj2index; i++) { out.println("case " + i + ": jj_3_" + (i + 1) + "(); break;"); } out.println("}"); out.println("}"); out.println("p = p.next;"); out.println("} while (p != null);"); out.println("} catch(LookaheadSuccess ls) {}"); out.println("}"); out.println("jj_rescan = false;"); out.println("}"); out.println(); out.println("private void jj_save(int index, int xla) throws java.io.IOException {"); out.indent(); out.println("JJCalls p = jj_2_rtns[index];"); out.println("while (p.gen > jj_gen) {"); out.println("if (p.next == null) { p = p.next = new JJCalls(); break; }"); out.println("p = p.next;"); out.println("}"); out.println("p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla;"); out.unindent(); out.println("}"); out.println(); } if (parseEngine.jj2index != 0 && Options.getErrorReporting()) { out.println("static final class JJCalls {"); out.indent(); out.println("int gen;"); out.println("Token first;"); out.println("int arg;"); out.println("JJCalls next;"); out.unindent(); out.println("}"); out.println(); } }