Package org.codehaus.groovy.syntax
Class Token
java.lang.Object
org.codehaus.groovy.syntax.CSTNode
org.codehaus.groovy.syntax.Token
A
CSTNode produced by the Lexer.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates aReductionfrom this token.asReduction(CSTNode second) Creates aReductionfrom this token, adding the supplied node as the second element.asReduction(CSTNode second, CSTNode third) Creates aReductionfrom this token, adding the supplied nodes as the second and third element, respectively.asReduction(CSTNode second, CSTNode third, CSTNode fourth) Creates aReductionfrom this token, adding the supplied nodes as the second, third, and fourth element, respectively.dup()Returns a copy of this Token.get(int index) Returns the specified element, or null.intReturns the meaning of this node.getRoot()Returns the root of the node.Returns the text of the root node.intReturns the starting column of the node.intReturns the starting line of the node.getText()Returns the text of the token.intgetType()Returns the actual type of the node.static TokennewDecimal(String text, int startLine, int startColumn) Creates a token that represents a decimal number.static TokennewIdentifier(String text, int startLine, int startColumn) Creates a token that represents an identifier.static TokennewInteger(String text, int startLine, int startColumn) Creates a token that represents an integer.static TokennewKeyword(String text, int startLine, int startColumn) Creates a token that represents a keyword.static TokennewPlaceholder(int meaning) Creates a token with the specified meaning.static TokenCreates a token that represents a double-quoted string.static TokennewSymbol(int type, int startLine, int startColumn) Creates a token that represents a symbol, using a library for the text.static TokenCreates a token that represents a symbol, using a library for the type.setMeaning(int meaning) Sets the meaning for this node (and its root Token).voidNot advisable, but if you need to adjust the token's text, this will do it.intsize()Returns the number of elements in the node (including root).Methods inherited from class org.codehaus.groovy.syntax.CSTNode
add, addChildrenOf, canMean, children, get, getDescription, getMeaningAs, getRoot, hasChildren, isA, isAllOf, isAnExpression, isEmpty, isOneOf, markAsExpression, set, toString, write, write
-
Field Details
-
EOF
-
NULL
-
-
Constructor Details
-
Token
Initializes the Token with the specified information.
-
-
Method Details
-
dup
Returns a copy of this Token. -
getMeaning
public int getMeaning()Returns the meaning of this node. If the node isEmpty(), returns the type of Token.NULL.- Overrides:
getMeaningin classCSTNode
-
setMeaning
Sets the meaning for this node (and its root Token). Not valid if the node isEmpty(). Returns this token, for convenience.- Overrides:
setMeaningin classCSTNode
-
getType
public int getType()Returns the actual type of the node. If the node isEmpty(), returns the type of Token.NULL. -
size
public int size()Returns the number of elements in the node (including root). -
get
Returns the specified element, or null. -
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 nodeisEmpty(). -
getRootText
Returns the text of the root node. UsesgetRoot(true)to get the root, so you will only receive null in return if the root token returns it.- Overrides:
getRootTextin classCSTNode
-
getText
Returns the text of the token. Equivalent togetRootText()when called directly. -
setText
Not advisable, but if you need to adjust the token's text, this will do it. -
getStartLine
public int getStartLine()Returns the starting line of the node. Returns -1 if not known.- Overrides:
getStartLinein classCSTNode
-
getStartColumn
public int getStartColumn()Returns the starting column of the node. Returns -1 if not known.- Overrides:
getStartColumnin classCSTNode
-
asReduction
Creates aReductionfrom this token. Returns self if the node is already aReduction.- Specified by:
asReductionin classCSTNode
-
asReduction
Creates aReductionfrom this token, adding the supplied node as the second element. -
asReduction
Creates aReductionfrom this token, adding the supplied nodes as the second and third element, respectively. -
asReduction
Creates aReductionfrom this token, adding the supplied nodes as the second, third, and fourth element, respectively. -
newKeyword
Creates a token that represents a keyword. Returns null if the specified text isn't a keyword. -
newString
Creates a token that represents a double-quoted string. -
newIdentifier
Creates a token that represents an identifier. -
newInteger
Creates a token that represents an integer. -
newDecimal
Creates a token that represents a decimal number. -
newSymbol
Creates a token that represents a symbol, using a library for the text. -
newSymbol
Creates a token that represents a symbol, using a library for the type. -
newPlaceholder
Creates a token with the specified meaning.
-