Tree¶
-
public abstract class
Tree
¶ A node of an Abstract Syntax Tree.
Methods¶
addChild¶
-
public void
addChild
(Tree addedChild, int rank)¶ Adds a new child to this node. Allowed only when this is a list node. Inserts the added child so that its rank will be “rank” (rank of 1st child is 1). Negative ranks are allowed, designating positions backward from the end, e.g -1 is last child, -2 is last but one.
addChildren¶
-
public void
addChildren
(Tree[] addedChildren, int rank)¶ Adds a set of new children to this node. Allowed only when this is a list node. Inserts the addedChildren so that the rank of the first of them will be “rank” (rank of 1st child is 1). Negative ranks are allowed, designating positions backward from the end, e.g -1 is last child, -2 is last but one. When rank is negative, it will be the position of the last of addedChildren.
addChildren¶
-
public void
addChildren
(TapList<Tree> addedChildren, int rank)¶ Adds a set of new children to this node. Allowed only when this is a list node. Inserts the addedChildren so that the rank of the first of them will be “rank” (rank of 1st child is 1). Negative ranks are allowed, designating positions backward from the end, e.g -1 is last child, -2 is last but one. When rank is negative, it will be the position of the last of addedChildren.
allAnnotations¶
-
public Enumeration<?>
allAnnotations
()¶ - Returns
all annotations currently attached to this Tree.
checkSyntax¶
checkSyntax¶
children¶
childrenList¶
connectNewChild¶
-
protected void
connectNewChild
(Tree newChild, Tree[] parentNewChildren, int index)¶ Utility to branch a child Tree under this Tree, as its new index-th child, with a correct full management of the “parent” links.
- Parameters
parentNewChildren – the future array of children of this parent tree, which may be different from the previous array, for instance in the case of variable-arity lists.
copy¶
copyAnnotations¶
-
public void
copyAnnotations
(Tree model)¶ Copies the annotations of the model onto this Tree. Also manages copies of unfinished identifiers such as #xd#. TODO: annotations are dangerous: copyAnnotations() share them between copies only when the annotation already exists, Some parts on the code rely on this! This should be cleaned up, but meanwhile, we force explicit sharing upon copy for some specific annotations (see annotationsToShareAlways).
cutChild¶
down¶
equalsTree¶
getAnnotation¶
getAnnotationPair¶
getRank¶
getRemoveAnnotation¶
intValue¶
-
public int
intValue
()¶ - Returns
the integer value contained in this atom node. Allowed only when this is an integer atom node.
isIntAtom¶
-
public abstract boolean
isIntAtom
()¶ - Returns
True iff this Tree node is an atom that contains an integer.
isStringAtom¶
-
public abstract boolean
isStringAtom
()¶ - Returns
True iff this Tree node is an atom that contains a String.
length¶
-
public int
length
()¶ - Returns
the number of children of this Tree node. Allowed only when this is either a fixed or list arity node, but not an atom node.
rankInParent¶
-
public int
rankInParent
()¶ - Returns
the rank of this node in its parent node. Rank starts at 1. @return -1 if no parent.
removeAnnotation¶
removeChild¶
-
public void
removeChild
(int rank)¶ Cuts off this Tree’s child of rank “rank” (rank of 1st child is 1). Allowed only when this is a list arity node. Leaves no hole in this Tree in place of the cut child.
setAnnotation¶
setChild¶
-
public void
setChild
(Tree newChild, int rank)¶ Replaces this Tree’s child of rank “rank” with the new child (rank of 1st child is 1). Allowed only when this is either a fixed or list arity node, but not an atom node. When this is a list node and rank is larger than its length, this enlarges the list and pads with null children (is this really necessary?)
setValue¶
-
public void
setValue
(int value)¶ Sets the value attached to an integer atom Tree node. Allowed only when this is an integer atom node.
setValue¶
stringValue¶
writeToILFile¶
-
protected abstract void
writeToILFile
(java.io.BufferedWriter fileWriter)¶ Prints into a file, as an AST.
- Throws
IOException – if an input or output error is detected.