public class CommonToken extends Object implements WritableToken, Serializable
Modifier and Type | Field and Description |
---|---|
protected int |
channel |
protected int |
charPositionInLine |
protected int |
index
What token number is this from 0..n-1 tokens; < 0 implies invalid index
|
protected int |
line |
protected Pair<TokenSource,CharStream> |
source |
protected int |
start
The char position into the input buffer where this token starts
|
protected int |
stop
The char position into the input buffer where this token stops
|
protected String |
text
We need to be able to change the text once in a while.
|
protected int |
type |
DEFAULT_CHANNEL, EOF, EPSILON, HIDDEN_CHANNEL, INVALID_TYPE, MIN_USER_TOKEN_TYPE
Constructor and Description |
---|
CommonToken(int type) |
CommonToken(int type,
String text) |
CommonToken(Pair<TokenSource,CharStream> source,
int type,
int channel,
int start,
int stop) |
CommonToken(Token oldToken) |
Modifier and Type | Method and Description |
---|---|
int |
getChannel()
Return the channel this token.
|
int |
getCharPositionInLine()
The index of the first character of this token relative to the
beginning of the line at which it occurs, 0..n-1
|
CharStream |
getInputStream()
Gets the
CharStream from which this token was derived. |
int |
getLine()
The line number on which the 1st character of this token was matched,
line=1..n
|
int |
getStartIndex()
The starting character index of the token
This method is optional; return -1 if not implemented.
|
int |
getStopIndex()
The last character index of the token.
|
String |
getText()
Get the text of the token
|
int |
getTokenIndex()
An index from 0..n-1 of the token object in the input stream.
|
TokenSource |
getTokenSource()
Gets the
TokenSource which created this token. |
int |
getType()
Get the token type of the token
|
void |
setChannel(int channel) |
void |
setCharPositionInLine(int charPositionInLine) |
void |
setLine(int line) |
void |
setStartIndex(int start) |
void |
setStopIndex(int stop) |
void |
setText(String text)
Override the text for this token.
|
void |
setTokenIndex(int index) |
void |
setType(int type) |
String |
toString() |
protected int type
protected int line
protected int charPositionInLine
protected int channel
protected Pair<TokenSource,CharStream> source
protected String text
protected int index
protected int start
protected int stop
public CommonToken(int type)
public CommonToken(@NotNull Pair<TokenSource,CharStream> source, int type, int channel, int start, int stop)
public CommonToken(int type, String text)
public CommonToken(Token oldToken)
public int getType()
Token
public void setLine(int line)
setLine
in interface WritableToken
public void setText(String text)
setText
in interface WritableToken
public int getLine()
Token
public int getCharPositionInLine()
Token
getCharPositionInLine
in interface Token
public void setCharPositionInLine(int charPositionInLine)
setCharPositionInLine
in interface WritableToken
public int getChannel()
Token
getChannel
in interface Token
public void setChannel(int channel)
setChannel
in interface WritableToken
public void setType(int type)
setType
in interface WritableToken
public int getStartIndex()
Token
getStartIndex
in interface Token
public void setStartIndex(int start)
public int getStopIndex()
Token
getStopIndex
in interface Token
public void setStopIndex(int stop)
public int getTokenIndex()
Token
getTokenIndex
in interface Token
public void setTokenIndex(int index)
setTokenIndex
in interface WritableToken
public TokenSource getTokenSource()
Token
TokenSource
which created this token.getTokenSource
in interface Token
public CharStream getInputStream()
Token
CharStream
from which this token was derived.getInputStream
in interface Token
Copyright © 1992-2013 ANTLR. All Rights Reserved.