Package org.codehaus.groovy.syntax
Class Reduction
java.lang.Object
org.codehaus.groovy.syntax.CSTNode
org.codehaus.groovy.syntax.Reduction
public class Reduction extends CSTNode
A syntax reduction, produced by the
Parser.-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description CSTNodeadd(CSTNode element)Adds an element to the node.ReductionasReduction()Creates aReductionfrom this node.CSTNodeget(int index)Returns the specified element, or null.TokengetRoot()Returns the root of the node, the Token that indicates its type.booleanisAnExpression()Returns true if the node is a complete expression.booleanisEmpty()Returns true if the node is completely empty (no root, even).voidmarkAsExpression()Marks the node a complete expression.static ReductionnewContainer()Creates a newReductionwithToken.NULLas its root.CSTNoderemove(int index)Removes a node from theReduction.CSTNodeset(int index, CSTNode element)Sets an element in at the specified index.intsize()Returns the number of elements in the node.Methods inherited from class org.codehaus.groovy.syntax.CSTNode
addChildrenOf, canMean, children, get, getDescription, getMeaning, getMeaningAs, getRoot, getRootText, getStartColumn, getStartLine, getType, hasChildren, isA, isAllOf, isOneOf, setMeaning, toString, write, writeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
EMPTY
-
-
Constructor Details
-
Reduction
Initializes theReductionwith the specified root.
-
-
Method Details
-
newContainer
Creates a newReductionwithToken.NULLas its root. -
isEmpty
public boolean isEmpty()Returns true if the node is completely empty (no root, even). -
size
public int size()Returns the number of elements in the node. -
get
Returns the specified element, or null. -
getRoot
Returns the root of the node, the Token that indicates its type. Returns null if there is no root (usually only if the node is a placeholder of some kind -- see isEmpty()). -
markAsExpression
public void markAsExpression()Marks the node a complete expression.- Overrides:
markAsExpressionin classCSTNode
-
isAnExpression
public boolean isAnExpression()Returns true if the node is a complete expression.- Overrides:
isAnExpressionin classCSTNode
-
add
Adds an element to the node. -
set
Sets an element in at the specified index. -
remove
Removes a node from theReduction. You cannot remove the root node (index 0). -
asReduction
Creates aReductionfrom this node. Returns self if the node is already aReduction.- Specified by:
asReductionin classCSTNode
-