| Type Params | Return Type | Name and description |
|---|---|---|
|
public Reduction |
asReduction()Converts this token to a Reduction with this token as the root. |
|
public Reduction |
asReduction(CSTNode second)Converts this token to a Reduction with this token as the root and the specified node as the second element. |
|
public Reduction |
asReduction(CSTNode second, CSTNode third)Converts this token to a Reduction with this token as the root and the specified nodes as the second and third elements. |
|
public Reduction |
asReduction(CSTNode second, CSTNode third, CSTNode fourth)Converts this token to a Reduction with this token as the root and the specified nodes as the second, third, and fourth elements. |
|
public Token |
dup()Creates a shallow copy of this Token, preserving type, text, position, and meaning. |
|
public CSTNode |
get(int index)Returns the element at the specified index. |
|
public int |
getMeaning()Returns the current meaning (interpretation) of this token. |
|
public Token |
getRoot()Returns the root token of this node, which is always this token itself. |
|
public String |
getRootText()Returns the text content of this token. |
|
public int |
getStartColumn()Returns the starting column number of this token in the source. |
|
public int |
getStartLine()Returns the starting line number of this token in the source. |
|
public String |
getText()Returns the text content of this token. |
|
public int |
getType()Returns the actual type of this token as determined by the lexer. |
|
public static Token |
newDecimal(String text, int startLine, int startColumn)Factory method to create a decimal number literal token. |
|
public static Token |
newIdentifier(String text, int startLine, int startColumn)Factory method to create an identifier token. |
|
public static Token |
newInteger(String text, int startLine, int startColumn)Factory method to create an integer literal token. |
|
public static Token |
newKeyword(String text, int startLine, int startColumn)Factory method to create a keyword token if the given text represents a known keyword. |
|
public static Token |
newPlaceholder(int meaning)Factory method to create a placeholder token with a specific meaning but unknown text. |
|
public static Token |
newString(String text, int startLine, int startColumn)Factory method to create a string literal token. |
|
public static Token |
newSymbol(int type, int startLine, int startColumn)Factory method to create a symbol token from a type constant. |
|
public static Token |
newSymbol(String text, int startLine, int startColumn)Factory method to create a symbol token from text. |
|
public CSTNode |
setMeaning(int meaning)Sets the meaning (interpretation) for this token. |
|
public void |
setText(String text)Sets the text content of this token. |
|
public int |
size()Returns the number of elements in this node, which is always 1 (the token itself). |
| Methods inherited from class | Name |
|---|---|
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 |
Sentinel token indicating end-of-file.
Sentinel token for null/unknown positions.
Constructs a Token with the specified type, text, and source position.
type - the token type from Typestext - the token's text contentstartLine - the source line number (1-based, or -1 if unknown)startColumn - the source column number (1-based, or -1 if unknown)Converts this token to a Reduction with this token as the root.
Converts this token to a Reduction with this token as the root and the specified node as the second element.
second - the second element to add to the reductionConverts this token to a Reduction with this token as the root and the specified nodes as the second and third elements.
second - the second element to add to the reductionthird - the third element to add to the reductionConverts this token to a Reduction with this token as the root and the specified nodes as the second, third, and fourth elements.
second - the second element to add to the reductionthird - the third element to add to the reductionfourth - the fourth element to add to the reductionCreates a shallow copy of this Token, preserving type, text, position, and meaning.
Returns the element at the specified index. Only index 0 (the token itself) is valid.
index - the element indexReturns the current meaning (interpretation) of this token. May differ from getType() if the meaning has been reassigned.
Returns the root token of this node, which is always this token itself.
Returns the text content of this token. Equivalent to getText().
Returns the starting column number of this token in the source.
Returns the starting line number of this token in the source.
Returns the text content of this token.
Returns the actual type of this token as determined by the lexer.
Factory method to create a decimal number literal token.
text - the decimal literal textstartLine - the source line number (1-based)startColumn - the source column number (1-based)Factory method to create an identifier token.
text - the identifier namestartLine - the source line number (1-based)startColumn - the source column number (1-based)Factory method to create an integer literal token.
text - the integer literal text (may include prefix and suffix)startLine - the source line number (1-based)startColumn - the source column number (1-based)Factory method to create a keyword token if the given text represents a known keyword.
text - the text to check as a keywordstartLine - the source line number (1-based)startColumn - the source column number (1-based)null if the text is not a keywordFactory method to create a placeholder token with a specific meaning but unknown text. Used internally during parsing to hold semantic information.
meaning - the token's meaning type from TypesFactory method to create a string literal token.
text - the string contentstartLine - the source line number (1-based)startColumn - the source column number (1-based)Factory method to create a symbol token from a type constant. The symbol text is looked up from the Types registry.
type - the symbol type from TypesstartLine - the source line number (1-based)startColumn - the source column number (1-based)Factory method to create a symbol token from text. The symbol type is looked up from the Types registry.
text - the symbol text (e.g., "+", "-", "{")startLine - the source line number (1-based)startColumn - the source column number (1-based)Sets the meaning (interpretation) for this token. Has no effect on the sentinel tokens (EOF and NULL).
meaning - the new meaning type from TypesSets the text content of this token. Has no effect on the sentinel tokens (EOF and NULL).
text - the new text contentReturns the number of elements in this node, which is always 1 (the token itself).
Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.