public class CommonTokenStream extends BufferedTokenStream
BufferedTokenStream
superclass
is that this stream knows how to ignore off channel tokens. There may be
a performance advantage to using the superclass if you don't pass
whitespace and comments etc. to the parser on a hidden channel (i.e.,
you set $channel
instead of calling skip()
in lexer rules.)UnbufferedTokenStream
,
BufferedTokenStream
Modifier and Type | Field and Description |
---|---|
protected int |
channel
Skip tokens on any channel but this one; this is how we skip whitespace...
|
fetchedEOF, p, tokens, tokenSource
EOF, UNKNOWN_SOURCE_NAME
Constructor and Description |
---|
CommonTokenStream(TokenSource tokenSource) |
CommonTokenStream(TokenSource tokenSource,
int channel) |
Modifier and Type | Method and Description |
---|---|
protected int |
adjustSeekIndex(int i)
Allowed derived classes to modify the behavior of operations which change
the current stream position by adjusting the target token index of a seek
operation.
|
int |
getNumberOfOnChannelTokens()
Count EOF just once.
|
protected Token |
LB(int k) |
Token |
LT(int k)
|
consume, fetch, fill, filterForChannel, get, get, getHiddenTokensToLeft, getHiddenTokensToLeft, getHiddenTokensToRight, getHiddenTokensToRight, getSourceName, getText, getText, getText, getText, getTokens, getTokens, getTokens, getTokens, getTokenSource, index, LA, lazyInit, mark, nextTokenOnChannel, previousTokenOnChannel, release, reset, seek, setTokenSource, setup, size, sync
protected int channel
public CommonTokenStream(TokenSource tokenSource)
public CommonTokenStream(TokenSource tokenSource, int channel)
protected int adjustSeekIndex(int i)
BufferedTokenStream
i
. If an
exception is thrown in this method, the current stream index should not be
changed.
For example, CommonTokenStream
overrides this method to ensure that
the seek target is always an on-channel token.adjustSeekIndex
in class BufferedTokenStream
i
- The target token index.protected Token LB(int k)
LB
in class BufferedTokenStream
public Token LT(int k)
TokenStream
Token
instance associated with the value returned by
LA(k)
. This method has the same pre- and post-conditions as
IntStream.LA(int)
. In addition, when the preconditions of this method
are met, the return value is non-null and the value of
LT(k).getType()==LA(k)
.LT
in interface TokenStream
LT
in class BufferedTokenStream
IntStream.LA(int)
public int getNumberOfOnChannelTokens()
Copyright © 1992-2013 ANTLR. All Rights Reserved.