⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 javafiles.java

📁 java 编译器java复杂编译器,可以编译java文件的类库
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    ostr.println("  }");    ostr.println("  public void ReInit(java.io.InputStream dstream, int startline,");    ostr.println("                                                           int startcolumn)");    ostr.println("  {");    ostr.println("     ReInit(dstream, startline, startcolumn, 4096);");    ostr.println("  }");    ostr.println(prefix + "public String GetImage()");    ostr.println("  {");    ostr.println("     if (bufpos >= tokenBegin)");    ostr.println("        return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);");    ostr.println("     else");    ostr.println("        return new String(buffer, tokenBegin, bufsize - tokenBegin) +");    ostr.println("                              new String(buffer, 0, bufpos + 1);");    ostr.println("  }");    ostr.println("");    ostr.println(prefix + "public char[] GetSuffix(int len)");    ostr.println("  {");    ostr.println("     char[] ret = new char[len];");    ostr.println("");    ostr.println("     if ((bufpos + 1) >= len)");    ostr.println("        System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);");    ostr.println("     else");    ostr.println("     {");    ostr.println("        System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,");    ostr.println("                                                          len - bufpos - 1);");    ostr.println("        System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);");    ostr.println("     }");    ostr.println("");    ostr.println("     return ret;");    ostr.println("  }");    ostr.println("");    ostr.println(prefix + "public void Done()");    ostr.println("  {");    ostr.println("     buffer = null;");    if (OtherFilesGen.keepLineCol)    {    ostr.println("     bufline = null;");    ostr.println("     bufcolumn = null;");    }    ostr.println("  }");    if (OtherFilesGen.keepLineCol)    {    ostr.println("");    ostr.println("  /**");    ostr.println("   * Method to adjust line and column numbers for the start of a token.");    ostr.println("   */");    ostr.println(prefix + "public void adjustBeginLineColumn(int newLine, int newCol)");    ostr.println("  {");    ostr.println("     int start = tokenBegin;");    ostr.println("     int len;");    ostr.println("");    ostr.println("     if (bufpos >= tokenBegin)");    ostr.println("     {");    ostr.println("        len = bufpos - tokenBegin + inBuf + 1;");    ostr.println("     }");    ostr.println("     else");    ostr.println("     {");    ostr.println("        len = bufsize - tokenBegin + bufpos + 1 + inBuf;");    ostr.println("     }");    ostr.println("");    ostr.println("     int i = 0, j = 0, k = 0;");    ostr.println("     int nextColDiff = 0, columnDiff = 0;");    ostr.println("");    ostr.println("     while (i < len &&");    ostr.println("            bufline[j = start % bufsize] == bufline[k = ++start % bufsize])");    ostr.println("     {");    ostr.println("        bufline[j] = newLine;");    ostr.println("        nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];");    ostr.println("        bufcolumn[j] = newCol + columnDiff;");    ostr.println("        columnDiff = nextColDiff;");    ostr.println("        i++;");    ostr.println("     } ");    ostr.println("");    ostr.println("     if (i < len)");    ostr.println("     {");    ostr.println("        bufline[j] = newLine++;");    ostr.println("        bufcolumn[j] = newCol + columnDiff;");    ostr.println("");    ostr.println("        while (i++ < len)");    ostr.println("        {");    ostr.println("           if (bufline[j = start % bufsize] != bufline[++start % bufsize])");    ostr.println("              bufline[j] = newLine++;");    ostr.println("           else");    ostr.println("              bufline[j] = newLine;");    ostr.println("        }");    ostr.println("     }");    ostr.println("");    ostr.println("     line = bufline[j];");    ostr.println("     column = bufcolumn[j];");    ostr.println("  }");    ostr.println("");    }    ostr.println("}");    ostr.close();  }  public static void gen_CharStream() {    File tmp = null;    if ((tmp = new File(outputDir, "CharStream.java")).exists()) {      CheckVersion("CharStream.java", charStreamVersion);      return;    }    System.out.println("File \"CharStream.java\" does not exist.  Will create one.");    try {      ostr = new PrintWriter(                new BufferedWriter(                   new FileWriter(tmp),                   8192                )             );    } catch (IOException e) {      JavaCCErrors.semantic_error("Could not open file CharStream.java for writing.");      throw new Error();    }    ostr.println("/* " + getIdString(toolName, "CharStream.java") + " Version " + charStreamVersion + " */");    if (cu_to_insertion_point_1.size() != 0 &&        ((Token)cu_to_insertion_point_1.elementAt(0)).kind == PACKAGE       ) {      for (int i = 1; i < cu_to_insertion_point_1.size(); i++) {        if (((Token)cu_to_insertion_point_1.elementAt(i)).kind == SEMICOLON) {          cline = ((Token)(cu_to_insertion_point_1.elementAt(0))).beginLine;          ccol = ((Token)(cu_to_insertion_point_1.elementAt(0))).beginColumn;          for (int j = 0; j <= i; j++) {            printToken((Token)(cu_to_insertion_point_1.elementAt(j)), ostr);          }          ostr.println("");          ostr.println("");          break;        }      }    }    ostr.println("/**");    ostr.println(" * This interface describes a character stream that maintains line and");    ostr.println(" * column number positions of the characters.  It also has the capability");    ostr.println(" * to backup the stream to some extent.  An implementation of this");    ostr.println(" * interface is used in the TokenManager implementation generated by");    ostr.println(" * JavaCCParser.");    ostr.println(" *");    ostr.println(" * All the methods except backup can be implemented in any fashion. backup");    ostr.println(" * needs to be implemented correctly for the correct operation of the lexer.");    ostr.println(" * Rest of the methods are all used to get information like line number,");    ostr.println(" * column number and the String that constitutes a token and are not used");    ostr.println(" * by the lexer. Hence their implementation won't affect the generated lexer's");    ostr.println(" * operation.");    ostr.println(" */");    ostr.println("");    ostr.println("public interface CharStream {");    ostr.println("");    ostr.println("  /**");    ostr.println("   * Returns the next character from the selected input.  The method");    ostr.println("   * of selecting the input is the responsibility of the class");    ostr.println("   * implementing this interface.  Can throw any java.io.IOException.");    ostr.println("   */");    ostr.println("  char readChar() throws java.io.IOException;");    ostr.println("");    ostr.println("  /**");    ostr.println("   * Returns the column position of the character last read.");    ostr.println("   * @deprecated ");    ostr.println("   * @see #getEndColumn");    ostr.println("   */");    ostr.println("  int getColumn();");    ostr.println("");    ostr.println("  /**");    ostr.println("   * Returns the line number of the character last read.");    ostr.println("   * @deprecated ");    ostr.println("   * @see #getEndLine");    ostr.println("   */");    ostr.println("  int getLine();");    ostr.println("");    ostr.println("  /**");    ostr.println("   * Returns the column number of the last character for current token (being");    ostr.println("   * matched after the last call to BeginTOken).");    ostr.println("   */");    ostr.println("  int getEndColumn();");    ostr.println("");    ostr.println("  /**");    ostr.println("   * Returns the line number of the last character for current token (being");    ostr.println("   * matched after the last call to BeginTOken).");    ostr.println("   */");    ostr.println("  int getEndLine();");    ostr.println("");    ostr.println("  /**");    ostr.println("   * Returns the column number of the first character for current token (being");    ostr.println("   * matched after the last call to BeginTOken).");    ostr.println("   */");    ostr.println("  int getBeginColumn();");    ostr.println("");    ostr.println("  /**");    ostr.println("   * Returns the line number of the first character for current token (being");    ostr.println("   * matched after the last call to BeginTOken).");    ostr.println("   */");    ostr.println("  int getBeginLine();");    ostr.println("");    ostr.println("  /**");    ostr.println("   * Backs up the input stream by amount steps. Lexer calls this method if it");    ostr.println("   * had already read some characters, but could not use them to match a");    ostr.println("   * (longer) token. So, they will be used again as the prefix of the next");    ostr.println("   * token and it is the implemetation's responsibility to do this right.");    ostr.println("   */");    ostr.println("  void backup(int amount);");    ostr.println("");    ostr.println("  /**");    ostr.println("   * Returns the next character that marks the beginning of the next token.");    ostr.println("   * All characters must remain in the buffer between two successive calls");    ostr.println("   * to this method to implement backup correctly.");    ostr.println("   */");    ostr.println("  char BeginToken() throws java.io.IOException;");    ostr.println("");    ostr.println("  /**");    ostr.println("   * Returns a string made up of characters from the marked token beginning ");    ostr.println("   * to the current buffer position. Implementations have the choice of returning");    ostr.println("   * anything that they want to. For example, for efficiency, one might decide");    ostr.println("   * to just return null, which is a valid implementation.");    ostr.println("   */");    ostr.println("  String GetImage();");    ostr.println("");    ostr.println("  /**");    ostr.println("   * Returns an array of characters that make up the suffix of length 'len' for");    ostr.println("   * the currently matched token. This is used to build up the matched string");    ostr.println("   * for use in actions in the case of MORE. A simple and inefficient");    ostr.println("   * implementation of this is as follows :");    ostr.println("   *");    ostr.println("   *   {");    ostr.println("   *      String t = GetImage();");    ostr.println("   *      return t.substring(t.length() - len, t.length()).toCharArray();");    ostr.println("   *   }");    ostr.println("   */");    ostr.println("  char[] GetSuffix(int len);");    ostr.println("");    ostr.println("  /**");    ostr.println("   * The lexer calls this function to indicate that it is done with the stream");    ostr.println("   * and hence implementations can free any resources held by this class.");    ostr.println("   * Again, the body of this function can be just empty and it will not");    ostr.println("   * affect the lexer's operation.");    ostr.println("   */");    ostr.println("  void Done();");    ostr.println("");    ostr.println("}");    ostr.close();  }  public static void gen_ParseException() {    File tmp = null;    if ((tmp = new File(outputDir, "ParseException.java")).exists()) {      CheckVersion("ParseException.java", parseExceptionVersion);      return;    }    System.out.println("File \"ParseException.java\" does not exist.  Will create one.");    try {      ostr = new PrintWriter(                new BufferedWriter(                   new FileWriter(tmp),                   8192                )             );    } catch (IOException e) {      JavaCCErrors.semantic_error("Could not open file ParseException.java for writing.");      throw new Error();    }    ostr.println("/* " + getIdString(toolName, "ParseException.java") + " Version " + parseExceptionVersion + " */");    if (cu_to_insertion_point_1.size() != 0 &&        ((Token)cu_to_insertion_point_1.elementAt(0)).kind == PACKAGE       ) {      for (int i = 1; i < cu_to_insertion_point_1.size(); i++) {        if (((Token)cu_to_insertion_point_1.elementAt(i)).kind == SEMICOLON) {          cline = ((Token)(cu_to_insertion_point_1.elementAt(0))).beginLine;          ccol = ((Token)(cu_to_insertion_point_1.elementAt(0))).beginColumn;          for (int j = 0; j <= i; j++) {            printToken((Token)(cu_to_insertion_point_1.elementAt(j)), ostr);          }          ostr.println("");          ostr.println("");          break;        }      }    }    ostr.println("/**");    ostr.println(" * This exception is thrown when parse errors are encountered.");    ostr.println(" * You can explicitly create objects of this exception type by");    ostr.println(" * calling the method generateParseException in the generated");    ostr.println(" * parser.");    ostr.println(" *");    ostr.println(" * You can modify this class to customize your error reporting");    ostr.println(" * mechanisms so long as you retain the public fields.");    ostr.println(" */");    ostr.println("public class ParseException extends Exception {");    ostr.println("");    ostr.println("  /**");    ostr.println("   * This constructor is used by the method \"generateParseException\"");    ostr.println("   * in the generated parser.  Calling this constructor generates");    ostr.println("   * a new object of this type with the fields \"currentToken\",");    ostr.println("   * \"expectedTokenSequences\", and \"tokenImage\" set.  The boolean");    ostr.println("   * flag \"specialConstructor\" is also set to true to indicate that");    ostr.println("   * this constructor was used to create this object.");    ostr.println("   * This constructor calls its super class with the empty string");    ostr.println("   * to force the \"toString\" method of parent class \"Throwable\" to");    ostr.println("   * print the error message in the form:");    ostr.println("   *     ParseException: <result of getMessage>");    ostr.println("   */");    ostr.println("  public ParseException(Token currentTokenVal,");    ostr.println("                        int[][] expectedTokenSequencesVal,");    ostr.println("                        String[] tokenImageVal");    ostr.println("                       )");    ostr.println("  {");    ostr.println("    super(\"\");");    ostr.println("    specialConstructor = true;");    ostr.println("    currentToken = currentTokenVal;");    ostr.println("    expectedTokenSequences = expectedTokenSequencesVal;");    ostr.println("    tokenImage = tokenImageVal;");    ostr.println("  }");    ostr.println("");    ostr.println("  /**");    ostr.println("   * The following constructors are for use by you for whatever");    ostr.println("   * purpose you can think of.  Constructing the exception in this");    ostr.println("   * manner makes the exception behave in the normal way - i.e., as");    ostr.println("   * documented in the class \"Throwable\".  The fields \"errorToken\",");    ostr.println("   * \"expectedTokenSequences\", and \"tokenImage\" do not contain");    ostr.println("   * relevant information.  The JavaCC generated code does not use");    ostr.println("   * these constructors.");    ostr.println("   */");    ostr.println("");    ostr.println("  public ParseException() {");    ostr.println("    super();");    ostr.println("    specialConstructor = false;");    ostr.println("  }");    ostr.println("");    ostr

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -