Top Description Fields Constructors Methods
org.antlr.runtime

public Class ClassicToken

extends Object
implements Token
Class Inheritance
All Implemented Interfaces
org.antlr.runtime.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

Modifier and TypeField and Description
protected int
protected int
protected int
index

What token number is this from 0..n-1 tokens

protected int
protected String
protected int

Constructor Summary

AccessConstructor and Description
public
ClassicToken(int type)

public
ClassicToken(Token oldToken)

public
ClassicToken(int type, String text)

public
ClassicToken(int type, String text, int channel)

Method Summary

Modifier and TypeMethod and Description
public int
public int
getCharPositionInLine()

Implements org.antlr.runtime.Token.getCharPositionInLine.

The index of the first character relative to the beginning of the line 0..n-1
public CharStream
getInputStream()

Implements org.antlr.runtime.Token.getInputStream.

From what character stream was this token created?
public int
getLine()

Implements org.antlr.runtime.Token.getLine.

The line number on which this token was matched; line=1..n
public String
getText()

Implements org.antlr.runtime.Token.getText.

Get the text of the token
public int
getTokenIndex()

Implements org.antlr.runtime.Token.getTokenIndex.

An index from 0..n-1 of the token object in the input stream.
public int
public void
public void
public void
public void
public void
public void
public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

channelback to summary
protected int channel
charPositionInLineback to summary
protected int charPositionInLine
indexback to summary
protected int index

What token number is this from 0..n-1 tokens

lineback to summary
protected int line
textback to summary
protected String text
typeback to summary
protected int type

Constructor Detail

ClassicTokenback to summary
public ClassicToken(int type)
ClassicTokenback to summary
public ClassicToken(Token oldToken)
ClassicTokenback to summary
public ClassicToken(int type, String text)
ClassicTokenback to summary
public ClassicToken(int type, String text, int channel)

Method Detail

getChannelback to summary
public int getChannel()

Implements org.antlr.runtime.Token.getChannel.

Annotations
@Override
getCharPositionInLineback to summary
public int getCharPositionInLine()

Implements org.antlr.runtime.Token.getCharPositionInLine.

Doc from org.antlr.runtime.Token.getCharPositionInLine.

The index of the first character relative to the beginning of the line 0..n-1

Annotations
@Override
getInputStreamback to summary
public CharStream getInputStream()

Implements org.antlr.runtime.Token.getInputStream.

Doc from org.antlr.runtime.Token.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.

Annotations
@Override
getLineback to summary
public int getLine()

Implements org.antlr.runtime.Token.getLine.

Doc from org.antlr.runtime.Token.getLine.

The line number on which this token was matched; line=1..n

Annotations
@Override
getTextback to summary
public String getText()

Implements org.antlr.runtime.Token.getText.

Doc from org.antlr.runtime.Token.getText.

Get the text of the token

Annotations
@Override
getTokenIndexback to summary
public int getTokenIndex()

Implements org.antlr.runtime.Token.getTokenIndex.

Doc from org.antlr.runtime.Token.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.

Annotations
@Override
getTypeback to summary
public int getType()

Implements org.antlr.runtime.Token.getType.

Annotations
@Override
setChannelback to summary
public void setChannel(int channel)

Implements org.antlr.runtime.Token.setChannel.

Annotations
@Override
setCharPositionInLineback to summary
public void setCharPositionInLine(int charPositionInLine)

Implements org.antlr.runtime.Token.setCharPositionInLine.

Annotations
@Override
setInputStreamback to summary
public void setInputStream(CharStream input)

Implements org.antlr.runtime.Token.setInputStream.

Annotations
@Override
setLineback to summary
public void setLine(int line)

Implements org.antlr.runtime.Token.setLine.

Annotations
@Override
setTextback to summary
public void setText(String text)

Implements org.antlr.runtime.Token.setText.

Annotations
@Override
setTokenIndexback to summary
public void setTokenIndex(int index)

Implements org.antlr.runtime.Token.setTokenIndex.

Annotations
@Override
setTypeback to summary
public void setType(int type)

Implements org.antlr.runtime.Token.setType.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override