a lot of bugfixes
[phpeclipse.git] / net.sourceforge.phpeclipse / src / test / SimpleCharStream.java
index 1187798..e6aa7e0 100644 (file)
@@ -17,6 +17,8 @@ public class SimpleCharStream
   //Added by Matthieu Casanova
   public static int position = 0;
 
+  public static int beginOffset, endOffset;
+
   static protected int bufline[];
   static protected int bufcolumn[];
 
@@ -27,6 +29,7 @@ public class SimpleCharStream
   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;
@@ -119,6 +122,7 @@ public class SimpleCharStream
         else {
            maxNextCharInd += i;
         }
+        currentBuffer.append(buffer);
         return;
      }
      catch(java.io.IOException e) {
@@ -132,6 +136,7 @@ public class SimpleCharStream
 
   static public char BeginToken() throws java.io.IOException
   {
+     beginOffset = endOffset;
      tokenBegin = -1;
      char c = readChar();
      tokenBegin = bufpos;
@@ -177,10 +182,12 @@ public class SimpleCharStream
 
      bufline[bufpos] = line;
      bufcolumn[bufpos] = column;
+
   }
 
   static public char readChar() throws java.io.IOException
   {
+    endOffset++;
      if (inBuf > 0)
      {
         --inBuf;
@@ -204,7 +211,7 @@ public class SimpleCharStream
   }
 
   /**
-   * @deprecated 
+   * @deprecated
    * @see #getEndColumn
    */
 
@@ -213,7 +220,7 @@ public class SimpleCharStream
   }
 
   /**
-   * @deprecated 
+   * @deprecated
    * @see #getEndLine
    */
 
@@ -238,7 +245,7 @@ public class SimpleCharStream
   }
 
   static public void backup(int amount) {
-
+    endOffset -= amount;
     inBuf += amount;
     if ((bufpos -= amount) < 0)
        bufpos += bufsize;
@@ -252,6 +259,7 @@ public 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;
 
@@ -259,6 +267,9 @@ public 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,
@@ -275,6 +286,7 @@ public class SimpleCharStream
   int startcolumn, int buffersize)
   {
     inputStream = dstream;
+    currentBuffer = new StringBuffer();
     line = startline;
     column = startcolumn - 1;
 
@@ -289,6 +301,8 @@ public class SimpleCharStream
     tokenBegin = inBuf = maxNextCharInd = 0;
     bufpos = -1;
     position = 0;
+    beginOffset = 0;
+    endOffset = 0;
   }
 
   public void ReInit(java.io.Reader dstream, int startline,
@@ -363,6 +377,7 @@ public class SimpleCharStream
      buffer = null;
      bufline = null;
      bufcolumn = null;
+
   }
 
   /**
@@ -393,7 +408,7 @@ public class SimpleCharStream
         bufcolumn[j] = newCol + columnDiff;
         columnDiff = nextColDiff;
         i++;
-     } 
+     }
 
      if (i < len)
      {
@@ -402,10 +417,11 @@ 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;
+           }
         }
      }
 
@@ -413,7 +429,10 @@ public class SimpleCharStream
      column = bufcolumn[j];
   }
 
-  //hack
+  /**
+   * @deprecated
+   * @return
+   */
   public static int getPosition() {
     return position + bufpos;
   }