3.x RC1 compatibility
[phpeclipse.git] / net.sourceforge.phpeclipse / src / test / SimpleCharStream.java
index 0049aa7..3ccaf79 100644 (file)
@@ -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,33 @@ 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[];
+  public static final boolean staticFlag = false;
+  int bufsize;
+  int available;
+  int tokenBegin;
+  public int bufpos = -1;
 
-  static private int column = 0;
-  static private int line = 1;
+  protected int beginOffset, endOffset;
 
-  static private boolean prevCharIsCR = false;
-  static private boolean prevCharIsLF = false;
+  protected int bufline[];
+  protected int bufcolumn[];
 
-  static private java.io.Reader inputStream;
+  protected int column = 0;
+  protected int line = 1;
 
-  static private char[] buffer;
-  static private int maxNextCharInd = 0;
-  static private int inBuf = 0;
+  protected boolean prevCharIsCR = false;
+  protected boolean prevCharIsLF = false;
 
-  static private final void ExpandBuff(boolean wrapAround)
+  protected java.io.Reader inputStream;
+
+  protected char[] buffer;
+  protected int maxNextCharInd = 0;
+  protected int inBuf = 0;
+  protected StringBuffer currentBuffer = new StringBuffer();
+
+  protected void ExpandBuff(boolean wrapAround)
   {
      char[] newbuffer = new char[bufsize + 2048];
      int newbufline[] = new int[bufsize + 2048];
@@ -78,7 +82,7 @@ public final class SimpleCharStream
      tokenBegin = 0;
   }
 
-  static private final void FillBuff() throws java.io.IOException
+  protected void FillBuff() throws java.io.IOException
   {
      if (maxNextCharInd == available)
      {
@@ -86,12 +90,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 +116,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 +131,9 @@ public final class SimpleCharStream
      }
   }
 
-  static public final char BeginToken() throws java.io.IOException
+  public char BeginToken() throws java.io.IOException
   {
+     beginOffset = endOffset;
      tokenBegin = -1;
      char c = readChar();
      tokenBegin = bufpos;
@@ -132,7 +141,7 @@ public final class SimpleCharStream
      return c;
   }
 
-  static private final void UpdateLineColumn(char c)
+  protected void UpdateLineColumn(char c)
   {
      column++;
 
@@ -172,14 +181,17 @@ public final class SimpleCharStream
      bufcolumn[bufpos] = column;
   }
 
-  static public final char readChar() throws java.io.IOException
+  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];
      }
@@ -198,7 +210,7 @@ public final class SimpleCharStream
    * @see #getEndColumn
    */
 
-  static public final int getColumn() {
+  public int getColumn() {
      return bufcolumn[bufpos];
   }
 
@@ -207,28 +219,29 @@ public final class SimpleCharStream
    * @see #getEndLine
    */
 
-  static public final int getLine() {
+  public int getLine() {
      return bufline[bufpos];
   }
 
-  static public final int getEndColumn() {
+  public int getEndColumn() {
      return bufcolumn[bufpos];
   }
 
-  static public final int getEndLine() {
+  public int getEndLine() {
      return bufline[bufpos];
   }
 
-  static public final int getBeginColumn() {
+  public int getBeginColumn() {
      return bufcolumn[tokenBegin];
   }
 
-  static public final int getBeginLine() {
+  public int getBeginLine() {
      return bufline[tokenBegin];
   }
 
-  static public final void backup(int amount) {
+  public void backup(int amount) {
 
+    endOffset -= amount;
     inBuf += amount;
     if ((bufpos -= amount) < 0)
        bufpos += bufsize;
@@ -237,11 +250,8 @@ public final 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();
     line = startline;
     column = startcolumn - 1;
 
@@ -249,6 +259,8 @@ 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 +277,7 @@ public final class SimpleCharStream
   int startcolumn, int buffersize)
   {
     inputStream = dstream;
+    currentBuffer = new StringBuffer();
     line = startline;
     column = startcolumn - 1;
 
@@ -278,6 +291,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 +338,7 @@ public final class SimpleCharStream
   {
      ReInit(dstream, startline, startcolumn, 4096);
   }
-  static public final String GetImage()
+  public String GetImage()
   {
      if (bufpos >= tokenBegin)
         return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
@@ -331,7 +347,7 @@ public final class SimpleCharStream
                               new String(buffer, 0, bufpos + 1);
   }
 
-  static public final char[] GetSuffix(int len)
+  public char[] GetSuffix(int len)
   {
      char[] ret = new char[len];
 
@@ -347,7 +363,7 @@ public final class SimpleCharStream
      return ret;
   }
 
-  static public void Done()
+  public void Done()
   {
      buffer = null;
      bufline = null;
@@ -357,7 +373,7 @@ public final class SimpleCharStream
   /**
    * Method to adjust line and column numbers for the start of a token.<BR>
    */
-  static public void adjustBeginLineColumn(int newLine, int newCol)
+  public void adjustBeginLineColumn(int newLine, int newCol)
   {
      int start = tokenBegin;
      int len;
@@ -402,4 +418,25 @@ public final class SimpleCharStream
      column = bufcolumn[j];
   }
 
+    public StringBuffer getCurrentBuffer() {
+        return currentBuffer;
+    }
+
+    //Added by Matthieu Casanova
+    public int position = 0;
+  /**
+   * @deprecated
+   * @return
+   */
+  public int getPosition() {
+    return position + bufpos;
+  }
+
+    public int getBeginOffset() {
+        return beginOffset;
+    }
+
+    public int getEndOffset() {
+        return endOffset;
+    }
 }