类 CommonTokenStream
- java.lang.Object
-
- org.antlr.runtime.BufferedTokenStream
-
- org.antlr.runtime.CommonTokenStream
-
- 所有已实现的接口:
IntStream
,TokenStream
public class CommonTokenStream extends BufferedTokenStream
The most common stream of tokens where every token is buffered up and tokens are filtered for a certain channel (the parser will only see these tokens). Even though it buffers all of the tokens, this token stream pulls tokens from the tokens source on demand. In other words, until you ask for a token using consume(), LT(), etc. the stream does not pull from the lexer. The only difference between this stream and 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.)
-
-
字段概要
字段 修饰符和类型 字段 说明 protected int
channel
Skip tokens on any channel but this one; this is how we skip whitespace...-
从类继承的字段 org.antlr.runtime.BufferedTokenStream
lastMarker, p, range, tokens, tokenSource
-
-
构造器概要
构造器 构造器 说明 CommonTokenStream()
CommonTokenStream(TokenSource tokenSource)
CommonTokenStream(TokenSource tokenSource, int channel)
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
consume()
Always leave p on an on-channel token.int
getNumberOfOnChannelTokens()
Count EOF just once.protected Token
LB(int k)
Token
LT(int k)
Get Token at current input pointer + i ahead where i=1 is next Token.void
reset()
void
setTokenSource(TokenSource tokenSource)
Reset this token stream by setting its token source.protected void
setup()
protected int
skipOffTokenChannels(int i)
Given a starting index, return the index of the first on-channel token.protected int
skipOffTokenChannelsReverse(int i)
-
-
-
构造器详细资料
-
CommonTokenStream
public CommonTokenStream()
-
CommonTokenStream
public CommonTokenStream(TokenSource tokenSource)
-
CommonTokenStream
public CommonTokenStream(TokenSource tokenSource, int channel)
-
-
方法详细资料
-
consume
public void consume()
Always leave p on an on-channel token.- 指定者:
consume
在接口中IntStream
- 覆盖:
consume
在类中BufferedTokenStream
-
LB
protected Token LB(int k)
- 覆盖:
LB
在类中BufferedTokenStream
-
LT
public Token LT(int k)
从接口复制的说明:TokenStream
Get Token at current input pointer + i ahead where i=1 is next Token. i<0 indicates tokens in the past. So -1 is previous token and -2 is two tokens ago. LT(0) is undefined. For i>=n, return Token.EOFToken. Return null for LT(0) and any index that results in an absolute address that is negative.- 指定者:
LT
在接口中TokenStream
- 覆盖:
LT
在类中BufferedTokenStream
-
skipOffTokenChannels
protected int skipOffTokenChannels(int i)
Given a starting index, return the index of the first on-channel token.
-
skipOffTokenChannelsReverse
protected int skipOffTokenChannelsReverse(int i)
-
reset
public void reset()
- 覆盖:
reset
在类中BufferedTokenStream
-
setup
protected void setup()
- 覆盖:
setup
在类中BufferedTokenStream
-
getNumberOfOnChannelTokens
public int getNumberOfOnChannelTokens()
Count EOF just once.
-
setTokenSource
public void setTokenSource(TokenSource tokenSource)
Reset this token stream by setting its token source.- 覆盖:
setTokenSource
在类中BufferedTokenStream
-
-