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

📄 javafiles.java

📁 java 编译器java复杂编译器,可以编译java文件的类库
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has * intellectual property rights relating to technology embodied in the product * that is described in this document. In particular, and without limitation, * these intellectual property rights may include one or more of the U.S. * patents listed at http://www.sun.com/patents and one or more additional * patents or pending patent applications in the U.S. and in other countries. * U.S. Government Rights - Commercial software. Government users are subject * to the Sun Microsystems, Inc. standard license agreement and applicable * provisions of the FAR and its supplements.  Use is subject to license terms. * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This * product is covered and controlled by U.S. Export Control laws and may be * subject to the export or import laws in other countries.  Nuclear, missile, * chemical biological weapons or nuclear maritime end uses or end users, * whether direct or indirect, are strictly prohibited.  Export or reexport * to countries subject to U.S. embargo or to entities identified on U.S. * export exclusion lists, including, but not limited to, the denied persons * and specially designated nationals lists is strictly prohibited. */package org.javacc.parser;import java.io.*;public class JavaFiles    extends JavaCCGlobals    implements JavaCCParserConstants{  static PrintWriter ostr;  /**   * ID of the latest version (of JavaCC) in which one of the CharStream classes   * or the CharStream interface is modified.   */  static final String charStreamVersion = "3.0";  /**   * ID of the latest version (of JavaCC) in which the TokenManager interface is modified.   */  static final String tokenManagerVersion = "3.0";  /**   * ID of the latest version (of JavaCC) in which the Token class is modified.   */  static final String tokenVersion = "3.0";  /**   * ID of the latest version (of JavaCC) in which the ParseException class is   * modified.   */  static final String parseExceptionVersion = "3.0";  /**   * ID of the latest version (of JavaCC) in which the TokenMgrError class is   * modified.   */  static final String tokenMgrErrorVersion = "3.0";  /**   * Replaces all backslahes with double backslashes.   */  static String replaceBackslash(String str)  {     StringBuffer b;     int i = 0, len = str.length();     while (i < len && str.charAt(i++) != '\\') ;     if (i == len)  // No backslash found.       return str;     char c;     b = new StringBuffer();     for (i = 0; i < len; i++)       if ((c = str.charAt(i)) == '\\')          b.append("\\\\");       else          b.append(c);     return b.toString();  }  static void CheckVersion(String fileName, String versionId)  {     fileName = replaceBackslash(fileName);     String firstLine = "/* " + getIdString(toolName, fileName) +                                         " Version " + versionId + " */";     char[] buf = new char[firstLine.length()];     try {       File fp = new File(outputDir, fileName);       Reader stream = new FileReader(fp);       int read, total = 0;       for (;;)          if ((read = stream.read(buf, 0, buf.length)) > 0)          {             if ((total += read) == buf.length)                if (new String(buf).equals(firstLine))                   return;                else                   break;          }          else             break;    } catch(FileNotFoundException e1) {      // This should never happen      JavaCCErrors.semantic_error("Could not open file " + fileName + " for writing.");      throw new Error();    } catch(IOException e2) {    }    JavaCCErrors.warning(fileName + ": File is obsolete.  Please rename or delete this file so" +                       " that a new one can be generated for you.");    return;  }  public static void gen_JavaCharStream() {    File tmp = null;    if ((tmp = new File(outputDir, "JavaCharStream.java")).exists()) {      CheckVersion("JavaCharStream.java", charStreamVersion);      return;    }    System.out.println("File \"JavaCharStream.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 JavaCharStream.java for writing.");      throw new Error();    }    ostr.println("/* " + getIdString(toolName, "JavaCharStream.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;        }      }    }    String prefix = (Options.B("STATIC") ? "  static " : "  ");    ostr.println("/**");    ostr.println(" * An implementation of interface CharStream, where the stream is assumed to");    ostr.println(" * contain only ASCII characters (with java-like unicode escape processing).");    ostr.println(" */");    ostr.println("");    ostr.println("public class JavaCharStream");    ostr.println("{");    ostr.println("  public static final boolean staticFlag = " +                                         Options.B("STATIC") + ";");    ostr.println("  static final int hexval(char c) throws java.io.IOException {");    ostr.println("    switch(c)");    ostr.println("    {");    ostr.println("       case '0' :");    ostr.println("          return 0;");    ostr.println("       case '1' :");    ostr.println("          return 1;");    ostr.println("       case '2' :");    ostr.println("          return 2;");    ostr.println("       case '3' :");    ostr.println("          return 3;");    ostr.println("       case '4' :");    ostr.println("          return 4;");    ostr.println("       case '5' :");    ostr.println("          return 5;");    ostr.println("       case '6' :");    ostr.println("          return 6;");    ostr.println("       case '7' :");    ostr.println("          return 7;");    ostr.println("       case '8' :");    ostr.println("          return 8;");    ostr.println("       case '9' :");    ostr.println("          return 9;");    ostr.println("");    ostr.println("       case 'a' :");    ostr.println("       case 'A' :");    ostr.println("          return 10;");    ostr.println("       case 'b' :");    ostr.println("       case 'B' :");    ostr.println("          return 11;");    ostr.println("       case 'c' :");    ostr.println("       case 'C' :");    ostr.println("          return 12;");    ostr.println("       case 'd' :");    ostr.println("       case 'D' :");    ostr.println("          return 13;");    ostr.println("       case 'e' :");    ostr.println("       case 'E' :");    ostr.println("          return 14;");    ostr.println("       case 'f' :");    ostr.println("       case 'F' :");    ostr.println("          return 15;");    ostr.println("    }");    ostr.println("");    ostr.println("    throw new java.io.IOException(); // Should never come here");    ostr.println("  }");    ostr.println("");    ostr.println(prefix + "public int bufpos = -1;");    ostr.println(prefix + "int bufsize;");    ostr.println(prefix + "int available;");    ostr.println(prefix + "int tokenBegin;");    if (OtherFilesGen.keepLineCol)    {       ostr.println(prefix + "protected int bufline[];");       ostr.println(prefix + "protected int bufcolumn[];");       ostr.println("");       ostr.println(prefix + "protected int column = 0;");       ostr.println(prefix + "protected int line = 1;");       ostr.println("");       ostr.println(prefix + "protected boolean prevCharIsCR = false;");       ostr.println(prefix + "protected boolean prevCharIsLF = false;");    }    ostr.println("");    ostr.println(prefix + "protected java.io.Reader inputStream;");    ostr.println("");    ostr.println(prefix + "protected char[] nextCharBuf;");    ostr.println(prefix + "protected char[] buffer;");    ostr.println(prefix + "protected int maxNextCharInd = 0;");    ostr.println(prefix + "protected int nextCharInd = -1;");    ostr.println(prefix + "protected int inBuf = 0;");    ostr.println("");    ostr.println(prefix + "protected void ExpandBuff(boolean wrapAround)");    ostr.println("  {");    ostr.println("     char[] newbuffer = new char[bufsize + 2048];");    if (OtherFilesGen.keepLineCol)    {       ostr.println("     int newbufline[] = new int[bufsize + 2048];");       ostr.println("     int newbufcolumn[] = new int[bufsize + 2048];");    }    ostr.println("");    ostr.println("     try");    ostr.println("     {");    ostr.println("        if (wrapAround)");    ostr.println("        {");    ostr.println("           System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);");    ostr.println("           System.arraycopy(buffer, 0, newbuffer,");    ostr.println("                                             bufsize - tokenBegin, bufpos);");    ostr.println("           buffer = newbuffer;");    if (OtherFilesGen.keepLineCol)    {       ostr.println("");       ostr.println("           System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);");       ostr.println("           System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);");       ostr.println("           bufline = newbufline;");       ostr.println("");       ostr.println("           System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);");       ostr.println("           System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);");       ostr.println("           bufcolumn = newbufcolumn;");    }    ostr.println("");    ostr.println("           bufpos += (bufsize - tokenBegin);");    ostr.println("        }");    ostr.println("        else");    ostr.println("        {");    ostr.println("           System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);");    ostr.println("           buffer = newbuffer;");    if (OtherFilesGen.keepLineCol)    {       ostr.println("");       ostr.println("           System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);");       ostr.println("           bufline = newbufline;");       ostr.println("");       ostr.println("           System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);");       ostr.println("           bufcolumn = newbufcolumn;");    }    ostr.println("");    ostr.println("           bufpos -= tokenBegin;");    ostr.println("        }");    ostr.println("     }");    ostr.println("     catch (Throwable t)");    ostr.println("     {");    ostr.println("        throw new Error(t.getMessage());");    ostr.println("     }");    ostr.println("");    ostr.println("     available = (bufsize += 2048);");    ostr.println("     tokenBegin = 0;");    ostr.println("  }");    ostr.println("");    ostr.println(prefix + "protected void FillBuff() throws java.io.IOException");    ostr.println("  {");    ostr.println("     int i;");    ostr.println("     if (maxNextCharInd == 4096)");    ostr.println("        maxNextCharInd = nextCharInd = 0;");    ostr.println("");    ostr.println("     try {");    ostr.println("        if ((i = inputStream.read(nextCharBuf, maxNextCharInd,");    ostr.println("                                            4096 - maxNextCharInd)) == -1)");    ostr.println("        {");    ostr.println("           inputStream.close();");    ostr.println("           throw new java.io.IOException();");    ostr.println("        }");    ostr.println("        else");    ostr.println("           maxNextCharInd += i;");    ostr.println("        return;");    ostr.println("     }");    ostr.println("     catch(java.io.IOException e) {");    ostr.println("        if (bufpos != 0)");    ostr.println("        {");    ostr.println("           --bufpos;");    ostr.println("           backup(0);");    ostr.println("        }");    if (OtherFilesGen.keepLineCol)    {       ostr.println("        else");       ostr.println("        {");       ostr.println("           bufline[bufpos] = line;");       ostr.println("           bufcolumn[bufpos] = column;");       ostr.println("        }");    }    ostr.println("        throw e;");

⌨️ 快捷键说明

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