[Pydev-cvs] org.python.pydev.parser/src/org/python/pydev/parser/jython ReaderCharStream.java, 1.4,
Brought to you by:
fabioz
Update of /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/jython In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20472/src/org/python/pydev/parser/jython Modified Files: ReaderCharStream.java SpecialStr.java FastCharStream.java Token.java ICompilerAPI.java Log Message: Synching to latest changes: Pydev <ul> <li><strong>Editor</strong>: Cursor settings no longer overridden</li> <li><strong>Code-completion</strong>: If __all__ is defined with runtime elements (and not only in a single assign statement), it's ignored for code-completion purposes</li> <li><strong>Debugger</strong>: Pythonpath the same in debug and regular modes (sys.path[0] is the same directory as the file run)</li> <li><strong>Debugger</strong>: Persist choices done in the debugger when files from the debugger are not found</li> <li><strong>Interpreter config</strong>: "email" automatically added to the "forced builtins"</li> <li><strong>Parser</strong>: Correctly recognizing absolute import with 3 or more levels</li> <li><strong>Syntax check</strong>: Option to do only on active editor</li> </ul> Also: tabs changed for spaces Index: ReaderCharStream.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/jython/ReaderCharStream.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ReaderCharStream.java 28 Apr 2006 13:43:41 -0000 1.4 --- ReaderCharStream.java 27 Sep 2008 19:58:42 -0000 1.5 *************** *** 6,271 **** public final class ReaderCharStream implements CharStream { ! int bufsize; ! int available; ! int tokenBegin; ! public int bufpos = -1; ! private int bufline[]; ! private int bufcolumn[]; ! private int column = 0; ! private int line = 1; ! private boolean prevCharIsCR = false; ! private boolean prevCharIsLF = false; ! private java.io.Reader inputStream; ! private char[] buffer; ! private int maxNextCharInd = 0; ! private int inBuf = 0; ! ! private static final boolean DEBUG = false; ! private final void ExpandBuff(boolean wrapAround) { ! char[] newbuffer = new char[bufsize + 2048]; ! int newbufline[] = new int[bufsize + 2048]; ! int newbufcolumn[] = new int[bufsize + 2048]; ! try { ! if (wrapAround) { ! System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); ! System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos); ! buffer = newbuffer; ! System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); ! System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); ! bufline = newbufline; ! System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); ! System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); ! bufcolumn = newbufcolumn; ! maxNextCharInd = (bufpos += (bufsize - tokenBegin)); ! } else { ! System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); ! buffer = newbuffer; ! System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); ! bufline = newbufline; ! System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); ! bufcolumn = newbufcolumn; ! maxNextCharInd = (bufpos -= tokenBegin); ! } ! } catch (Throwable t) { ! throw new Error(t.getMessage()); ! } ! bufsize += 2048; ! available = bufsize; ! tokenBegin = 0; ! } ! private final void FillBuff() throws java.io.IOException { ! if (maxNextCharInd == available) { ! if (available == bufsize) { ! if (tokenBegin > 2048) { ! bufpos = maxNextCharInd = 0; ! available = tokenBegin; ! } else if (tokenBegin < 0) ! bufpos = maxNextCharInd = 0; ! else ! ExpandBuff(false); ! } else if (available > tokenBegin) ! available = bufsize; ! else if ((tokenBegin - available) < 2048) ! ExpandBuff(true); ! else ! available = tokenBegin; ! } ! int i; ! try { ! if ((i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1) { ! inputStream.close(); ! throw new java.io.IOException(); ! } else ! maxNextCharInd += i; ! return; ! } catch (java.io.IOException e) { ! --bufpos; ! backup(0); ! if (tokenBegin == -1) ! tokenBegin = bufpos; ! throw e; ! } ! } ! public final char BeginToken() throws java.io.IOException { ! tokenBegin = -1; ! char c = readChar(); ! tokenBegin = bufpos; ! if(DEBUG){ ! System.out.println("ReaderCharStream: BeginToken >>"+(int)c+"<<"); ! } ! return c; ! } ! private final void UpdateLineColumn(char c) { ! column++; ! if (prevCharIsLF) { ! prevCharIsLF = false; ! line += (column = 1); ! } else if (prevCharIsCR) { ! prevCharIsCR = false; ! if (c == '\n') { ! prevCharIsLF = true; ! } else ! line += (column = 1); ! } ! switch (c) { ! case '\r': ! prevCharIsCR = true; ! break; ! case '\n': ! prevCharIsLF = true; ! break; ! // ok, this was commented out because the position would not reflect correctly the positions found in the ast. ! // this may have other problems, but they have to be analyzed better to see the problems this may bring ! // (files that mix tabs and spaces may suffer, but I could not find out very well the problems -- anyway, ! // restricting the analysis to files that have only tabs or only spaces seems reasonable -- shortcuts are available ! // so that we can convert a file from one type to another, so, what remains is making some lint analysis to be sure of it). ! // case '\t' : ! // column--; ! // column += (8 - (column & 07)); ! // break; ! default: ! break; ! } ! bufline[bufpos] = line; ! bufcolumn[bufpos] = column; ! } ! public final char readChar() throws java.io.IOException { ! if (inBuf > 0) { ! --inBuf; ! return buffer[(bufpos == bufsize - 1) ? (bufpos = 0) : ++bufpos]; ! } ! if (++bufpos >= maxNextCharInd) ! FillBuff(); ! char c = buffer[bufpos]; ! UpdateLineColumn(c); ! if(DEBUG){ ! System.out.println("ReaderCharStream: readChar >>"+(int)c+"<<"); ! } ! return (c); ! } ! /** ! * @deprecated ! * @see #getEndColumn ! */ ! public final int getColumn() { ! return bufcolumn[bufpos]; ! } ! /** ! * @deprecated ! * @see #getEndLine ! */ ! public final int getLine() { ! return bufline[bufpos]; ! } ! public final int getEndColumn() { ! return bufcolumn[bufpos]; ! } ! public final int getEndLine() { ! return bufline[bufpos]; ! } ! public final int getBeginColumn() { ! return bufcolumn[tokenBegin]; ! } ! public final int getBeginLine() { ! return bufline[tokenBegin]; ! } ! public final void backup(int amount) { ! if(DEBUG){ ! System.out.println("ReaderCharStream: backup >>"+amount+"<<"); ! } ! inBuf += amount; ! if ((bufpos -= amount) < 0) ! bufpos += bufsize; ! } ! public ReaderCharStream(java.io.Reader dstream) { ! inputStream = dstream; ! line = 1; ! column = 0; ! available = bufsize = 4096; ! buffer = new char[bufsize]; ! bufline = new int[bufsize]; ! bufcolumn = new int[bufsize]; ! } ! public final String GetImage() { ! String s = null; ! if (bufpos >= tokenBegin) ! s = new String(buffer, tokenBegin, bufpos - tokenBegin + 1); ! else ! s = new String(buffer, tokenBegin, bufsize - tokenBegin) + new String(buffer, 0, bufpos + 1); ! ! if(DEBUG){ ! System.out.println("ReaderCharStream: GetImage >>"+s+"<<"); ! } ! return s; ! } ! public final char[] GetSuffix(int len) { ! char[] ret = new char[len]; ! if ((bufpos + 1) >= len) ! System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); ! else { ! System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, len - bufpos - 1); ! System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); ! } ! if(DEBUG){ ! System.out.println("ReaderCharStream: GetSuffix:"+len+" >>"+new String(ret)+"<<"); ! } ! return ret; ! } ! public void Done() { ! buffer = null; ! bufline = null; ! bufcolumn = null; ! } } --- 6,271 ---- public final class ReaderCharStream implements CharStream { ! int bufsize; ! int available; ! int tokenBegin; ! public int bufpos = -1; ! private int bufline[]; ! private int bufcolumn[]; ! private int column = 0; ! private int line = 1; ! private boolean prevCharIsCR = false; ! private boolean prevCharIsLF = false; ! private java.io.Reader inputStream; ! private char[] buffer; ! private int maxNextCharInd = 0; ! private int inBuf = 0; ! ! private static final boolean DEBUG = false; ! private final void ExpandBuff(boolean wrapAround) { ! char[] newbuffer = new char[bufsize + 2048]; ! int newbufline[] = new int[bufsize + 2048]; ! int newbufcolumn[] = new int[bufsize + 2048]; ! try { ! if (wrapAround) { ! System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); ! System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos); ! buffer = newbuffer; ! System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); ! System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); ! bufline = newbufline; ! System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); ! System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); ! bufcolumn = newbufcolumn; ! maxNextCharInd = (bufpos += (bufsize - tokenBegin)); ! } else { ! System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); ! buffer = newbuffer; ! System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); ! bufline = newbufline; ! System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); ! bufcolumn = newbufcolumn; ! maxNextCharInd = (bufpos -= tokenBegin); ! } ! } catch (Throwable t) { ! throw new Error(t.getMessage()); ! } ! bufsize += 2048; ! available = bufsize; ! tokenBegin = 0; ! } ! private final void FillBuff() throws java.io.IOException { ! if (maxNextCharInd == available) { ! if (available == bufsize) { ! if (tokenBegin > 2048) { ! bufpos = maxNextCharInd = 0; ! available = tokenBegin; ! } else if (tokenBegin < 0) ! bufpos = maxNextCharInd = 0; ! else ! ExpandBuff(false); ! } else if (available > tokenBegin) ! available = bufsize; ! else if ((tokenBegin - available) < 2048) ! ExpandBuff(true); ! else ! available = tokenBegin; ! } ! int i; ! try { ! if ((i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1) { ! inputStream.close(); ! throw new java.io.IOException(); ! } else ! maxNextCharInd += i; ! return; ! } catch (java.io.IOException e) { ! --bufpos; ! backup(0); ! if (tokenBegin == -1) ! tokenBegin = bufpos; ! throw e; ! } ! } ! public final char BeginToken() throws java.io.IOException { ! tokenBegin = -1; ! char c = readChar(); ! tokenBegin = bufpos; ! if(DEBUG){ ! System.out.println("ReaderCharStream: BeginToken >>"+(int)c+"<<"); ! } ! return c; ! } ! private final void UpdateLineColumn(char c) { ! column++; ! if (prevCharIsLF) { ! prevCharIsLF = false; ! line += (column = 1); ! } else if (prevCharIsCR) { ! prevCharIsCR = false; ! if (c == '\n') { ! prevCharIsLF = true; ! } else ! line += (column = 1); ! } ! switch (c) { ! case '\r': ! prevCharIsCR = true; ! break; ! case '\n': ! prevCharIsLF = true; ! break; ! // ok, this was commented out because the position would not reflect correctly the positions found in the ast. ! // this may have other problems, but they have to be analyzed better to see the problems this may bring ! // (files that mix tabs and spaces may suffer, but I could not find out very well the problems -- anyway, ! // restricting the analysis to files that have only tabs or only spaces seems reasonable -- shortcuts are available ! // so that we can convert a file from one type to another, so, what remains is making some lint analysis to be sure of it). ! // case '\t' : ! // column--; ! // column += (8 - (column & 07)); ! // break; ! default: ! break; ! } ! bufline[bufpos] = line; ! bufcolumn[bufpos] = column; ! } ! public final char readChar() throws java.io.IOException { ! if (inBuf > 0) { ! --inBuf; ! return buffer[(bufpos == bufsize - 1) ? (bufpos = 0) : ++bufpos]; ! } ! if (++bufpos >= maxNextCharInd) ! FillBuff(); ! char c = buffer[bufpos]; ! UpdateLineColumn(c); ! if(DEBUG){ ! System.out.println("ReaderCharStream: readChar >>"+(int)c+"<<"); ! } ! return (c); ! } ! /** ! * @deprecated ! * @see #getEndColumn ! */ ! public final int getColumn() { ! return bufcolumn[bufpos]; ! } ! /** ! * @deprecated ! * @see #getEndLine ! */ ! public final int getLine() { ! return bufline[bufpos]; ! } ! public final int getEndColumn() { ! return bufcolumn[bufpos]; ! } ! public final int getEndLine() { ! return bufline[bufpos]; ! } ! public final int getBeginColumn() { ! return bufcolumn[tokenBegin]; ! } ! public final int getBeginLine() { ! return bufline[tokenBegin]; ! } ! public final void backup(int amount) { ! if(DEBUG){ ! System.out.println("ReaderCharStream: backup >>"+amount+"<<"); ! } ! inBuf += amount; ! if ((bufpos -= amount) < 0) ! bufpos += bufsize; ! } ! public ReaderCharStream(java.io.Reader dstream) { ! inputStream = dstream; ! line = 1; ! column = 0; ! available = bufsize = 4096; ! buffer = new char[bufsize]; ! bufline = new int[bufsize]; ! bufcolumn = new int[bufsize]; ! } ! public final String GetImage() { ! String s = null; ! if (bufpos >= tokenBegin) ! s = new String(buffer, tokenBegin, bufpos - tokenBegin + 1); ! else ! s = new String(buffer, tokenBegin, bufsize - tokenBegin) + new String(buffer, 0, bufpos + 1); ! ! if(DEBUG){ ! System.out.println("ReaderCharStream: GetImage >>"+s+"<<"); ! } ! return s; ! } ! public final char[] GetSuffix(int len) { ! char[] ret = new char[len]; ! if ((bufpos + 1) >= len) ! System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); ! else { ! System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, len - bufpos - 1); ! System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); ! } ! if(DEBUG){ ! System.out.println("ReaderCharStream: GetSuffix:"+len+" >>"+new String(ret)+"<<"); ! } ! return ret; ! } ! public void Done() { ! buffer = null; ! bufline = null; ! bufcolumn = null; ! } } Index: Token.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/jython/Token.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Token.java 7 Jun 2006 13:25:19 -0000 1.2 --- Token.java 27 Sep 2008 19:58:42 -0000 1.3 *************** *** 73,77 **** public static final Token newToken(int ofKind) { ! throw new RuntimeException("It should be initialized directly."); // switch(ofKind) // { --- 73,77 ---- public static final Token newToken(int ofKind) { ! throw new RuntimeException("It should be initialized directly."); // switch(ofKind) // { Index: SpecialStr.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/jython/SpecialStr.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SpecialStr.java 20 Mar 2006 19:37:35 -0000 1.1 --- SpecialStr.java 27 Sep 2008 19:58:42 -0000 1.2 *************** *** 2,31 **** public class SpecialStr { ! public String str; ! public int beginLine; ! public int beginCol; ! public SpecialStr(String str, int beginLine, int beginCol){ ! this.str = str; ! this.beginLine = beginLine; ! this.beginCol = beginCol; ! } ! ! @Override ! public String toString() { ! return str; ! } ! @Override ! public int hashCode() { ! return str.hashCode(); ! } ! ! @Override ! public boolean equals(Object obj) { ! if(!(obj instanceof SpecialStr)){ ! return false; ! } ! return str.equals(((SpecialStr)obj).str); ! } } --- 2,31 ---- public class SpecialStr { ! public String str; ! public int beginLine; ! public int beginCol; ! public SpecialStr(String str, int beginLine, int beginCol){ ! this.str = str; ! this.beginLine = beginLine; ! this.beginCol = beginCol; ! } ! ! @Override ! public String toString() { ! return str; ! } ! @Override ! public int hashCode() { ! return str.hashCode(); ! } ! ! @Override ! public boolean equals(Object obj) { ! if(!(obj instanceof SpecialStr)){ ! return false; ! } ! return str.equals(((SpecialStr)obj).str); ! } } Index: ICompilerAPI.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/jython/ICompilerAPI.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ICompilerAPI.java 20 Mar 2006 19:37:35 -0000 1.1 --- ICompilerAPI.java 27 Sep 2008 19:58:43 -0000 1.2 *************** *** 14,28 **** public interface ICompilerAPI { ! public Object newLong(String s); ! public Object newLong(java.math.BigInteger i); ! public Object newFloat(double v); ! ! public Object newImaginary(double v); ! ! public Object newInteger(int i); ! ! public String decode_UnicodeEscape(String str, int start, int end, ! String errors, boolean unicode); } --- 14,28 ---- public interface ICompilerAPI { ! public Object newLong(String s); ! public Object newLong(java.math.BigInteger i); ! public Object newFloat(double v); ! ! public Object newImaginary(double v); ! ! public Object newInteger(int i); ! ! public String decode_UnicodeEscape(String str, int start, int end, ! String errors, boolean unicode); } Index: FastCharStream.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/jython/FastCharStream.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** FastCharStream.java 2 Jul 2008 20:18:52 -0000 1.8 --- FastCharStream.java 27 Sep 2008 19:58:42 -0000 1.9 *************** *** 15,159 **** public final class FastCharStream implements CharStream { ! private char[] buffer; ! private int bufline[]; ! private int bufcolumn[]; ! private boolean prevCharIsCR = false; ! private boolean prevCharIsLF = false; ! private int column = 0; ! private int line = 1; ! private int bufpos = -1; ! private int updatePos; ! ! private int tokenBegin; ! ! private static IOException ioException; ! private static final boolean DEBUG = false; ! public FastCharStream(char cs[]) { ! this.buffer = cs; ! this.bufline = new int[cs.length]; ! this.bufcolumn = new int[cs.length]; ! } ! public final char readChar() throws IOException { ! try { ! bufpos++; ! char r = this.buffer[bufpos]; ! ! if(bufpos >= updatePos){ ! updatePos++; ! ! //start UpdateLineCol ! column++; ! ! if (prevCharIsLF) { ! prevCharIsLF = false; ! line += (column = 1); ! ! } else if (prevCharIsCR) { ! ! prevCharIsCR = false; ! if (r == '\n') { ! prevCharIsLF = true; ! } else { ! line += (column = 1); ! } ! } ! ! if(r == '\r'){ ! prevCharIsCR = true; ! ! }else if(r == '\n'){ ! prevCharIsLF = true; ! ! } ! ! bufline[bufpos] = line; ! bufcolumn[bufpos] = column; ! //end UpdateLineCol ! } ! ! return r; ! } catch (ArrayIndexOutOfBoundsException e) { ! bufpos--; ! if (ioException == null){ ! ioException = new IOException(); ! } ! throw ioException; ! } ! } ! /** ! * @deprecated ! * @see #getEndColumn ! */ ! public final int getColumn() { ! return bufcolumn[bufpos]; ! } ! /** ! * @deprecated ! * @see #getEndLine ! */ ! public final int getLine() { ! return bufline[bufpos]; ! } ! public final int getEndColumn() { ! return bufcolumn[bufpos]; ! } ! public final int getEndLine() { ! return bufline[bufpos]; ! } ! public final int getBeginColumn() { ! return bufcolumn[tokenBegin]; ! } ! public final int getBeginLine() { ! return bufline[tokenBegin]; ! } ! public final void backup(int amount) { ! if(DEBUG){ ! System.out.println("FastCharStream: backup >>"+amount+"<<"); ! } ! bufpos -= amount; ! } ! public final char BeginToken() throws IOException { ! char c = readChar(); ! tokenBegin = bufpos; ! if(DEBUG){ ! System.out.println("FastCharStream: BeginToken >>"+(int)c+"<<"); ! } ! return c; ! } ! public final String GetImage() { ! if (bufpos >= tokenBegin) { ! return new String(buffer, tokenBegin, bufpos - tokenBegin+1); ! } else { ! return new String(buffer, tokenBegin, buffer.length - tokenBegin+1); ! } ! } ! public final char[] GetSuffix(int len) { ! char[] ret = new char[len]; ! if (len > 0) { ! try { int initial = bufpos - len +1; if(initial < 0){ --- 15,159 ---- public final class FastCharStream implements CharStream { ! private char[] buffer; ! private int bufline[]; ! private int bufcolumn[]; ! private boolean prevCharIsCR = false; ! private boolean prevCharIsLF = false; ! private int column = 0; ! private int line = 1; ! private int bufpos = -1; ! private int updatePos; ! ! private int tokenBegin; ! ! private static IOException ioException; ! private static final boolean DEBUG = false; ! public FastCharStream(char cs[]) { ! this.buffer = cs; ! this.bufline = new int[cs.length]; ! this.bufcolumn = new int[cs.length]; ! } ! public final char readChar() throws IOException { ! try { ! bufpos++; ! char r = this.buffer[bufpos]; ! ! if(bufpos >= updatePos){ ! updatePos++; ! ! //start UpdateLineCol ! column++; ! ! if (prevCharIsLF) { ! prevCharIsLF = false; ! line += (column = 1); ! ! } else if (prevCharIsCR) { ! ! prevCharIsCR = false; ! if (r == '\n') { ! prevCharIsLF = true; ! } else { ! line += (column = 1); ! } ! } ! ! if(r == '\r'){ ! prevCharIsCR = true; ! ! }else if(r == '\n'){ ! prevCharIsLF = true; ! ! } ! ! bufline[bufpos] = line; ! bufcolumn[bufpos] = column; ! //end UpdateLineCol ! } ! ! return r; ! } catch (ArrayIndexOutOfBoundsException e) { ! bufpos--; ! if (ioException == null){ ! ioException = new IOException(); ! } ! throw ioException; ! } ! } ! /** ! * @deprecated ! * @see #getEndColumn ! */ ! public final int getColumn() { ! return bufcolumn[bufpos]; ! } ! /** ! * @deprecated ! * @see #getEndLine ! */ ! public final int getLine() { ! return bufline[bufpos]; ! } ! public final int getEndColumn() { ! return bufcolumn[bufpos]; ! } ! public final int getEndLine() { ! return bufline[bufpos]; ! } ! public final int getBeginColumn() { ! return bufcolumn[tokenBegin]; ! } ! public final int getBeginLine() { ! return bufline[tokenBegin]; ! } ! public final void backup(int amount) { ! if(DEBUG){ ! System.out.println("FastCharStream: backup >>"+amount+"<<"); ! } ! bufpos -= amount; ! } ! public final char BeginToken() throws IOException { ! char c = readChar(); ! tokenBegin = bufpos; ! if(DEBUG){ ! System.out.println("FastCharStream: BeginToken >>"+(int)c+"<<"); ! } ! return c; ! } ! public final String GetImage() { ! if (bufpos >= tokenBegin) { ! return new String(buffer, tokenBegin, bufpos - tokenBegin+1); ! } else { ! return new String(buffer, tokenBegin, buffer.length - tokenBegin+1); ! } ! } ! public final char[] GetSuffix(int len) { ! char[] ret = new char[len]; ! if (len > 0) { ! try { int initial = bufpos - len +1; if(initial < 0){ *************** *** 165,183 **** System.arraycopy(buffer, initial, ret, 0, len); } ! } catch (Exception e) { ! e.printStackTrace(); ! } ! } ! if(DEBUG){ ! System.out.println("FastCharStream: GetSuffix:"+len+" >>"+new String(ret)+"<<"); ! } ! return ret; ! } ! public final void Done() { ! buffer = null; ! bufline = null; ! bufcolumn = null; ! } } --- 165,183 ---- System.arraycopy(buffer, initial, ret, 0, len); } ! } catch (Exception e) { ! e.printStackTrace(); ! } ! } ! if(DEBUG){ ! System.out.println("FastCharStream: GetSuffix:"+len+" >>"+new String(ret)+"<<"); ! } ! return ret; ! } ! public final void Done() { ! buffer = null; ! bufline = null; ! bufcolumn = null; ! } } |