Constructor and Description |
---|
Token(int type,
java.lang.String text,
int startLine,
int startColumn)
Initializes the Token with the specified information.
|
Modifier and Type | Method and Description |
---|---|
Reduction |
asReduction()
Creates a
Reduction from this token. |
Reduction |
asReduction(CSTNode second)
Creates a
Reduction from this token, adding the supplied
node as the second element. |
Reduction |
asReduction(CSTNode second,
CSTNode third)
Creates a
Reduction from this token, adding the supplied
nodes as the second and third element, respectively. |
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. |
Token |
dup()
Returns a copy of this Token.
|
CSTNode |
get(int index)
Returns the specified element, or null.
|
int |
getMeaning()
Returns the meaning of this node.
|
Token |
getRoot()
Returns the root of the node.
|
java.lang.String |
getRootText()
Returns the text of the root node.
|
int |
getStartColumn()
Returns the starting column of the node.
|
int |
getStartLine()
Returns the starting line of the node.
|
java.lang.String |
getText()
Returns the text of the token.
|
int |
getType()
Returns the actual type of the node.
|
static Token |
newDecimal(java.lang.String text,
int startLine,
int startColumn)
Creates a token that represents a decimal number.
|
static Token |
newIdentifier(java.lang.String text,
int startLine,
int startColumn)
Creates a token that represents an identifier.
|
static Token |
newInteger(java.lang.String text,
int startLine,
int startColumn)
Creates a token that represents an integer.
|
static Token |
newKeyword(java.lang.String text,
int startLine,
int startColumn)
Creates a token that represents a keyword.
|
static Token |
newPlaceholder(int type)
Creates a token with the specified meaning.
|
static Token |
newString(java.lang.String text,
int startLine,
int startColumn)
Creates a token that represents a double-quoted string.
|
static Token |
newSymbol(int type,
int startLine,
int startColumn)
Creates a token that represents a symbol, using a library for the text.
|
static Token |
newSymbol(java.lang.String type,
int startLine,
int startColumn)
Creates a token that represents a symbol, using a library for the type.
|
CSTNode |
setMeaning(int meaning)
Sets the meaning for this node (and it's root Token).
|
void |
setText(java.lang.String text)
Not advisable, but if you need to adjust the token's text, this
will do it.
|
int |
size()
Returns the number of elements in the node (including root).
|
add, addChildrenOf, canMean, children, get, getDescription, getMeaningAs, getRoot, hasChildren, isA, isAllOf, isAnExpression, isEmpty, isOneOf, markAsExpression, set, toString, write, write
public Token(int type, java.lang.String text, int startLine, int startColumn)
public Token dup()
public int getMeaning()
getMeaning
in class CSTNode
public CSTNode setMeaning(int meaning)
setMeaning
in class CSTNode
public int getType()
public int size()
public CSTNode get(int index)
public Token getRoot()
isEmpty()
.public java.lang.String getRootText()
getRoot(true)
to get the root, so you will only receive null in return if the
root token returns it.getRootText
in class CSTNode
public java.lang.String getText()
getRootText()
when called directly.public void setText(java.lang.String text)
public int getStartLine()
getStartLine
in class CSTNode
public int getStartColumn()
getStartColumn
in class CSTNode
public Reduction asReduction()
Reduction
from this token. Returns self if the
node is already a Reduction
.asReduction
in class CSTNode
public Reduction asReduction(CSTNode second)
Reduction
from this token, adding the supplied
node as the second element.public Reduction asReduction(CSTNode second, CSTNode third)
Reduction
from this token, adding the supplied
nodes as the second and third element, respectively.public Reduction asReduction(CSTNode second, CSTNode third, CSTNode fourth)
Reduction
from this token, adding the supplied
nodes as the second, third, and fourth element, respectively.public static Token newKeyword(java.lang.String text, int startLine, int startColumn)
public static Token newString(java.lang.String text, int startLine, int startColumn)
public static Token newIdentifier(java.lang.String text, int startLine, int startColumn)
public static Token newInteger(java.lang.String text, int startLine, int startColumn)
public static Token newDecimal(java.lang.String text, int startLine, int startColumn)
public static Token newSymbol(int type, int startLine, int startColumn)
public static Token newSymbol(java.lang.String type, int startLine, int startColumn)
public static Token newPlaceholder(int type)