Groovy 2.2.1

org.codehaus.groovy.syntax
[Java] Class Token

java.lang.Object
  org.codehaus.groovy.syntax.CSTNode
      org.codehaus.groovy.syntax.Token

public class Token
extends CSTNode

A CSTNode produced by the Lexer.

Authors:
bob mcwhirter
Chris Poirier
Version:
\$Id\$
See Also:
Parser
Token
Reduction
Types


Field Summary
static Token EOF

static Token NULL

 
Constructor Summary
Token(int type, String text, int startLine, int startColumn)

 
Method Summary
Reduction asReduction()

Creates a Reduction from this token.

Reduction asReduction(CSTNode second)

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

Reduction asReduction(CSTNode second, CSTNode third)

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

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

Token dup()

CSTNode get(int index)

int getMeaning()

Returns the meaning of this node.

Token getRoot()

Returns the root of the node.

String getRootText()

Returns the text of the token.

int getStartColumn()

int getStartLine()

Returns the starting column of the node.

String getText()

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

int getType()

static Token newDecimal(String text, int startLine, int startColumn)

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

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

Creates a token that represents an integer.

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

Creates a token that represents a decimal number.

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

Creates a token that represents a keyword.

static Token newPlaceholder(int type)

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

Creates a token that represents an identifier.

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

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

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

Creates a token with the specified meaning.

CSTNode setMeaning(int meaning)

void setText(String text)

Returns the starting line of the node.

int size()

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

 
Methods inherited from class CSTNode
add, addChildrenOf, asReduction, canMean, children, get, get, getDescription, getMeaning, getMeaningAs, getRoot, getRoot, getRootText, getStartColumn, getStartLine, getType, hasChildren, isA, isAllOf, isAnExpression, isEmpty, isOneOf, markAsExpression, set, setMeaning, size, toString, write, write
 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Field Detail

EOF

public static final Token EOF


NULL

public static final Token NULL


 
Constructor Detail

Token

public Token(int type, String text, int startLine, int startColumn)


 
Method Detail

asReduction

public Reduction asReduction()
Creates a Reduction from this token. Returns self if the node is already a Reduction.


asReduction

public Reduction asReduction(CSTNode second)
Creates a Reduction from this token, adding the supplied nodes as the second and third element, respectively.


asReduction

public Reduction asReduction(CSTNode second, CSTNode third)
Creates a Reduction from this token, adding the supplied nodes as the second, third, and fourth element, respectively.


asReduction

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


dup

public Token dup()


get

public CSTNode get(int index)


getMeaning

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


getRoot

public 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 node isEmpty().


getRootText

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


getStartColumn

public int getStartColumn()


getStartLine

public int getStartLine()
Returns the starting column of the node. Returns -1 if not known.


getText

public String getText()
Not advisable, but if you need to adjust the token's text, this will do it.


getType

public int getType()


newDecimal

public static Token newDecimal(String text, int startLine, int startColumn)
Creates a token that represents a symbol, using a library for the text.


newIdentifier

public static Token newIdentifier(String text, int startLine, int startColumn)
Creates a token that represents an integer.


newInteger

public static Token newInteger(String text, int startLine, int startColumn)
Creates a token that represents a decimal number.


newKeyword

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.


newPlaceholder

public static Token newPlaceholder(int type)


newString

public static Token newString(String text, int startLine, int startColumn)
Creates a token that represents an identifier.


newSymbol

public static Token newSymbol(int type, int startLine, int startColumn)
Creates a token that represents a symbol, using a library for the type.


newSymbol

public static Token newSymbol(String type, int startLine, int startColumn)
Creates a token with the specified meaning.


setMeaning

public CSTNode setMeaning(int meaning)


setText

public void setText(String text)
Returns the starting line of the node. Returns -1 if not known.


size

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


 

Copyright © 2003-2013 The Codehaus. All rights reserved.