public class LegacyCommonTokenStream extends Object implements TokenStream
Modifier and Type | Field and Description |
---|---|
protected int |
channel
Skip tokens on any channel but this one; this is how we skip whitespace...
|
protected Map<Integer,Integer> |
channelOverrideMap
Map<tokentype, channel> to override some Tokens' channel numbers
|
protected boolean |
discardOffChannelTokens
By default, track all incoming tokens
|
protected Set<Integer> |
discardSet
Set<tokentype>; discard any tokens with this type
|
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<Token> |
tokens
Record every single token pulled from the source so we can reproduce
chunks of it later.
|
protected TokenSource |
tokenSource |
Constructor and Description |
---|
LegacyCommonTokenStream() |
LegacyCommonTokenStream(TokenSource tokenSource) |
LegacyCommonTokenStream(TokenSource tokenSource,
int channel) |
Modifier and Type | Method and Description |
---|---|
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<? extends Token> |
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<? extends Token> |
getTokens() |
List<? extends Token> |
getTokens(int start,
int stop) |
List<? extends Token> |
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<? extends Token> |
getTokens(int start,
int stop,
int ttype) |
List<? extends Token> |
getTokens(int start,
int stop,
List<Integer> 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.
|
protected TokenSource tokenSource
protected List<Token> tokens
protected Map<Integer,Integer> channelOverrideMap
protected int channel
protected boolean discardOffChannelTokens
protected int lastMarker
protected int range
protected int p
public LegacyCommonTokenStream()
public LegacyCommonTokenStream(TokenSource tokenSource)
public LegacyCommonTokenStream(TokenSource tokenSource, int channel)
public void setTokenSource(TokenSource tokenSource)
protected void fillBuffer()
public void consume()
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<? extends Token> getTokens(int start, int stop, BitSet types)
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<? extends Token> get(int start, int stop)
public int LA(int i)
IntStream
public int mark()
IntStream
public void release(int marker)
IntStream
public int size()
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 reset()
public void seek(int index)
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.