Package org.antlr.runtime
Class ClassicToken
- java.lang.Object
-
- org.antlr.runtime.ClassicToken
-
- All Implemented Interfaces:
Token
public class ClassicToken extends java.lang.Object implements Token
A Token object like we'd use in ANTLR 2.x; has an actual string created and associated with this object. These objects are needed for imaginary tree nodes that have payload objects. We need to create a Token object that has a string; the tree node will point at this token. CommonToken has indexes into a char stream and hence cannot be used to introduce new strings.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
channel
protected int
charPositionInLine
protected int
index
What token number is this from 0..n-1 tokensprotected int
line
protected java.lang.String
text
protected int
type
-
Fields inherited from interface org.antlr.runtime.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
Constructors Constructor Description ClassicToken(int type)
ClassicToken(int type, java.lang.String text)
ClassicToken(int type, java.lang.String text, int channel)
ClassicToken(Token oldToken)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getChannel()
int
getCharPositionInLine()
The index of the first character relative to the beginning of the line 0..n-1CharStream
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...int
getLine()
The line number on which this token was matched; line=1..njava.lang.String
getText()
Get the text of the tokenint
getTokenIndex()
An index from 0..n-1 of the token object in the input stream.int
getType()
void
setChannel(int channel)
void
setCharPositionInLine(int charPositionInLine)
void
setInputStream(CharStream input)
void
setLine(int line)
void
setText(java.lang.String text)
void
setTokenIndex(int index)
void
setType(int type)
java.lang.String
toString()
-
-
-
Constructor Detail
-
ClassicToken
public ClassicToken(int type)
-
ClassicToken
public ClassicToken(Token oldToken)
-
ClassicToken
public ClassicToken(int type, java.lang.String text)
-
ClassicToken
public ClassicToken(int type, java.lang.String text, int channel)
-
-
Method Detail
-
getText
public java.lang.String getText()
Description copied from interface:Token
Get the text of the token
-
getLine
public int getLine()
Description copied from interface:Token
The line number on which this token was matched; line=1..n
-
getCharPositionInLine
public int getCharPositionInLine()
Description copied from interface:Token
The index of the first character relative to the beginning of the line 0..n-1- Specified by:
getCharPositionInLine
in interfaceToken
-
setCharPositionInLine
public void setCharPositionInLine(int charPositionInLine)
- Specified by:
setCharPositionInLine
in interfaceToken
-
getChannel
public int getChannel()
- Specified by:
getChannel
in interfaceToken
-
setChannel
public void setChannel(int channel)
- Specified by:
setChannel
in interfaceToken
-
getTokenIndex
public int getTokenIndex()
Description copied from interface:Token
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.- Specified by:
getTokenIndex
in interfaceToken
-
setTokenIndex
public void setTokenIndex(int index)
- Specified by:
setTokenIndex
in interfaceToken
-
getInputStream
public CharStream getInputStream()
Description copied from interface:Token
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.- Specified by:
getInputStream
in interfaceToken
-
setInputStream
public void setInputStream(CharStream input)
- Specified by:
setInputStream
in interfaceToken
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-