public class DebugTokenStream extends Object implements TokenStream
Modifier and Type | Field and Description |
---|---|
protected DebugEventListener |
dbg |
protected boolean |
initialStreamState |
TokenStream |
input |
protected int |
lastMarker
Track the last mark() call result value for use in rewind().
|
Constructor and Description |
---|
DebugTokenStream(TokenStream input,
DebugEventListener dbg) |
Modifier and Type | Method and Description |
---|---|
void |
consume() |
protected void |
consumeInitialHiddenTokens() |
Token |
get(int i)
Get a token at an absolute index i; 0..n-1.
|
String |
getSourceName()
Where are you getting symbols from? Normally, implementations will
pass the buck all the way to the lexer who can ask its input stream
for the file name or whatever.
|
TokenSource |
getTokenSource()
Where is this stream pulling tokens from? This is not the name, but
the object that provides Token objects.
|
int |
index()
Return the current input symbol index 0..n where n indicates the
last symbol has been read.
|
int |
LA(int i)
Get int at current input pointer + i ahead where i=1 is next int.
|
Token |
LT(int i)
Get Token at current input pointer + i ahead where i=1 is next Token.
|
int |
mark()
Tell the stream to start buffering if it hasn't already.
|
int |
range()
How far ahead has the stream been asked to look? The return
value is a valid index from 0..n-1.
|
void |
release(int marker)
You may want to commit to a backtrack but don't want to force the
stream to keep bookkeeping objects around for a marker that is
no longer necessary.
|
void |
rewind()
Rewind to the input position of the last marker.
|
void |
rewind(int marker)
Reset the stream so that next call to index would return marker.
|
void |
seek(int index)
Set the input cursor to the position indicated by index.
|
void |
setDebugListener(DebugEventListener dbg) |
int |
size()
Only makes sense for streams that buffer everything up probably, but
might be useful to display the entire stream or for testing.
|
String |
toString() |
String |
toString(int start,
int stop)
Return the text of all tokens from start to stop, inclusive.
|
String |
toString(Token start,
Token stop)
Because the user is not required to use a token with an index stored
in it, we must provide a means for two token objects themselves to
indicate the start/end location.
|
protected DebugEventListener dbg
public TokenStream input
protected boolean initialStreamState
protected int lastMarker
public DebugTokenStream(TokenStream input, DebugEventListener dbg)
public void setDebugListener(DebugEventListener dbg)
protected void consumeInitialHiddenTokens()
public Token LT(int i)
TokenStream
LT
in interface TokenStream
public int LA(int i)
IntStream
public Token get(int i)
TokenStream
get
in interface TokenStream
public int mark()
IntStream
public int index()
IntStream
public int range()
TokenStream
range
in interface TokenStream
public void rewind(int marker)
IntStream
public void rewind()
IntStream
public void release(int marker)
IntStream
public void seek(int index)
IntStream
public int size()
IntStream
public TokenSource getTokenSource()
TokenStream
getTokenSource
in interface TokenStream
public String getSourceName()
IntStream
getSourceName
in interface IntStream
public String toString(int start, int stop)
TokenStream
toString
in interface TokenStream
public String toString(Token start, Token stop)
TokenStream
toString
in interface TokenStream
Copyright © 1992–2015 ANTLR. All rights reserved.