Top Description Fields Constructors Methods
org.codehaus.groovy.syntax

public Class Token

extends CSTNode
Class Inheritance
Imports
org.codehaus.groovy.GroovyBugError

A CSTNode produced by the Lexer.
See Also
antlr.Parser, antlr.Token, Reduction, Types

Field Summary

Modifier and TypeField and Description
public static final Token
private int
public static final Token
private int
private int
private String
private int

Constructor Summary

AccessConstructor and Description
public
Token(int type, String text, int startLine, int startColumn)

Initializes the Token with the specified information.

private
Token()

Initializes the NULL Token.

Method Summary

Modifier and TypeMethod and Description
public Reduction
asReduction()

Implements abstract org.codehaus.groovy.syntax.CSTNode.asReduction.

Creates a Reduction from this token.
public Reduction
asReduction(CSTNode second)

Creates a Reduction from this token, adding the supplied node as the second element.

public Reduction
asReduction(CSTNode second, CSTNode third)

Creates a Reduction from this token, adding the supplied nodes as the second and third element, respectively.

public Reduction
asReduction(CSTNode second, CSTNode third, CSTNode fourth)

Creates a Reduction from this token, adding the supplied nodes as the second, third, and fourth element, respectively.

public Token
dup()

Returns a copy of this Token.

public CSTNode
get(int index)

Implements abstract org.codehaus.groovy.syntax.CSTNode.get.

Returns the specified element, or null.
public int
getMeaning()

Overrides org.codehaus.groovy.syntax.CSTNode.getMeaning.

Returns the meaning of this node.
public Token
getRoot()

Implements abstract org.codehaus.groovy.syntax.CSTNode.getRoot.

Returns the root of the node.
public String
getRootText()

Overrides org.codehaus.groovy.syntax.CSTNode.getRootText.

Returns the text of the root node.
public int
getStartColumn()

Overrides org.codehaus.groovy.syntax.CSTNode.getStartColumn.

Returns the starting column of the node.
public int
getStartLine()

Overrides org.codehaus.groovy.syntax.CSTNode.getStartLine.

Returns the starting line of the node.
public String
getText()

Returns the text of the token.

public int
getType()

Overrides org.codehaus.groovy.syntax.CSTNode.getType.

Returns the actual type of the node.
public static Token
newDecimal(String text, int startLine, int startColumn)

Creates a token that represents a decimal number.

public static Token
newIdentifier(String text, int startLine, int startColumn)

Creates a token that represents an identifier.

public static Token
newInteger(String text, int startLine, int startColumn)

Creates a token that represents an integer.

public static Token
newKeyword(String text, int startLine, int startColumn)

Creates a token that represents a keyword.

public static Token
newPlaceholder(int type)

Creates a token with the specified meaning.

public static Token
newString(String text, int startLine, int startColumn)

Creates a token that represents a double-quoted string.

public static Token
newSymbol(int type, int startLine, int startColumn)

Creates a token that represents a symbol, using a library for the text.

public static Token
newSymbol(String type, int startLine, int startColumn)

Creates a token that represents a symbol, using a library for the type.

public CSTNode
setMeaning(int meaning)

Overrides org.codehaus.groovy.syntax.CSTNode.setMeaning.

Sets the meaning for this node (and its root Token).
public void
setText(String text)

Not advisable, but if you need to adjust the token's text, this will do it.

public int
size()

Implements abstract org.codehaus.groovy.syntax.CSTNode.size.

Returns the number of elements in the node (including root).
Inherited from org.codehaus.groovy.syntax.CSTNode:
addaddChildrenOfcanMeanchildrengetgetDescriptiongetMeaningAsgetRoothasChildrenisAisAllOfisAnExpressionisEmptyisOneOfmarkAsExpressionmatchesmatchesmatchesmatchesmatchessettoStringwritewrite

Field Detail

EOFback to summary
public static final Token EOF
meaningback to summary
private int meaning
NULLback to summary
public static final Token NULL
startColumnback to summary
private int startColumn
startLineback to summary
private int startLine
textback to summary
private String text
typeback to summary
private int type

Constructor Detail

Tokenback to summary
public Token(int type, String text, int startLine, int startColumn)

Initializes the Token with the specified information.

Tokenback to summary
private Token()

Initializes the NULL Token.

Method Detail

asReductionback to summary
public Reduction asReduction()

Implements abstract org.codehaus.groovy.syntax.CSTNode.asReduction.

Creates a Reduction from this token. Returns self if the node is already a Reduction.

asReductionback to summary
public Reduction asReduction(CSTNode second)

Creates a Reduction from this token, adding the supplied node as the second element.

asReductionback to summary
public Reduction asReduction(CSTNode second, CSTNode third)

Creates a Reduction from this token, adding the supplied nodes as the second and third element, respectively.

asReductionback to summary
public Reduction asReduction(CSTNode second, CSTNode third, CSTNode fourth)

Creates a Reduction from this token, adding the supplied nodes as the second, third, and fourth element, respectively.

dupback to summary
public Token dup()

Returns a copy of this Token.

getback to summary
public CSTNode get(int index)

Implements abstract org.codehaus.groovy.syntax.CSTNode.get.

Returns the specified element, or null.

getMeaningback to summary
public int getMeaning()

Overrides org.codehaus.groovy.syntax.CSTNode.getMeaning.

Returns the meaning of this node. If the node isEmpty(), returns the type of Token.NULL.

getRootback to summary
public Token getRoot()

Implements abstract org.codehaus.groovy.syntax.CSTNode.getRoot.

Returns the root of the node. By convention, all nodes have a Token as the first element (or root), which indicates the type of the node. May return null if the node isEmpty().

getRootTextback to summary
public String getRootText()

Overrides org.codehaus.groovy.syntax.CSTNode.getRootText.

Returns the text of the root node. Uses getRoot(true) to get the root, so you will only receive null in return if the root token returns it.

getStartColumnback to summary
public int getStartColumn()

Overrides org.codehaus.groovy.syntax.CSTNode.getStartColumn.

Returns the starting column of the node. Returns -1 if not known.

getStartLineback to summary
public int getStartLine()

Overrides org.codehaus.groovy.syntax.CSTNode.getStartLine.

Returns the starting line of the node. Returns -1 if not known.

getTextback to summary
public String getText()

Returns the text of the token. Equivalent to getRootText() when called directly.

getTypeback to summary
public int getType()

Overrides org.codehaus.groovy.syntax.CSTNode.getType.

Returns the actual type of the node. If the node isEmpty(), returns the type of Token.NULL.

newDecimalback to summary
public static Token newDecimal(String text, int startLine, int startColumn)

Creates a token that represents a decimal number.

newIdentifierback to summary
public static Token newIdentifier(String text, int startLine, int startColumn)

Creates a token that represents an identifier.

newIntegerback to summary
public static Token newInteger(String text, int startLine, int startColumn)

Creates a token that represents an integer.

newKeywordback to summary
public static Token newKeyword(String text, int startLine, int startColumn)

Creates a token that represents a keyword. Returns null if the specified text isn't a keyword.

newPlaceholderback to summary
public static Token newPlaceholder(int type)

Creates a token with the specified meaning.

newStringback to summary
public static Token newString(String text, int startLine, int startColumn)

Creates a token that represents a double-quoted string.

newSymbolback to summary
public static Token newSymbol(int type, int startLine, int startColumn)

Creates a token that represents a symbol, using a library for the text.

newSymbolback to summary
public static Token newSymbol(String type, int startLine, int startColumn)

Creates a token that represents a symbol, using a library for the type.

setMeaningback to summary
public CSTNode setMeaning(int meaning)

Overrides org.codehaus.groovy.syntax.CSTNode.setMeaning.

Sets the meaning for this node (and its root Token). Not valid if the node isEmpty(). Returns this token, for convenience.

setTextback to summary
public void setText(String text)

Not advisable, but if you need to adjust the token's text, this will do it.

sizeback to summary
public int size()

Implements abstract org.codehaus.groovy.syntax.CSTNode.size.

Returns the number of elements in the node (including root).