Package org.codehaus.groovy.syntax
Class Token
- java.lang.Object
- 
- org.codehaus.groovy.syntax.CSTNode
- 
- org.codehaus.groovy.syntax.Token
 
 
- 
- 
Constructor SummaryConstructors Constructor Description Token(int type, java.lang.String text, int startLine, int startColumn)Initializes the Token with the specified information.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ReductionasReduction()Creates aReductionfrom this token.ReductionasReduction(CSTNode second)Creates aReductionfrom this token, adding the supplied node as the second element.ReductionasReduction(CSTNode second, CSTNode third)Creates aReductionfrom this token, adding the supplied nodes as the second and third element, respectively.ReductionasReduction(CSTNode second, CSTNode third, CSTNode fourth)Creates aReductionfrom this token, adding the supplied nodes as the second, third, and fourth element, respectively.Tokendup()Returns a copy of this Token.CSTNodeget(int index)Returns the specified element, or null.intgetMeaning()Returns the meaning of this node.TokengetRoot()Returns the root of the node.java.lang.StringgetRootText()Returns the text of the root node.intgetStartColumn()Returns the starting column of the node.intgetStartLine()Returns the starting line of the node.java.lang.StringgetText()Returns the text of the token.intgetType()Returns the actual type of the node.static TokennewDecimal(java.lang.String text, int startLine, int startColumn)Creates a token that represents a decimal number.static TokennewIdentifier(java.lang.String text, int startLine, int startColumn)Creates a token that represents an identifier.static TokennewInteger(java.lang.String text, int startLine, int startColumn)Creates a token that represents an integer.static TokennewKeyword(java.lang.String text, int startLine, int startColumn)Creates a token that represents a keyword.static TokennewPlaceholder(int type)Creates a token with the specified meaning.static TokennewString(java.lang.String text, int startLine, int startColumn)Creates 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 TokennewSymbol(java.lang.String type, int startLine, int startColumn)Creates a token that represents a symbol, using a library for the type.CSTNodesetMeaning(int meaning)Sets the meaning for this node (and it's root Token).voidsetText(java.lang.String text)Not 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.CSTNodeadd, addChildrenOf, canMean, children, get, getDescription, getMeaningAs, getRoot, hasChildren, isA, isAllOf, isAnExpression, isEmpty, isOneOf, markAsExpression, set, toString, write, write
 
- 
 
- 
- 
- 
Method Detail- 
duppublic Token dup() Returns a copy of this Token.
 - 
getMeaningpublic int getMeaning() Returns the meaning of this node. If the node isEmpty(), returns the type of Token.NULL.- Overrides:
- getMeaningin class- CSTNode
 
 - 
setMeaningpublic CSTNode setMeaning(int meaning) Sets the meaning for this node (and it's root Token). Not valid if the node isEmpty(). Returns this token, for convenience.- Overrides:
- setMeaningin class- CSTNode
 
 - 
getTypepublic int getType() Returns the actual type of the node. If the node isEmpty(), returns the type of Token.NULL.
 - 
sizepublic int size() Returns the number of elements in the node (including root).
 - 
getpublic CSTNode get(int index) Returns the specified element, or null.
 - 
getRootpublic Token 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().
 - 
getRootTextpublic java.lang.String 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 class- CSTNode
 
 - 
getTextpublic java.lang.String getText() Returns the text of the token. Equivalent togetRootText()when called directly.
 - 
setTextpublic void setText(java.lang.String text) Not advisable, but if you need to adjust the token's text, this will do it.
 - 
getStartLinepublic int getStartLine() Returns the starting line of the node. Returns -1 if not known.- Overrides:
- getStartLinein class- CSTNode
 
 - 
getStartColumnpublic int getStartColumn() Returns the starting column of the node. Returns -1 if not known.- Overrides:
- getStartColumnin class- CSTNode
 
 - 
asReductionpublic Reduction asReduction() Creates aReductionfrom this token. Returns self if the node is already aReduction.- Specified by:
- asReductionin class- CSTNode
 
 - 
asReductionpublic Reduction asReduction(CSTNode second) Creates aReductionfrom this token, adding the supplied node as the second element.
 - 
asReductionpublic Reduction asReduction(CSTNode second, CSTNode third) Creates aReductionfrom this token, adding the supplied nodes as the second and third element, respectively.
 - 
asReductionpublic Reduction asReduction(CSTNode second, CSTNode third, CSTNode fourth) Creates aReductionfrom this token, adding the supplied nodes as the second, third, and fourth element, respectively.
 - 
newKeywordpublic static Token newKeyword(java.lang.String text, int startLine, int startColumn) Creates a token that represents a keyword. Returns null if the specified text isn't a keyword.
 - 
newStringpublic static Token newString(java.lang.String text, int startLine, int startColumn) Creates a token that represents a double-quoted string.
 - 
newIdentifierpublic static Token newIdentifier(java.lang.String text, int startLine, int startColumn) Creates a token that represents an identifier.
 - 
newIntegerpublic static Token newInteger(java.lang.String text, int startLine, int startColumn) Creates a token that represents an integer.
 - 
newDecimalpublic static Token newDecimal(java.lang.String text, int startLine, int startColumn) Creates a token that represents a decimal number.
 - 
newSymbolpublic static Token newSymbol(int type, int startLine, int startColumn) Creates a token that represents a symbol, using a library for the text.
 - 
newSymbolpublic static Token newSymbol(java.lang.String type, int startLine, int startColumn) Creates a token that represents a symbol, using a library for the type.
 - 
newPlaceholderpublic static Token newPlaceholder(int type) Creates a token with the specified meaning.
 
- 
 
-