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 0049aa7..e6aa7e0 100644 --- a/net.sourceforge.phpeclipse/src/test/SimpleCharStream.java +++ b/net.sourceforge.phpeclipse/src/test/SimpleCharStream.java @@ -1,4 +1,4 @@ -/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 2.1 */ +/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 3.0 */ package test; /** @@ -6,29 +6,36 @@ package test; * contain only ASCII characters (without unicode processing). */ -public final class SimpleCharStream +public class SimpleCharStream { public static final boolean staticFlag = true; static int bufsize; static int available; static int tokenBegin; static public int bufpos = -1; - static private int bufline[]; - static private int bufcolumn[]; - static private int column = 0; - static private int line = 1; + //Added by Matthieu Casanova + public static int position = 0; - static private boolean prevCharIsCR = false; - static private boolean prevCharIsLF = false; + public static int beginOffset, endOffset; - static private java.io.Reader inputStream; + static protected int bufline[]; + static protected int bufcolumn[]; - static private char[] buffer; - static private int maxNextCharInd = 0; - static private int inBuf = 0; + static protected int column = 0; + static protected int line = 1; - static private final void ExpandBuff(boolean wrapAround) + static protected boolean prevCharIsCR = false; + static protected boolean prevCharIsLF = false; + + static protected java.io.Reader inputStream; + static 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) { char[] newbuffer = new char[bufsize + 2048]; int newbufline[] = new int[bufsize + 2048]; @@ -78,7 +85,7 @@ public final class SimpleCharStream tokenBegin = 0; } - static private final void FillBuff() throws java.io.IOException + static protected void FillBuff() throws java.io.IOException { if (maxNextCharInd == available) { @@ -86,12 +93,14 @@ public final class SimpleCharStream { if (tokenBegin > 2048) { + position += bufpos; bufpos = maxNextCharInd = 0; available = tokenBegin; } - else if (tokenBegin < 0) + else if (tokenBegin < 0) { + position += bufpos; bufpos = maxNextCharInd = 0; - else + } else ExpandBuff(false); } else if (available > tokenBegin) @@ -110,8 +119,10 @@ public final class SimpleCharStream inputStream.close(); throw new java.io.IOException(); } - else + else { maxNextCharInd += i; + } + currentBuffer.append(buffer); return; } catch(java.io.IOException e) { @@ -123,8 +134,9 @@ public final class SimpleCharStream } } - static public final char BeginToken() throws java.io.IOException + static public char BeginToken() throws java.io.IOException { + beginOffset = endOffset; tokenBegin = -1; char c = readChar(); tokenBegin = bufpos; @@ -132,7 +144,7 @@ public final class SimpleCharStream return c; } - static private final void UpdateLineColumn(char c) + static protected void UpdateLineColumn(char c) { column++; @@ -170,22 +182,27 @@ public final class SimpleCharStream bufline[bufpos] = line; bufcolumn[bufpos] = column; + } - static public final char readChar() throws java.io.IOException + static public char readChar() throws java.io.IOException { + endOffset++; if (inBuf > 0) { --inBuf; - if (++bufpos == bufsize) + if (++bufpos == bufsize) { + position += bufpos; bufpos = 0; + } return buffer[bufpos]; } - if (++bufpos >= maxNextCharInd) - FillBuff(); + if (++bufpos >= maxNextCharInd) { + FillBuff(); + } char c = buffer[bufpos]; @@ -194,41 +211,41 @@ public final class SimpleCharStream } /** - * @deprecated + * @deprecated * @see #getEndColumn */ - static public final int getColumn() { + static public int getColumn() { return bufcolumn[bufpos]; } /** - * @deprecated + * @deprecated * @see #getEndLine */ - static public final int getLine() { + static public int getLine() { return bufline[bufpos]; } - static public final int getEndColumn() { + static public int getEndColumn() { return bufcolumn[bufpos]; } - static public final int getEndLine() { + static public int getEndLine() { return bufline[bufpos]; } - static public final int getBeginColumn() { + static public int getBeginColumn() { return bufcolumn[tokenBegin]; } - static public final int getBeginLine() { + static public int getBeginLine() { return bufline[tokenBegin]; } - static public final void backup(int amount) { - + static public void backup(int amount) { + endOffset -= amount; inBuf += amount; if ((bufpos -= amount) < 0) bufpos += bufsize; @@ -242,6 +259,7 @@ public final class SimpleCharStream " either use ReInit() or set the JavaCC option STATIC to false\n" + " during the generation of this class."); inputStream = dstream; + currentBuffer = new StringBuffer(); line = startline; column = startcolumn - 1; @@ -249,6 +267,9 @@ public final class SimpleCharStream buffer = new char[buffersize]; bufline = new int[buffersize]; bufcolumn = new int[buffersize]; + beginOffset = 0; + endOffset = 0; + } public SimpleCharStream(java.io.Reader dstream, int startline, @@ -265,6 +286,7 @@ public final class SimpleCharStream int startcolumn, int buffersize) { inputStream = dstream; + currentBuffer = new StringBuffer(); line = startline; column = startcolumn - 1; @@ -278,6 +300,9 @@ public final class SimpleCharStream prevCharIsLF = prevCharIsCR = false; tokenBegin = inBuf = maxNextCharInd = 0; bufpos = -1; + position = 0; + beginOffset = 0; + endOffset = 0; } public void ReInit(java.io.Reader dstream, int startline, @@ -322,7 +347,7 @@ public final class SimpleCharStream { ReInit(dstream, startline, startcolumn, 4096); } - static public final String GetImage() + static public String GetImage() { if (bufpos >= tokenBegin) return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); @@ -331,7 +356,7 @@ public final class SimpleCharStream new String(buffer, 0, bufpos + 1); } - static public final char[] GetSuffix(int len) + static public char[] GetSuffix(int len) { char[] ret = new char[len]; @@ -352,6 +377,7 @@ public final class SimpleCharStream buffer = null; bufline = null; bufcolumn = null; + } /** @@ -382,7 +408,7 @@ public final class SimpleCharStream bufcolumn[j] = newCol + columnDiff; columnDiff = nextColDiff; i++; - } + } if (i < len) { @@ -391,10 +417,11 @@ public final 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; + } } } @@ -402,4 +429,11 @@ public final class SimpleCharStream column = bufcolumn[j]; } + /** + * @deprecated + * @return + */ + public static int getPosition() { + return position + bufpos; + } }