In computer science, a tree is a widely used abstract data type (ADT), or data structure implementing this ADT, that simulates a hierarchical tree structure, with a root value and subtrees of children with a parent node, represented as a set of linked nodes. A tree data structure can be defined recursively (locally) as a collection of nodes (starting at a root node), where each node is a data structure consisting of a value, together with a list of references to nodes (the “children”), with the constraints that no reference is duplicated, and none points to the root. Alternatively, a tree can be defined abstractly as a whole (globally) as an ordered tree, with a value assigned to each node. Both these perspectives are useful: while a tree can be analyzed mathematically as a whole, when actually represented as a data structure it is usually represented and worked with separately by node (rather than as a set of nodes and an adjacency list of edges between nodes, as one may represent a digraph, for instance). For example, looking at a tree as a whole, one can talk about “the parent node” of a given node, but in general as a data structure a given node only contains the list of its children, but does not contain a reference to its parent (if any).
Generally all variables, functions and namespaces are nodes in one big Easypt tree. The best explanation is output of the following line:
Root.debugTree();
Output:
something way too long too publish here
(Skip reading whole output if you get the idea.)
Output could have more than 1000 lines. Pretty big tree. debugTree
is Object
method so printing any subtree of whole tree is possible. Additionally, some variables (freshly created by constructors) might not be connected to tree yet.
Object
Object
provide following methods for manipulating the tree:
debugTree
Object
as rootObject
getParent
Object
hasChild
Object
has child named as first argument valueString
(name of child to check)Boolean
getChild
value
String
(name of child to return)addChild
Object
with given object’s nameObject
Object
with given nameString
(name), object of any typeObject
Code:
auto mother;
auto father;
#
Here the "weirdest" syntax comes,
It not also attach son as child to
mother, but also attach mother
as parent to son.
#
mother.var son;
father.var daughter;
# Adds father's daughter as step-daughter #
mother.addChild("step-daughter", father.getChild("daughter"));
mother.addChild(Object());
auto childrenArray.=(mother.getChildrenArray());
for (auto it.=(childrenArray.begin()).!=, childrenArray.end(), it.++, {
if (instanceOf(it.get(), Object), {
log(it.get().getName());
});
});
mother.debugTree();