public abstract class CSTNode extends Object
Parser
,
Token
,
Reduction
,
Types
Constructor and Description |
---|
CSTNode() |
Modifier and Type | Method and Description |
---|---|
CSTNode |
add(CSTNode element)
Adds an element to the node.
|
void |
addChildrenOf(CSTNode of)
Adds all children of the specified node to this one.
|
abstract 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.
|
abstract CSTNode |
get(int index)
Returns the specified element, or null.
|
CSTNode |
get(int index,
boolean safe)
Returns the specified element, or Token.NULL if
safe is set and the specified element is null (or doesn't
exist).
|
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.
|
abstract Token |
getRoot()
Returns the root of the node.
|
Token |
getRoot(boolean safe)
Returns the root of the node, the Token that indicates it's
type.
|
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 true if the node has any non-root elements.
|
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).
|
abstract 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)
Formats the node and writes it to the specified
Writer . |
protected void |
write(PrintWriter writer,
String indent)
Formats the node and writes it to the specified
Writer . |
public int getMeaning()
public CSTNode setMeaning(int meaning)
public int getType()
public boolean canMean(int type)
public boolean isA(int type)
public boolean isOneOf(int[] types)
public boolean isAllOf(int[] types)
public int getMeaningAs(int[] types)
public boolean isEmpty()
public abstract int size()
public boolean hasChildren()
public int children()
public abstract CSTNode get(int index)
public CSTNode get(int index, boolean safe)
public abstract Token getRoot()
isEmpty()
.public Token getRoot(boolean safe)
public String getRootText()
getRoot(true)
to get the root, so you will only receive null in return if the
root token returns it.public String getDescription()
public int getStartLine()
public int getStartColumn()
public void markAsExpression()
public boolean isAnExpression()
public CSTNode add(CSTNode element)
public void addChildrenOf(CSTNode of)
public CSTNode set(int index, CSTNode element)
public abstract Reduction asReduction()
Reduction
from this node. Returns self if the
node is already a Reduction
.public String toString()
String
and returns it.public void write(PrintWriter writer)
Writer
.protected void write(PrintWriter writer, String indent)
Writer
.
The indent is prepended to each output line, and is increased for each
recursion.