Class LookaheadStream<T>
java.lang.Object
org.antlr.runtime.misc.FastQueue<T>
org.antlr.runtime.misc.LookaheadStream<T>
- Direct Known Subclasses:
CommonTreeNodeStream, UnbufferedTokenStream
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intAbsolute token index.Track object returned by nextElement upon end of stream; Return it later when they ask for LT passed end of input.protected intTrack the last mark() call result value for use in rewind().protected inttracks how deep mark() calls are nestedprotected TThis is theLT(-1)element for the first element inFastQueue.data.static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidconsume()Make sure we have at least one element to remove, even if EOFvoidfill(int n) add n elements to bufferintindex()abstract booleanprotected TLB(int k) LT(int k) intmark()abstract TImplement nextElement to supply a stream of elements to this lookahead buffer.voidrelease(int marker) remove()Get and remove first element in queue; overrideFastQueue.remove(); it's the same, just checks for backtracking.voidreset()voidrewind()voidrewind(int marker) voidseek(int index) Seek to a 0-indexed absolute token index.intsize()Size of entire stream is unknown; we only know buffer size from FastQueue.protected voidsyncAhead(int need) Make sure we have 'need' elements from current position p.
-
Field Details
-
UNINITIALIZED_EOF_ELEMENT_INDEX
public static final int UNINITIALIZED_EOF_ELEMENT_INDEX- See Also:
-
currentElementIndex
protected int currentElementIndexAbsolute token index. It's the index of the symbol about to be read viaLT(1). Goes from 0 to numtokens. -
prevElement
This is theLT(-1)element for the first element inFastQueue.data. -
eof
Track object returned by nextElement upon end of stream; Return it later when they ask for LT passed end of input. -
lastMarker
protected int lastMarkerTrack the last mark() call result value for use in rewind(). -
markDepth
protected int markDepthtracks how deep mark() calls are nested
-
-
Constructor Details
-
LookaheadStream
public LookaheadStream()
-
-
Method Details
-
reset
-
nextElement
Implement nextElement to supply a stream of elements to this lookahead buffer. Return EOF upon end of the stream we're pulling from.- See Also:
-
isEOF
-
remove
Get and remove first element in queue; overrideFastQueue.remove(); it's the same, just checks for backtracking. -
consume
public void consume()Make sure we have at least one element to remove, even if EOF -
syncAhead
protected void syncAhead(int need) Make sure we have 'need' elements from current position p. Last valid p index is data.size()-1. p+need-1 is the data index 'need' elements ahead. If we need 1 element, (p+1-1)==p must be < data.size(). -
fill
public void fill(int n) add n elements to buffer -
size
-
LT
-
index
public int index() -
mark
public int mark() -
release
public void release(int marker) -
rewind
public void rewind(int marker) -
rewind
public void rewind() -
seek
public void seek(int index) Seek to a 0-indexed absolute token index. Normally used to seek backwards in the buffer. Does not force loading of nodes.To preserve backward compatibility, this method allows seeking past the end of the currently buffered data. In this case, the input pointer will be moved but the data will only actually be loaded upon the next call to
consume()orLT(int)fork>0.- Throws:
IllegalArgumentException- ifindexis less than 0UnsupportedOperationException- ifindexlies before the beginning of the moving window buffer (index <currentElementIndex-p).
-
LB
-