commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmi...@apache.org
Subject cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/parser SimpleCharStream.java ParseException.java Token.java TokenMgrError.java XPath.jj XPathParser.java XPathParserTokenManager.java jcc.bat JavaCharStream.java
Date Sun, 04 May 2003 23:49:00 GMT
dmitri      2003/05/04 16:48:59

  Modified:    jxpath/src/java/org/apache/commons/jxpath/ri/parser
                        ParseException.java Token.java TokenMgrError.java
                        XPath.jj XPathParser.java
                        XPathParserTokenManager.java jcc.bat
  Added:       jxpath/src/java/org/apache/commons/jxpath/ri/parser
                        SimpleCharStream.java
  Removed:     jxpath/src/java/org/apache/commons/jxpath/ri/parser
                        JavaCharStream.java
  Log:
  Upgraded to JavaCC 3.0, enabled optimizations
  
  Revision  Changes    Path
  1.3       +1 -1      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/parser/ParseException.java
  
  Index: ParseException.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/parser/ParseException.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ParseException.java	25 Jan 2003 01:49:19 -0000	1.2
  +++ ParseException.java	4 May 2003 23:48:59 -0000	1.3
  @@ -1,4 +1,4 @@
  -/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 2.1 */
  +/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */
   package org.apache.commons.jxpath.ri.parser;
   
   /**
  
  
  
  1.3       +2 -2      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/parser/Token.java
  
  Index: Token.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/parser/Token.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Token.java	25 Jan 2003 01:49:19 -0000	1.2
  +++ Token.java	4 May 2003 23:48:59 -0000	1.3
  @@ -1,4 +1,4 @@
  -/* Generated By:JavaCC: Do not edit this line. Token.java Version 2.1 */
  +/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
   package org.apache.commons.jxpath.ri.parser;
   
   /**
  @@ -53,7 +53,7 @@
     /**
      * Returns the image.
      */
  -  public final String toString()
  +  public String toString()
     {
        return image;
     }
  
  
  
  1.4       +3 -5      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/parser/TokenMgrError.java
  
  Index: TokenMgrError.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/parser/TokenMgrError.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TokenMgrError.java	25 Jan 2003 01:49:19 -0000	1.3
  +++ TokenMgrError.java	4 May 2003 23:48:59 -0000	1.4
  @@ -1,4 +1,4 @@
  -/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 2.1 *
  +/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 *
    * 
    * !!!MODIFIED BY DMITRI PLOTNIKOV - DO NOT REGENERATE!!!
    */
  @@ -40,8 +40,6 @@
       * Replaces unprintable characters by their espaced (or unicode escaped)
       * equivalents in the given string
       */
  -   
  -   // MADE PUBLIC - DMITRI PLOTNIKOV
      public static final String addEscapes(String str) {
         StringBuffer retval = new StringBuffer();
         char ch;
  @@ -99,7 +97,7 @@
       *    curchar     : the offending character
       * Note: You can customize the lexical error message by modifying this method.
       */
  -   private static final String LexicalError(boolean EOFSeen, int lexState, int errorLine,
int errorColumn, String errorAfter, char curChar) {
  +   protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int
errorColumn, String errorAfter, char curChar) {
         return("Lexical error at line " +
              errorLine + ", column " +
              errorColumn + ".  Encountered: " +
  @@ -151,5 +149,5 @@
   
      public char getCharacter(){
       return character;
  -   }   
  +   }
   }
  
  
  
  1.6       +3 -3      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/parser/XPath.jj
  
  Index: XPath.jj
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/parser/XPath.jj,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XPath.jj	25 Mar 2003 02:28:43 -0000	1.5
  +++ XPath.jj	4 May 2003 23:48:59 -0000	1.6
  @@ -22,10 +22,10 @@
       DEBUG_PARSER = false;               // (default false)
       DEBUG_LOOKAHEAD = false;            // (default false)
       DEBUG_TOKEN_MANAGER = false;        // (default false)
  -    OPTIMIZE_TOKEN_MANAGER = false;     // (default true)
  +    OPTIMIZE_TOKEN_MANAGER = true;      // (default true)
       ERROR_REPORTING = true;             // (default true)
  -    JAVA_UNICODE_ESCAPE = true;         // (default false)
  -    UNICODE_INPUT = false;              // (default false)
  +    JAVA_UNICODE_ESCAPE = false;        // (default false)
  +    UNICODE_INPUT = true;               // (default false)
       IGNORE_CASE = false;                // (default false)
       COMMON_TOKEN_ACTION = false;        // (default false)
       USER_TOKEN_MANAGER = false;         // (default false)
  
  
  
  1.6       +21 -7     jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/parser/XPathParser.java
  
  Index: XPathParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/parser/XPathParser.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XPathParser.java	25 Mar 2003 02:28:43 -0000	1.5
  +++ XPathParser.java	4 May 2003 23:48:59 -0000	1.6
  @@ -3506,7 +3506,7 @@
     }
   
     public XPathParserTokenManager token_source;
  -  JavaCharStream jj_input_stream;
  +  SimpleCharStream jj_input_stream;
     public Token token, jj_nt;
     private Token jj_scanpos, jj_lastpos;
     private int jj_la;
  @@ -3514,15 +3514,29 @@
     private boolean jj_semLA;
     private int jj_gen;
     final private int[] jj_la1 = new int[39];
  -  final private int[] jj_la1_0 = {0xf8000000,0x78000000,0x0,0x0,0x78000000,0xf80000c0,0xc0,0x40,0xc0,0xc0,0xf8000000,0xf8000000,0x0,0x0,0x0,0x0,0x160000,0xf8000000,0x0,0xf81604c0,0x100,0xf80000c0,0x0,0xc0,0x8000000,0x10000000,0x1800,0x1800,0x1e000,0x1e000,0x200,0x400,0x60000000,0x60000000,0xf81604c0,0xf8000000,0xf8000000,0x0,0x80000000,};
  -  final private int[] jj_la1_1 = {0xffff0007,0x0,0xffff0000,0x0,0x0,0xffffffff,0x0,0x0,0x0,0x0,0xffff0007,0xffffffff,0x0,0xfff8,0xfff8,0x0,0x0,0xffff0007,0x0,0xffffffff,0x0,0xffffffff,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xffffffff,0xffff0007,0xffff0007,0x0,0x7,};
  -  final private int[] jj_la1_2 = {0x7fff,0x4000,0x3fff,0x8000,0x4000,0x14c7fff,0x0,0x0,0x0,0x0,0x1007fff,0x14c7fff,0x100000,0x0,0x0,0x400000,0x10000,0x7fff,0x800000,0x14d7fff,0x0,0x14c7fff,0x100000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1000000,0x1000000,0x14d7fff,0x1007fff,0x1007fff,0x8000,0x0,};
  +  static private int[] jj_la1_0;
  +  static private int[] jj_la1_1;
  +  static private int[] jj_la1_2;
  +  static {
  +      jj_la1_0();
  +      jj_la1_1();
  +      jj_la1_2();
  +   }
  +   private static void jj_la1_0() {
  +      jj_la1_0 = new int[] {0xf8000000,0x78000000,0x0,0x0,0x78000000,0xf80000c0,0xc0,0x40,0xc0,0xc0,0xf8000000,0xf8000000,0x0,0x0,0x0,0x0,0x160000,0xf8000000,0x0,0xf81604c0,0x100,0xf80000c0,0x0,0xc0,0x8000000,0x10000000,0x1800,0x1800,0x1e000,0x1e000,0x200,0x400,0x60000000,0x60000000,0xf81604c0,0xf8000000,0xf8000000,0x0,0x80000000,};
  +   }
  +   private static void jj_la1_1() {
  +      jj_la1_1 = new int[] {0xffff0007,0x0,0xffff0000,0x0,0x0,0xffffffff,0x0,0x0,0x0,0x0,0xffff0007,0xffffffff,0x0,0xfff8,0xfff8,0x0,0x0,0xffff0007,0x0,0xffffffff,0x0,0xffffffff,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xffffffff,0xffff0007,0xffff0007,0x0,0x7,};
  +   }
  +   private static void jj_la1_2() {
  +      jj_la1_2 = new int[] {0x7fff,0x4000,0x3fff,0x8000,0x4000,0x14c7fff,0x0,0x0,0x0,0x0,0x1007fff,0x14c7fff,0x100000,0x0,0x0,0x400000,0x10000,0x7fff,0x800000,0x14d7fff,0x0,0x14c7fff,0x100000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1000000,0x1000000,0x14d7fff,0x1007fff,0x1007fff,0x8000,0x0,};
  +   }
     final private JJCalls[] jj_2_rtns = new JJCalls[6];
     private boolean jj_rescan = false;
     private int jj_gc = 0;
   
     public XPathParser(java.io.InputStream stream) {
  -    jj_input_stream = new JavaCharStream(stream, 1, 1);
  +    jj_input_stream = new SimpleCharStream(stream, 1, 1);
       token_source = new XPathParserTokenManager(jj_input_stream);
       token = new Token();
       token.next = jj_nt = token_source.getNextToken();
  @@ -3542,7 +3556,7 @@
     }
   
     public XPathParser(java.io.Reader stream) {
  -    jj_input_stream = new JavaCharStream(stream, 1, 1);
  +    jj_input_stream = new SimpleCharStream(stream, 1, 1);
       token_source = new XPathParserTokenManager(jj_input_stream);
       token = new Token();
       token.next = jj_nt = token_source.getNextToken();
  @@ -3672,7 +3686,7 @@
       }
     }
   
  -  final public ParseException generateParseException() {
  +  public ParseException generateParseException() {
       jj_expentries.removeAllElements();
       boolean[] la1tokens = new boolean[89];
       for (int i = 0; i < 89; i++) {
  
  
  
  1.6       +8 -8      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/parser/XPathParserTokenManager.java
  
  Index: XPathParserTokenManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/parser/XPathParserTokenManager.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XPathParserTokenManager.java	25 Mar 2003 02:28:43 -0000	1.5
  +++ XPathParserTokenManager.java	4 May 2003 23:48:59 -0000	1.6
  @@ -1744,22 +1744,22 @@
   static final long[] jjtoSkip = {
      0x3eL, 0x0L, 
   };
  -private JavaCharStream input_stream;
  +protected SimpleCharStream input_stream;
   private final int[] jjrounds = new int[13];
   private final int[] jjstateSet = new int[26];
   protected char curChar;
  -public XPathParserTokenManager(JavaCharStream stream)
  +public XPathParserTokenManager(SimpleCharStream stream)
   {
  -   if (JavaCharStream.staticFlag)
  +   if (SimpleCharStream.staticFlag)
         throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical
analyzer.");
      input_stream = stream;
   }
  -public XPathParserTokenManager(JavaCharStream stream, int lexState)
  +public XPathParserTokenManager(SimpleCharStream stream, int lexState)
   {
      this(stream);
      SwitchTo(lexState);
   }
  -public void ReInit(JavaCharStream stream)
  +public void ReInit(SimpleCharStream stream)
   {
      jjmatchedPos = jjnewStateCnt = 0;
      curLexState = defaultLexState;
  @@ -1773,7 +1773,7 @@
      for (i = 13; i-- > 0;)
         jjrounds[i] = 0x80000000;
   }
  -public void ReInit(JavaCharStream stream, int lexState)
  +public void ReInit(SimpleCharStream stream, int lexState)
   {
      ReInit(stream);
      SwitchTo(lexState);
  @@ -1786,7 +1786,7 @@
         curLexState = lexState;
   }
   
  -private final Token jjFillToken()
  +protected Token jjFillToken()
   {
      Token t = Token.newToken(jjmatchedKind);
      t.kind = jjmatchedKind;
  @@ -1806,7 +1806,7 @@
   int jjmatchedPos;
   int jjmatchedKind;
   
  -public final Token getNextToken() 
  +public Token getNextToken() 
   {
     int kind;
     Token specialToken = null;
  
  
  
  1.3       +1 -1      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/parser/jcc.bat
  
  Index: jcc.bat
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/parser/jcc.bat,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- jcc.bat	25 Jan 2003 01:49:19 -0000	1.2
  +++ jcc.bat	4 May 2003 23:48:59 -0000	1.3
  @@ -1,6 +1,6 @@
   @echo off
   
  -set JAVACC_HOME=c:\tools\javacc2.1
  +set JAVACC_HOME=c:\tools\javacc-3.0
   
   call %JAVACC_HOME%\bin\javacc.bat XPath.jj
   call %JAVACC_HOME%\bin\jjdoc.bat  XPath.jj
  
  
  
  1.1                  jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/parser/SimpleCharStream.java
  
  Index: SimpleCharStream.java
  ===================================================================
  /* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 3.0 */
  package org.apache.commons.jxpath.ri.parser;
  
  /**
   * An implementation of interface CharStream, where the stream is assumed to
   * contain only ASCII characters (without unicode processing).
   */
  
  public class SimpleCharStream
  {
    public static final boolean staticFlag = false;
    int bufsize;
    int available;
    int tokenBegin;
    public int bufpos = -1;
    protected int bufline[];
    protected int bufcolumn[];
  
    protected int column = 0;
    protected int line = 1;
  
    protected boolean prevCharIsCR = false;
    protected boolean prevCharIsLF = false;
  
    protected java.io.Reader inputStream;
  
    protected char[] buffer;
    protected int maxNextCharInd = 0;
    protected int inBuf = 0;
  
    protected 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;
    }
  
    protected 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 char BeginToken() throws java.io.IOException
    {
       tokenBegin = -1;
       char c = readChar();
       tokenBegin = bufpos;
  
       return c;
    }
  
    protected 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;
          case '\t' :
             column--;
             column += (8 - (column & 07));
             break;
          default :
             break;
       }
  
       bufline[bufpos] = line;
       bufcolumn[bufpos] = column;
    }
  
    public char readChar() throws java.io.IOException
    {
       if (inBuf > 0)
       {
          --inBuf;
  
          if (++bufpos == bufsize)
             bufpos = 0;
  
          return buffer[bufpos];
       }
  
       if (++bufpos >= maxNextCharInd)
          FillBuff();
  
       char c = buffer[bufpos];
  
       UpdateLineColumn(c);
       return (c);
    }
  
    /**
     * @deprecated 
     * @see #getEndColumn
     */
  
    public int getColumn() {
       return bufcolumn[bufpos];
    }
  
    /**
     * @deprecated 
     * @see #getEndLine
     */
  
    public int getLine() {
       return bufline[bufpos];
    }
  
    public int getEndColumn() {
       return bufcolumn[bufpos];
    }
  
    public int getEndLine() {
       return bufline[bufpos];
    }
  
    public int getBeginColumn() {
       return bufcolumn[tokenBegin];
    }
  
    public int getBeginLine() {
       return bufline[tokenBegin];
    }
  
    public void backup(int amount) {
  
      inBuf += amount;
      if ((bufpos -= amount) < 0)
         bufpos += bufsize;
    }
  
    public SimpleCharStream(java.io.Reader dstream, int startline,
    int startcolumn, int buffersize)
    {
      inputStream = dstream;
      line = startline;
      column = startcolumn - 1;
  
      available = bufsize = buffersize;
      buffer = new char[buffersize];
      bufline = new int[buffersize];
      bufcolumn = new int[buffersize];
    }
  
    public SimpleCharStream(java.io.Reader dstream, int startline,
                                                             int startcolumn)
    {
       this(dstream, startline, startcolumn, 4096);
    }
  
    public SimpleCharStream(java.io.Reader dstream)
    {
       this(dstream, 1, 1, 4096);
    }
    public void ReInit(java.io.Reader dstream, int startline,
    int startcolumn, int buffersize)
    {
      inputStream = dstream;
      line = startline;
      column = startcolumn - 1;
  
      if (buffer == null || buffersize != buffer.length)
      {
        available = bufsize = buffersize;
        buffer = new char[buffersize];
        bufline = new int[buffersize];
        bufcolumn = new int[buffersize];
      }
      prevCharIsLF = prevCharIsCR = false;
      tokenBegin = inBuf = maxNextCharInd = 0;
      bufpos = -1;
    }
  
    public void ReInit(java.io.Reader dstream, int startline,
                                                             int startcolumn)
    {
       ReInit(dstream, startline, startcolumn, 4096);
    }
  
    public void ReInit(java.io.Reader dstream)
    {
       ReInit(dstream, 1, 1, 4096);
    }
    public SimpleCharStream(java.io.InputStream dstream, int startline,
    int startcolumn, int buffersize)
    {
       this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
    }
  
    public SimpleCharStream(java.io.InputStream dstream, int startline,
                                                             int startcolumn)
    {
       this(dstream, startline, startcolumn, 4096);
    }
  
    public SimpleCharStream(java.io.InputStream dstream)
    {
       this(dstream, 1, 1, 4096);
    }
  
    public void ReInit(java.io.InputStream dstream, int startline,
                            int startcolumn, int buffersize)
    {
       ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
    }
  
    public void ReInit(java.io.InputStream dstream)
    {
       ReInit(dstream, 1, 1, 4096);
    }
    public void ReInit(java.io.InputStream dstream, int startline,
                                                             int startcolumn)
    {
       ReInit(dstream, startline, startcolumn, 4096);
    }
    public String GetImage()
    {
       if (bufpos >= tokenBegin)
          return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
       else
          return new String(buffer, tokenBegin, bufsize - tokenBegin) +
                                new String(buffer, 0, bufpos + 1);
    }
  
    public 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);
       }
  
       return ret;
    }
  
    public void Done()
    {
       buffer = null;
       bufline = null;
       bufcolumn = null;
    }
  
    /**
     * Method to adjust line and column numbers for the start of a token.<BR>
     */
    public void adjustBeginLineColumn(int newLine, int newCol)
    {
       int start = tokenBegin;
       int len;
  
       if (bufpos >= tokenBegin)
       {
          len = bufpos - tokenBegin + inBuf + 1;
       }
       else
       {
          len = bufsize - tokenBegin + bufpos + 1 + inBuf;
       }
  
       int i = 0, j = 0, k = 0;
       int nextColDiff = 0, columnDiff = 0;
  
       while (i < len &&
              bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
       {
          bufline[j] = newLine;
          nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
          bufcolumn[j] = newCol + columnDiff;
          columnDiff = nextColDiff;
          i++;
       } 
  
       if (i < len)
       {
          bufline[j] = newLine++;
          bufcolumn[j] = newCol + columnDiff;
  
          while (i++ < len)
          {
             if (bufline[j = start % bufsize] != bufline[++start % bufsize])
                bufline[j] = newLine++;
             else
                bufline[j] = newLine;
          }
       }
  
       line = bufline[j];
       column = bufcolumn[j];
    }
  
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message