public class CommonToken extends Object implements WritableToken, Serializable
| Modifier and Type | Field and Description |
|---|---|
protected int |
channel |
protected int |
charPositionInLine |
protected static Pair<TokenSource,CharStream> |
EMPTY_SOURCE |
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 static final Pair<TokenSource,CharStream> EMPTY_SOURCE
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()
Tokenpublic void setLine(int line)
setLine in interface WritableTokenpublic void setText(String text)
setText in interface WritableTokenpublic int getLine()
Tokenpublic int getCharPositionInLine()
TokengetCharPositionInLine in interface Tokenpublic void setCharPositionInLine(int charPositionInLine)
setCharPositionInLine in interface WritableTokenpublic int getChannel()
TokengetChannel in interface Tokenpublic void setChannel(int channel)
setChannel in interface WritableTokenpublic void setType(int type)
setType in interface WritableTokenpublic int getStartIndex()
TokengetStartIndex in interface Tokenpublic void setStartIndex(int start)
public int getStopIndex()
TokengetStopIndex in interface Tokenpublic void setStopIndex(int stop)
public int getTokenIndex()
TokengetTokenIndex in interface Tokenpublic void setTokenIndex(int index)
setTokenIndex in interface WritableTokenpublic TokenSource getTokenSource()
TokenTokenSource which created this token.getTokenSource in interface Tokenpublic CharStream getInputStream()
TokenCharStream from which this token was derived.getInputStream in interface TokenCopyright © 1992-2013 ANTLR. All Rights Reserved.