|
|||||
FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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.
Constructor Summary | |
CSTNode()
|
Method Summary | |
---|---|
CSTNode |
add(CSTNode element)
Adds an element to the node. |
void |
addChildrenOf(CSTNode of)
Adds all children of the specified node to this one. |
Reduction |
asReduction()
Creates a Reduction from this node.
|
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)
Returns the specified element, or null. |
String |
getDescription()
Returns a description of the node. |
int |
getMeaning()
Returns the meaning of this node. |
int |
getMeaningAs(def types)
Returns the first matching meaning of the specified types. |
Token |
getRoot()
Returns the root of the node. |
Token |
getRoot(boolean safe)
Returns the root of the node. |
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()
Returns the number of elements in the node (including root). |
boolean |
isA(int type)
Returns true if the node's meaning matches the specified type. |
boolean |
isAllOf(def 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(def types)
Returns true if the node's meaning matches any of the specified types. |
void |
markAsExpression()
Marks the node a complete expression. |
boolean |
matches(int type)
Returns true if the node matches the specified type. |
boolean |
matches(int type, int child1)
Returns true if the node and it's first child match the specified types. |
boolean |
matches(int type, int child1, int child2)
Returns true if the node and it's first and second child match the specified types. |
boolean |
matches(int type, int child1, int child2, int child3)
Returns true if the node and it's first three children match the specified types. |
boolean |
matches(int type, int child1, int child2, int child3, int child4)
Returns true if the node an it's first four children match the specified types. |
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()
Creates a Reduction from this node.
|
void |
write(PrintWriter writer)
Formats the node and writes it to the specified Writer .
|
void |
write(PrintWriter writer, String indent)
Formats the node and writes it to the specified Writer .
|
Constructor Detail |
---|
CSTNode()
Method Detail |
---|
public CSTNode add(CSTNode element)
public void addChildrenOf(CSTNode of)
public Reduction asReduction()
Reduction
from this node. Returns self if the
node is already a Reduction
.
public boolean canMean(int type)
public int children()
public CSTNode get(int index)
public CSTNode get(int index, boolean safe)
public String getDescription()
public int getMeaning()
public int getMeaningAs(def types)
public Token getRoot()
isEmpty()
.
public Token getRoot(boolean safe)
isEmpty()
.
public String getRootText()
getRoot(true)
to get the root, so you will only receive null in return if the
root token returns it.
public int getStartColumn()
public int getStartLine()
public int getType()
public boolean hasChildren()
public boolean isA(int type)
public boolean isAllOf(def types)
public boolean isAnExpression()
public boolean isEmpty()
public boolean isOneOf(def types)
public void markAsExpression()
public boolean matches(int type)
isA()
. Missing nodes are Token.NULL.
public boolean matches(int type, int child1)
public boolean matches(int type, int child1, int child2)
public boolean matches(int type, int child1, int child2, int child3)
public boolean matches(int type, int child1, int child2, int child3, int child4)
public CSTNode set(int index, CSTNode element)
public CSTNode setMeaning(int meaning)
public int size()
public String toString()
Reduction
from this node. Returns self if the
node is already a Reduction
.
public void write(PrintWriter writer)
Writer
.
void write(PrintWriter writer, String indent)
Writer
.
The indent is prepended to each output line, and is increased for each
recursion.