📄 javafiles.java
字号:
} ostr.println(" inputStream = dstream;"); if (OtherFilesGen.keepLineCol) { ostr.println(" line = startline;"); ostr.println(" column = startcolumn - 1;"); } ostr.println(""); ostr.println(" available = bufsize = buffersize;"); ostr.println(" buffer = new char[buffersize];"); if (OtherFilesGen.keepLineCol) { ostr.println(" bufline = new int[buffersize];"); ostr.println(" bufcolumn = new int[buffersize];"); } ostr.println(" nextCharBuf = new char[4096];"); ostr.println(" }"); ostr.println(""); ostr.println(" public JavaCharStream(java.io.Reader dstream,"); ostr.println(" int startline, int startcolumn)"); ostr.println(" {"); ostr.println(" this(dstream, startline, startcolumn, 4096);"); ostr.println(" }"); ostr.println(""); ostr.println(" public JavaCharStream(java.io.Reader dstream)"); ostr.println(" {"); ostr.println(" this(dstream, 1, 1, 4096);"); ostr.println(" }"); ostr.println(" public void ReInit(java.io.Reader dstream,"); ostr.println(" int startline, int startcolumn, int buffersize)"); ostr.println(" {"); ostr.println(" inputStream = dstream;"); if (OtherFilesGen.keepLineCol) { ostr.println(" line = startline;"); ostr.println(" column = startcolumn - 1;"); } ostr.println(""); ostr.println(" if (buffer == null || buffersize != buffer.length)"); ostr.println(" {"); ostr.println(" available = bufsize = buffersize;"); ostr.println(" buffer = new char[buffersize];"); if (OtherFilesGen.keepLineCol) { ostr.println(" bufline = new int[buffersize];"); ostr.println(" bufcolumn = new int[buffersize];"); } ostr.println(" nextCharBuf = new char[4096];"); ostr.println(" }"); if (OtherFilesGen.keepLineCol) { ostr.println(" prevCharIsLF = prevCharIsCR = false;"); } ostr.println(" tokenBegin = inBuf = maxNextCharInd = 0;"); ostr.println(" nextCharInd = bufpos = -1;"); ostr.println(" }"); ostr.println(""); ostr.println(" public void ReInit(java.io.Reader dstream,"); ostr.println(" int startline, int startcolumn)"); ostr.println(" {"); ostr.println(" ReInit(dstream, startline, startcolumn, 4096);"); ostr.println(" }"); ostr.println(""); ostr.println(" public void ReInit(java.io.Reader dstream)"); ostr.println(" {"); ostr.println(" ReInit(dstream, 1, 1, 4096);"); ostr.println(" }"); ostr.println(" public JavaCharStream(java.io.InputStream dstream, int startline,"); ostr.println(" int startcolumn, int buffersize)"); ostr.println(" {"); ostr.println(" this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);"); ostr.println(" }"); ostr.println(""); ostr.println(" public JavaCharStream(java.io.InputStream dstream, int startline,"); ostr.println(" int startcolumn)"); ostr.println(" {"); ostr.println(" this(dstream, startline, startcolumn, 4096);"); ostr.println(" }"); ostr.println(""); ostr.println(" public JavaCharStream(java.io.InputStream dstream)"); ostr.println(" {"); ostr.println(" this(dstream, 1, 1, 4096);"); ostr.println(" }"); ostr.println(""); ostr.println(" public void ReInit(java.io.InputStream dstream, int startline,"); ostr.println(" int startcolumn, int buffersize)"); ostr.println(" {"); ostr.println(" ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);"); 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(" public void ReInit(java.io.InputStream dstream)"); ostr.println(" {"); ostr.println(" ReInit(dstream, 1, 1, 4096);"); ostr.println(" }"); 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(" nextCharBuf = null;"); 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_SimpleCharStream() { File tmp = null; if ((tmp = new File(outputDir, "SimpleCharStream.java")).exists()) { CheckVersion("SimpleCharStream.java", charStreamVersion); return; } System.out.println("File \"SimpleCharStream.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 SimpleCharStream.java for writing."); throw new Error(); } ostr.println("/* " + getIdString(toolName, "SimpleCharStream.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 (without unicode processing)."); ostr.println(" */"); ostr.println(""); ostr.println("public class SimpleCharStream"); ostr.println("{"); ostr.println(" public static final boolean staticFlag = " + Options.B("STATIC") + ";"); ostr.println(prefix + "int bufsize;"); ostr.println(prefix + "int available;"); ostr.println(prefix + "int tokenBegin;"); ostr.println(prefix + "public int bufpos = -1;"); 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[] buffer;"); ostr.println(prefix + "protected int maxNextCharInd = 0;"); 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(" maxNextCharInd = (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(" maxNextCharInd = (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("");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -