Class CommonToken
java.lang.Object
org.antlr.runtime.CommonToken
- All Implemented Interfaces:
Serializable, Token
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected intprotected intWhat token number is this from 0..n-1 tokens; < 0 implies invalid indexprotected CharStreamprotected intprotected intThe char position into the input buffer where this token startsprotected intThe char position into the input buffer where this token stopsprotected StringWe need to be able to change the text once in a while.protected intFields inherited from interface Token
DEFAULT_CHANNEL, DOWN, EOF, EOF_TOKEN, EOR_TOKEN_TYPE, HIDDEN_CHANNEL, INVALID_TOKEN, INVALID_TOKEN_TYPE, MIN_TOKEN_TYPE, SKIP_TOKEN, UP -
Constructor Summary
ConstructorsConstructorDescriptionCommonToken(int type) CommonToken(int type, String text) CommonToken(CharStream input, int type, int channel, int start, int stop) CommonToken(Token oldToken) -
Method Summary
Modifier and TypeMethodDescriptionintintThe index of the first character relative to the beginning of the line 0..n-1From what character stream was this token created? You don't have to implement but it's nice to know where a Token comes from if you have include files etc...intgetLine()The line number on which this token was matched; line=1..nintintgetText()Get the text of the tokenintAn index from 0..n-1 of the token object in the input stream.intgetType()voidsetChannel(int channel) voidsetCharPositionInLine(int charPositionInLine) voidsetInputStream(CharStream input) voidsetLine(int line) voidsetStartIndex(int start) voidsetStopIndex(int stop) voidOverride the text for this token.voidsetTokenIndex(int index) voidsetType(int type) toString()
-
Field Details
-
type
protected int type -
line
protected int line -
charPositionInLine
protected int charPositionInLine -
channel
protected int channel -
input
-
text
We need to be able to change the text once in a while. If this is non-null, then getText should return this. Note that start/stop are not affected by changing this. -
index
protected int indexWhat token number is this from 0..n-1 tokens; < 0 implies invalid index -
start
protected int startThe char position into the input buffer where this token starts -
stop
protected int stopThe char position into the input buffer where this token stops
-
-
Constructor Details
-
CommonToken
public CommonToken(int type) -
CommonToken
-
CommonToken
-
CommonToken
-
-
Method Details
-
getType
-
setLine
-
getText
-
setText
Override the text for this token. getText() will return this text rather than pulling from the buffer. Note that this does not mean that start/stop indexes are not valid. It means that that input was converted to a new string in the token object. -
getLine
-
getCharPositionInLine
public int getCharPositionInLine()Description copied from interface:TokenThe index of the first character relative to the beginning of the line 0..n-1- Specified by:
getCharPositionInLinein interfaceToken
-
setCharPositionInLine
public void setCharPositionInLine(int charPositionInLine) - Specified by:
setCharPositionInLinein interfaceToken
-
getChannel
public int getChannel()- Specified by:
getChannelin interfaceToken
-
setChannel
public void setChannel(int channel) - Specified by:
setChannelin interfaceToken
-
setType
-
getStartIndex
public int getStartIndex() -
setStartIndex
public void setStartIndex(int start) -
getStopIndex
public int getStopIndex() -
setStopIndex
public void setStopIndex(int stop) -
getTokenIndex
public int getTokenIndex()Description copied from interface:TokenAn index from 0..n-1 of the token object in the input stream. This must be valid in order to use the ANTLRWorks debugger.- Specified by:
getTokenIndexin interfaceToken
-
setTokenIndex
public void setTokenIndex(int index) - Specified by:
setTokenIndexin interfaceToken
-
getInputStream
Description copied from interface:TokenFrom what character stream was this token created? You don't have to implement but it's nice to know where a Token comes from if you have include files etc... on the input.- Specified by:
getInputStreamin interfaceToken
-
setInputStream
- Specified by:
setInputStreamin interfaceToken
-
toString
-