Package org.extendj.neobeaver.ast
Class ASTNode<T extends ASTNode>
- java.lang.Object
-
- org.extendj.neobeaver.ast.ASTNode<T>
-
- All Implemented Interfaces:
java.lang.Cloneable,Parser.Symbol
- Direct Known Subclasses:
ActionName,GAction,GComponent,GDecl,GGrammar,GPrecedence,GRule,GSym,List,Opt,Type
public class ASTNode<T extends ASTNode> extends java.lang.Object implements java.lang.Cloneable, Parser.Symbol
-
-
Field Summary
Fields Modifier and Type Field Description protected ASTNode[]childrenstatic booleangeneratedWithCacheCycleprotected intnumChildrenprotected ASTNodeparent
-
Constructor Summary
Constructors Constructor Description ASTNode()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaccept(GVisitor vis)voidaddChild(T node)java.util.Iterator<T>astChildIterator()java.lang.Iterable<T>astChildren()ASTNode<T>clone()ASTNode<T>copy()voiddoFullTraversal()Performs a full traversal of the tree using getChild to trigger rewritesvoidflushAttrAndCollectionCache()voidflushAttrCache()voidflushCache()voidflushCollectionCache()voidflushTreeCache()ASTNode<T>fullCopy()Deprecated.Please use treeCopy or treeCopyNoTransform insteadTgetChild(int i)TgetChildNoTransform(int i)Gets a child without triggering rewrites.intgetIndexOfChild(ASTNode node)intgetNumChild()intgetNumChildNoTransform()Behaves like getNumChild, but does not invoke AST transformations (rewrites).ASTNodegetParent()Parser.SourcePositiongetPosition()voidinit$Children()Initializes the child array to the correct size.voidinsertChild(ASTNode node, int i)protected booleanis$Equal(ASTNode node)protected booleanis$Equal(ASTNode n1, ASTNode n2)protected intnumChildren()voidremoveChild(int i)static ASTStateresetState()ASTNoderewrittenNode()voidsetChild(ASTNode node, int i)voidsetParent(ASTNode node)ASTNodesetPosition(Parser.Symbol sym)ASTStatestate()ASTNode<T>treeCopy()Create a deep copy of the AST subtree at this node.ASTNode<T>treeCopyNoTransform()Create a deep copy of the AST subtree at this node.
-
-
-
Field Detail
-
generatedWithCacheCycle
public static final boolean generatedWithCacheCycle
- See Also:
- Constant Field Values
-
parent
protected ASTNode parent
-
children
protected ASTNode[] children
-
numChildren
protected int numChildren
-
-
Method Detail
-
setPosition
public ASTNode setPosition(Parser.Symbol sym)
-
getPosition
public Parser.SourcePosition getPosition()
- Specified by:
getPositionin interfaceParser.Symbol
-
accept
public void accept(GVisitor vis)
-
init$Children
public void init$Children()
Initializes the child array to the correct size. Initializes List and Opt nta children.
-
getIndexOfChild
public int getIndexOfChild(ASTNode node)
-
state
public final ASTState state()
-
resetState
public static final ASTState resetState()
-
astChildIterator
public java.util.Iterator<T> astChildIterator()
- Returns:
- an iterator that can be used to iterate over the children of this node. The iterator does not allow removing children.
-
astChildren
public java.lang.Iterable<T> astChildren()
- Returns:
- an object that can be used to iterate over the children of this node
-
getChild
public T getChild(int i)
-
addChild
public void addChild(T node)
-
getChildNoTransform
public T getChildNoTransform(int i)
Gets a child without triggering rewrites.
-
numChildren
protected int numChildren()
-
getNumChild
public int getNumChild()
-
getNumChildNoTransform
public final int getNumChildNoTransform()
Behaves like getNumChild, but does not invoke AST transformations (rewrites).
-
setChild
public void setChild(ASTNode node, int i)
-
insertChild
public void insertChild(ASTNode node, int i)
-
removeChild
public void removeChild(int i)
-
getParent
public ASTNode getParent()
-
setParent
public void setParent(ASTNode node)
-
flushTreeCache
public void flushTreeCache()
-
flushCache
public void flushCache()
-
flushAttrAndCollectionCache
public void flushAttrAndCollectionCache()
-
flushAttrCache
public void flushAttrCache()
-
flushCollectionCache
public void flushCollectionCache()
-
clone
public ASTNode<T> clone() throws java.lang.CloneNotSupportedException
- Overrides:
clonein classjava.lang.Object- Throws:
java.lang.CloneNotSupportedException
-
fullCopy
@Deprecated public ASTNode<T> fullCopy()
Deprecated.Please use treeCopy or treeCopyNoTransform insteadCreate a deep copy of the AST subtree at this node. The copy is dangling, i.e. has no parent.- Returns:
- dangling copy of the subtree at this node
-
treeCopyNoTransform
public ASTNode<T> treeCopyNoTransform()
Create a deep copy of the AST subtree at this node. The copy is dangling, i.e. has no parent.- Returns:
- dangling copy of the subtree at this node
-
treeCopy
public ASTNode<T> treeCopy()
Create a deep copy of the AST subtree at this node. The subtree of this node is traversed to trigger rewrites before copy. The copy is dangling, i.e. has no parent.- Returns:
- dangling copy of the subtree at this node
-
doFullTraversal
public void doFullTraversal()
Performs a full traversal of the tree using getChild to trigger rewrites
-
is$Equal
protected boolean is$Equal(ASTNode node)
-
rewrittenNode
public ASTNode rewrittenNode()
-
-