Package org.antlr.runtime
Interface Token
-
- All Known Implementing Classes:
ClassicToken,CommonToken,RemoteDebugEventSocketListener.ProxyToken
public interface Token
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_CHANNELAll tokens go to the parser (unless skip() is called in that rule) on a particular "channel".static intDOWNimaginary tree navigation type; traverse "get child" linkstatic intEOFstatic intEOR_TOKEN_TYPEstatic intHIDDEN_CHANNELAnything on different channel than DEFAULT_CHANNEL is not parsed by parser.static TokenINVALID_TOKENstatic intINVALID_TOKEN_TYPEstatic intMIN_TOKEN_TYPEstatic TokenSKIP_TOKENIn an action, a lexer rule can set token to this SKIP_TOKEN and ANTLR will avoid creating a token for this symbol and try to fetch another.static intUPimaginary tree navigation type; finish with a child list
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intgetChannel()intgetCharPositionInLine()The index of the first character relative to the beginning of the line 0..n-1CharStreamgetInputStream()From 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..nStringgetText()Get the text of the tokenintgetTokenIndex()An index from 0..n-1 of the token object in the input stream.intgetType()voidsetChannel(int channel)voidsetCharPositionInLine(int pos)voidsetInputStream(CharStream input)voidsetLine(int line)voidsetText(String text)voidsetTokenIndex(int index)voidsetType(int ttype)
-
-
-
Field Detail
-
EOR_TOKEN_TYPE
static final int EOR_TOKEN_TYPE
- See Also:
- Constant Field Values
-
DOWN
static final int DOWN
imaginary tree navigation type; traverse "get child" link- See Also:
- Constant Field Values
-
UP
static final int UP
imaginary tree navigation type; finish with a child list- See Also:
- Constant Field Values
-
MIN_TOKEN_TYPE
static final int MIN_TOKEN_TYPE
- See Also:
- Constant Field Values
-
EOF
static final int EOF
- See Also:
- Constant Field Values
-
INVALID_TOKEN_TYPE
static final int INVALID_TOKEN_TYPE
- See Also:
- Constant Field Values
-
INVALID_TOKEN
static final Token INVALID_TOKEN
-
SKIP_TOKEN
static final Token SKIP_TOKEN
In an action, a lexer rule can set token to this SKIP_TOKEN and ANTLR will avoid creating a token for this symbol and try to fetch another.
-
DEFAULT_CHANNEL
static final int DEFAULT_CHANNEL
All tokens go to the parser (unless skip() is called in that rule) on a particular "channel". The parser tunes to a particular channel so that whitespace etc... can go to the parser on a "hidden" channel.- See Also:
- Constant Field Values
-
HIDDEN_CHANNEL
static final int HIDDEN_CHANNEL
Anything on different channel than DEFAULT_CHANNEL is not parsed by parser.- See Also:
- Constant Field Values
-
-
Method Detail
-
getText
String getText()
Get the text of the token
-
setText
void setText(String text)
-
getType
int getType()
-
setType
void setType(int ttype)
-
getLine
int getLine()
The line number on which this token was matched; line=1..n
-
setLine
void setLine(int line)
-
getCharPositionInLine
int getCharPositionInLine()
The index of the first character relative to the beginning of the line 0..n-1
-
setCharPositionInLine
void setCharPositionInLine(int pos)
-
getChannel
int getChannel()
-
setChannel
void setChannel(int channel)
-
getTokenIndex
int getTokenIndex()
An index from 0..n-1 of the token object in the input stream. This must be valid in order to use the ANTLRWorks debugger.
-
setTokenIndex
void setTokenIndex(int index)
-
getInputStream
CharStream getInputStream()
From 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.
-
setInputStream
void setInputStream(CharStream input)
-
-