public abstract class LookaheadStream<T> extends FastQueue<T>
FastQueue superclass to
keep all elements until no more markers; then can reset to avoid growing a
huge buffer.| Modifier and Type | Field and Description |
|---|---|
protected int |
currentElementIndex
Absolute token index.
|
T |
eof
Track object returned by nextElement upon end of stream;
Return it later when they ask for LT passed end of input.
|
protected int |
lastMarker
Track the last mark() call result value for use in rewind().
|
protected int |
markDepth
tracks how deep mark() calls are nested
|
protected T |
prevElement
This is the
LT(-1) element for the first element in FastQueue.data. |
static int |
UNINITIALIZED_EOF_ELEMENT_INDEX |
| Constructor and Description |
|---|
LookaheadStream() |
| Modifier and Type | Method and Description |
|---|---|
void |
consume()
Make sure we have at least one element to remove, even if EOF
|
void |
fill(int n)
add n elements to buffer
|
int |
index() |
abstract boolean |
isEOF(T o) |
protected T |
LB(int k) |
T |
LT(int k) |
int |
mark() |
abstract T |
nextElement()
Implement nextElement to supply a stream of elements to this
lookahead buffer.
|
void |
release(int marker) |
T |
remove()
Get and remove first element in queue; override
FastQueue.remove(); it's the same, just checks for backtracking. |
void |
reset() |
void |
rewind() |
void |
rewind(int marker) |
void |
seek(int index)
Seek to a 0-indexed absolute token index.
|
int |
size()
Size of entire stream is unknown; we only know buffer size from FastQueue.
|
protected void |
syncAhead(int need)
Make sure we have 'need' elements from current position p.
|
public static final int UNINITIALIZED_EOF_ELEMENT_INDEX
protected int currentElementIndex
LT(1). Goes from 0 to numtokens.protected T prevElement
LT(-1) element for the first element in FastQueue.data.public T eof
protected int lastMarker
protected int markDepth
public abstract T nextElement()
isEOF(T)public abstract boolean isEOF(T o)
public T remove()
FastQueue.remove(); it's the same, just checks for backtracking.public void consume()
protected void syncAhead(int need)
public void fill(int n)
public int size()
public T LT(int k)
public int index()
public int mark()
public void release(int marker)
public void rewind(int marker)
public void rewind()
public void seek(int index)
consume() or LT(int) for k>0.IllegalArgumentException - if index is less than 0UnsupportedOperationException - if index lies before the
beginning of the moving window buffer
(index < currentElementIndex - p).protected T LB(int k)
Copyright © 1992-2013 ANTLR. All Rights Reserved.