org.jacaranda.verifier
Class JacarandaFilterStream

java.lang.Object
  extended by org.antlr.runtime.ANTLRStringStream
      extended by org.jacaranda.verifier.JacarandaFilterStream
All Implemented Interfaces:
org.antlr.runtime.CharStream, org.antlr.runtime.IntStream

public class JacarandaFilterStream
extends org.antlr.runtime.ANTLRStringStream

A subclass of ANTLRStringStream with the following customizations:

FILTER_CDATA errors are stored in a FIFO rather than reported immediately, because the error message and the correct rewriting depend on what lexical token type the error occurs in, which is not known in this stream class. It would be difficult for the lexer to directly detect these errors itself, because chars are consumed at many places in the generated lexer source. The only single place at which to hook char consumption is the consume() method of the input CharStream (or an earlier point in the input pipeline, which would be no simpler).


Field Summary
 
Fields inherited from class org.antlr.runtime.ANTLRStringStream
charPositionInLine, data, lastMarker, line, markDepth, markers, n, name, p
 
Fields inherited from interface org.antlr.runtime.CharStream
EOF
 
Constructor Summary
JacarandaFilterStream(char[] chars, int length, int tabStopColumns)
          Construct a JacarandaFilterStream that will take its input from the first 'length' code units of array 'chars', and will use the given tab stop distance.
JacarandaFilterStream(java.lang.String source, int tabStopColumns)
          Construct a JacarandaFilterStream that will take its input from the string 'source', and will use the given tab stop distance.
 
Method Summary
 void consume()
          Consume the next char.
 int getColumn()
          Obtain the current column position.
 ErrorRecord nextError(int stopIndex)
          If there is a queued error record for a position up to and including the given stopIndex, remove and return it.
 ErrorRecord nextErrorSoFar()
          If there is any queued error record, remove and return it.
 void rewindToToken(org.antlr.runtime.CommonToken t)
          Rewind the current position to the start of the given token, so that the first char of that token will be consumed next.
 java.lang.String substring(int start, int stop)
           
 
Methods inherited from class org.antlr.runtime.ANTLRStringStream
getCharPositionInLine, getLine, getSourceName, index, LA, LT, mark, release, reset, rewind, rewind, seek, setCharPositionInLine, setLine, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JacarandaFilterStream

public JacarandaFilterStream(java.lang.String source,
                             int tabStopColumns)
Construct a JacarandaFilterStream that will take its input from the string 'source', and will use the given tab stop distance.


JacarandaFilterStream

public JacarandaFilterStream(char[] chars,
                             int length,
                             int tabStopColumns)
Construct a JacarandaFilterStream that will take its input from the first 'length' code units of array 'chars', and will use the given tab stop distance.

Method Detail

getColumn

public int getColumn()
Obtain the current column position. The leftmost column in a line is column 1.


nextError

public ErrorRecord nextError(int stopIndex)
If there is a queued error record for a position up to and including the given stopIndex, remove and return it. Otherwise (also when the next error record is for a later index), return null.


nextErrorSoFar

public ErrorRecord nextErrorSoFar()
If there is any queued error record, remove and return it. Otherwise return null.


consume

public void consume()
Consume the next char.

Specified by:
consume in interface org.antlr.runtime.IntStream
Overrides:
consume in class org.antlr.runtime.ANTLRStringStream

rewindToToken

public void rewindToToken(org.antlr.runtime.CommonToken t)
Rewind the current position to the start of the given token, so that the first char of that token will be consumed next.


substring

public java.lang.String substring(int start,
                                  int stop)
Specified by:
substring in interface org.antlr.runtime.CharStream
Overrides:
substring in class org.antlr.runtime.ANTLRStringStream