|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.antlr.runtime.CommonTokenStream
public class CommonTokenStream
The most common stream of tokens is one where every token is buffered up and tokens are prefiltered for a certain channel (the parser will only see these tokens and cannot change the filter channel number during the parse). TODO: how to access the full token stream? How to track all tokens matched per rule?
Field Summary | |
---|---|
protected int |
channel
Skip tokens on any channel but this one; this is how we skip whitespace... |
protected java.util.Map |
channelOverrideMap
Map |
protected boolean |
discardOffChannelTokens
By default, track all incoming tokens |
protected java.util.Set |
discardSet
Set |
protected int |
lastMarker
Track the last mark() call result value for use in rewind(). |
protected int |
p
The index into the tokens list of the current token (next token to consume). |
protected java.util.List |
tokens
Record every single token pulled from the source so we can reproduce chunks of it later. |
protected TokenSource |
tokenSource
|
Constructor Summary | |
---|---|
CommonTokenStream()
|
|
CommonTokenStream(TokenSource tokenSource)
|
|
CommonTokenStream(TokenSource tokenSource,
int channel)
|
Method Summary | |
---|---|
void |
consume()
Move the input pointer to the next incoming token. |
void |
discardOffChannelTokens(boolean discardOffChannelTokens)
|
void |
discardTokenType(int ttype)
|
protected void |
fillBuffer()
Load all tokens from the token source and put in tokens. |
Token |
get(int i)
Return absolute token i; ignore which channel the tokens are on; that is, count all tokens not just on-channel tokens. |
java.lang.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. |
java.util.List |
getTokens()
|
java.util.List |
getTokens(int start,
int stop)
|
java.util.List |
getTokens(int start,
int stop,
BitSet types)
Given a start and stop index, return a List of all tokens in the token type BitSet. |
java.util.List |
getTokens(int start,
int stop,
int ttype)
|
java.util.List |
getTokens(int start,
int stop,
java.util.List types)
|
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. |
protected Token |
LB(int k)
Look backwards k tokens on-channel tokens |
Token |
LT(int k)
Get the ith token from the current position 1..n where k=1 is the first symbol of lookahead. |
int |
mark()
Tell the stream to start buffering if it hasn't already. |
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 |
reset()
|
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 |
setTokenSource(TokenSource tokenSource)
Reset this token stream by setting its token source. |
void |
setTokenTypeChannel(int ttype,
int channel)
A simple filter mechanism whereby you can tell this token stream to force all tokens of type ttype to be on channel. |
int |
size()
Only makes sense for streams that buffer everything up probably, but might be useful to display the entire stream or for testing. |
protected int |
skipOffTokenChannels(int i)
Given a starting index, return the index of the first on-channel token. |
protected int |
skipOffTokenChannelsReverse(int i)
|
java.lang.String |
toString()
|
java.lang.String |
toString(int start,
int stop)
Return the text of all tokens from start to stop, inclusive. |
java.lang.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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected TokenSource tokenSource
protected java.util.List tokens
protected java.util.Map channelOverrideMap
protected java.util.Set discardSet
protected int channel
protected boolean discardOffChannelTokens
protected int lastMarker
protected int p
Constructor Detail |
---|
public CommonTokenStream()
public CommonTokenStream(TokenSource tokenSource)
public CommonTokenStream(TokenSource tokenSource, int channel)
Method Detail |
---|
public void setTokenSource(TokenSource tokenSource)
protected void fillBuffer()
public void consume()
consume
in interface IntStream
protected int skipOffTokenChannels(int i)
protected int skipOffTokenChannelsReverse(int i)
public void setTokenTypeChannel(int ttype, int channel)
public void discardTokenType(int ttype)
public void discardOffChannelTokens(boolean discardOffChannelTokens)
public java.util.List getTokens()
public java.util.List getTokens(int start, int stop)
public java.util.List getTokens(int start, int stop, BitSet types)
public java.util.List getTokens(int start, int stop, java.util.List types)
public java.util.List getTokens(int start, int stop, int ttype)
public Token LT(int k)
LT
in interface TokenStream
protected Token LB(int k)
public Token get(int i)
get
in interface TokenStream
public int LA(int i)
IntStream
LA
in interface IntStream
public int mark()
IntStream
mark
in interface IntStream
public void release(int marker)
IntStream
release
in interface IntStream
public int size()
IntStream
size
in interface IntStream
public int index()
IntStream
index
in interface IntStream
public void rewind(int marker)
IntStream
rewind
in interface IntStream
public void rewind()
IntStream
rewind
in interface IntStream
public void reset()
public void seek(int index)
IntStream
seek
in interface IntStream
public TokenSource getTokenSource()
TokenStream
getTokenSource
in interface TokenStream
public java.lang.String getSourceName()
IntStream
getSourceName
in interface IntStream
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(int start, int stop)
TokenStream
toString
in interface TokenStream
public java.lang.String toString(Token start, Token stop)
TokenStream
toString
in interface TokenStream
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |