Skip to content

Node

interface Node

An element in an abstract tree.

It is not expected that users of this library have to deal with this class directly.

Trees

Trees are expected to be built bottom-up: a node is always built before its parents. Once a node has been accepted by a parent, it freezes (becomes forever immutable). The same node may be added to multiple parent nodes.

This schemes ensures that trees are always as simplified as possible: we are always building a single node at a time, and all its children are guaranteed to be immutable and fully simplified.

There are two main categories of nodes:

  • Nodes that represent some data by themselves,

  • Nodes that group other nodes into a single larger node.

The former category implements this interface, whereas the latter implements CompoundNode.

Inheritors

Functions

freeze

@LowLevelApi



abstract fun freeze()

Makes this node immutable.

After this method has been called, the expression can never be modified again. This ensures that nodes cannot change after they have been used within other nodes.

To learn more about this process, see Node.