X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/test/SimpleCharStream.java b/net.sourceforge.phpeclipse/src/test/SimpleCharStream.java index e6aa7e0..3ccaf79 100644 --- a/net.sourceforge.phpeclipse/src/test/SimpleCharStream.java +++ b/net.sourceforge.phpeclipse/src/test/SimpleCharStream.java @@ -8,34 +8,31 @@ package test; public class SimpleCharStream { - public static final boolean staticFlag = true; - static int bufsize; - static int available; - static int tokenBegin; - static public int bufpos = -1; + public static final boolean staticFlag = false; + int bufsize; + int available; + int tokenBegin; + public int bufpos = -1; - //Added by Matthieu Casanova - public static int position = 0; + protected int beginOffset, endOffset; - public static int beginOffset, endOffset; + protected int bufline[]; + protected int bufcolumn[]; - static protected int bufline[]; - static protected int bufcolumn[]; + protected int column = 0; + protected int line = 1; - static protected int column = 0; - static protected int line = 1; + protected boolean prevCharIsCR = false; + protected boolean prevCharIsLF = false; - static protected boolean prevCharIsCR = false; - static protected boolean prevCharIsLF = false; + protected java.io.Reader inputStream; - static protected java.io.Reader inputStream; - static protected StringBuffer currentBuffer = new StringBuffer(); + protected char[] buffer; + protected int maxNextCharInd = 0; + protected int inBuf = 0; + protected StringBuffer currentBuffer = new StringBuffer(); - static protected char[] buffer; - static protected int maxNextCharInd = 0; - static protected int inBuf = 0; - - static protected void ExpandBuff(boolean wrapAround) + protected void ExpandBuff(boolean wrapAround) { char[] newbuffer = new char[bufsize + 2048]; int newbufline[] = new int[bufsize + 2048]; @@ -85,7 +82,7 @@ public class SimpleCharStream tokenBegin = 0; } - static protected void FillBuff() throws java.io.IOException + protected void FillBuff() throws java.io.IOException { if (maxNextCharInd == available) { @@ -134,7 +131,7 @@ public class SimpleCharStream } } - static public char BeginToken() throws java.io.IOException + public char BeginToken() throws java.io.IOException { beginOffset = endOffset; tokenBegin = -1; @@ -144,7 +141,7 @@ public class SimpleCharStream return c; } - static protected void UpdateLineColumn(char c) + protected void UpdateLineColumn(char c) { column++; @@ -182,10 +179,9 @@ public class SimpleCharStream bufline[bufpos] = line; bufcolumn[bufpos] = column; - } - static public char readChar() throws java.io.IOException + public char readChar() throws java.io.IOException { endOffset++; if (inBuf > 0) @@ -200,9 +196,8 @@ public class SimpleCharStream return buffer[bufpos]; } - if (++bufpos >= maxNextCharInd) { - FillBuff(); - } + if (++bufpos >= maxNextCharInd) + FillBuff(); char c = buffer[bufpos]; @@ -211,40 +206,41 @@ public class SimpleCharStream } /** - * @deprecated + * @deprecated * @see #getEndColumn */ - static public int getColumn() { + public int getColumn() { return bufcolumn[bufpos]; } /** - * @deprecated + * @deprecated * @see #getEndLine */ - static public int getLine() { + public int getLine() { return bufline[bufpos]; } - static public int getEndColumn() { + public int getEndColumn() { return bufcolumn[bufpos]; } - static public int getEndLine() { + public int getEndLine() { return bufline[bufpos]; } - static public int getBeginColumn() { + public int getBeginColumn() { return bufcolumn[tokenBegin]; } - static public int getBeginLine() { + public int getBeginLine() { return bufline[tokenBegin]; } - static public void backup(int amount) { + public void backup(int amount) { + endOffset -= amount; inBuf += amount; if ((bufpos -= amount) < 0) @@ -254,12 +250,8 @@ public class SimpleCharStream public SimpleCharStream(java.io.Reader dstream, int startline, int startcolumn, int buffersize) { - if (inputStream != null) - throw new Error("\n ERROR: Second call to the constructor of a static SimpleCharStream. You must\n" + - " either use ReInit() or set the JavaCC option STATIC to false\n" + - " during the generation of this class."); inputStream = dstream; - currentBuffer = new StringBuffer(); + currentBuffer = new StringBuffer(); line = startline; column = startcolumn - 1; @@ -269,7 +261,6 @@ public class SimpleCharStream bufcolumn = new int[buffersize]; beginOffset = 0; endOffset = 0; - } public SimpleCharStream(java.io.Reader dstream, int startline, @@ -347,7 +338,7 @@ public class SimpleCharStream { ReInit(dstream, startline, startcolumn, 4096); } - static public String GetImage() + public String GetImage() { if (bufpos >= tokenBegin) return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); @@ -356,7 +347,7 @@ public class SimpleCharStream new String(buffer, 0, bufpos + 1); } - static public char[] GetSuffix(int len) + public char[] GetSuffix(int len) { char[] ret = new char[len]; @@ -372,18 +363,17 @@ public class SimpleCharStream return ret; } - static public void Done() + public void Done() { buffer = null; bufline = null; bufcolumn = null; - } /** * Method to adjust line and column numbers for the start of a token.
*/ - static public void adjustBeginLineColumn(int newLine, int newCol) + public void adjustBeginLineColumn(int newLine, int newCol) { int start = tokenBegin; int len; @@ -408,7 +398,7 @@ public class SimpleCharStream bufcolumn[j] = newCol + columnDiff; columnDiff = nextColDiff; i++; - } + } if (i < len) { @@ -417,11 +407,10 @@ public class SimpleCharStream while (i++ < len) { - if (bufline[j = start % bufsize] != bufline[++start % bufsize]) { + if (bufline[j = start % bufsize] != bufline[++start % bufsize]) bufline[j] = newLine++; - } else { + else bufline[j] = newLine; - } } } @@ -429,11 +418,25 @@ public class SimpleCharStream column = bufcolumn[j]; } + public StringBuffer getCurrentBuffer() { + return currentBuffer; + } + + //Added by Matthieu Casanova + public int position = 0; /** * @deprecated * @return */ - public static int getPosition() { + public int getPosition() { return position + bufpos; } + + public int getBeginOffset() { + return beginOffset; + } + + public int getEndOffset() { + return endOffset; + } }