An abstract base class for nodes in the concrete syntax tree that is the result of parsing. Note that the CSTNode is inextricably linked with the Token in that every CSTNode has a Token as it's root.
| Type | Name and description |
|---|---|
CSTNode |
add(CSTNode element)Adds an element to the node. |
void |
addChildrenOf(CSTNode of) |
Reduction |
asReduction() |
boolean |
canMean(int type)Returns true if the node can be coerced to the specified type. |
int |
children()Returns the number of non-root elements in the node. |
CSTNode |
get(int index)Returns the specified element, or null. |
CSTNode |
get(int index, boolean safe) |
String |
getDescription()Returns a description of the node. |
int |
getMeaning()Returns the meaning of this node. |
int |
getMeaningAs(int[] types)Returns the first matching meaning of the specified types. |
Token |
getRoot()Returns the root of the node. |
Token |
getRoot(boolean safe) |
String |
getRootText()Returns the text of the root. |
int |
getStartColumn()Returns the starting column of the node. |
int |
getStartLine()Returns the starting line of the node. |
int |
getType()Returns the actual type of the node. |
boolean |
hasChildren() |
boolean |
isA(int type)Returns true if the node's meaning matches the specified type. |
boolean |
isAllOf(int[] types)Returns true if the node's meaning matches all of the specified types. |
boolean |
isAnExpression()Returns true if the node is a complete expression. |
boolean |
isEmpty()Returns true if the node is completely empty (no root, even). |
boolean |
isOneOf(int[] types)Returns true if the node's meaning matches any of the specified types. |
void |
markAsExpression()Marks the node a complete expression. |
CSTNode |
set(int index, CSTNode element)Sets an element node in at the specified index. |
CSTNode |
setMeaning(int meaning)Sets the meaning for this node (and it's root Token). |
int |
size()Returns the number of elements in the node (including root). |
String |
toString()Formats the node as a String and returns it. |
void |
write(PrintWriter writer) |
protected void |
write(PrintWriter writer, String indent) |
Adds an element to the node. Returns the element for convenience. Not all nodes support this operation!
Returns true if the node can be coerced to the specified type.
Returns the number of non-root elements in the node.
Returns the specified element, or null.
Returns a description of the node.
Returns the meaning of this node. If the node isEmpty(), returns the type of Token.NULL.
Returns the first matching meaning of the specified types. Returns Types.UNKNOWN if there are no matches.
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().
Returns the text of the root. Uses getRoot(true)
to get the root, so you will only receive null in return if the
root token returns it.
Returns the starting column of the node. Returns -1 if not known.
Returns the starting line of the node. Returns -1 if not known.
Returns the actual type of the node. If the node isEmpty(), returns the type of Token.NULL.
Returns true if the node's meaning matches the specified type.
Returns true if the node's meaning matches all of the specified types.
Returns true if the node is a complete expression.
Returns true if the node is completely empty (no root, even).
Returns true if the node's meaning matches any of the specified types.
Marks the node a complete expression. Not all nodes support this operation!
Sets an element node in at the specified index. Returns the element for convenience. Not all nodes support this operation!
Sets the meaning for this node (and it's root Token). Not valid if the node isEmpty(). Returns the node, for convenience.
Returns the number of elements in the node (including root).
Formats the node as a String and returns it.