|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.antlr.runtime.LegacyCommonTokenStream
public class LegacyCommonTokenStream
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 Map |
channelOverrideMap
Map |
protected boolean |
discardOffChannelTokens
By default, track all incoming tokens |
protected 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 int |
range
|
protected List |
tokens
Record every single token pulled from the source so we can reproduce chunks of it later. |
protected TokenSource |
tokenSource
|
Constructor Summary | |
---|---|
LegacyCommonTokenStream()
|
|
LegacyCommonTokenStream(TokenSource tokenSource)
|
|
LegacyCommonTokenStream(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. |
List |
get(int start,
int stop)
Get all tokens from start..stop inclusively |
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. |
List |
getTokens()
|
List |
getTokens(int start,
int stop)
|
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. |
List |
getTokens(int start,
int stop,
int ttype)
|
List |
getTokens(int start,
int stop,
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. |
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 |
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)
|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected TokenSource tokenSource
protected List tokens
protected Map channelOverrideMap
protected Set discardSet
protected int channel
protected boolean discardOffChannelTokens
protected int lastMarker
protected int range
protected int p
Constructor Detail |
---|
public LegacyCommonTokenStream()
public LegacyCommonTokenStream(TokenSource tokenSource)
public LegacyCommonTokenStream(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 List getTokens()
public List getTokens(int start, int stop)
public List getTokens(int start, int stop, BitSet types)
public List getTokens(int start, int stop, List types)
public 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 List get(int start, int stop)
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 int range()
TokenStream
range
in interface TokenStream
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 String getSourceName()
IntStream
getSourceName
in interface IntStream
public String toString()
toString
in class Object
public String toString(int start, int stop)
TokenStream
toString
in interface TokenStream
public 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 |