Interface CAstNode

All Known Subinterfaces:
CAstLeafNode, JavaScriptCAstNode
All Known Implementing Classes:
CAstImpl.CAstNodeImpl, CAstImpl.CAstValueImpl, CAstOperator, CAstValueImpl.CAstNodeValueImpl, CAstValueImpl.CAstValueValueImpl

public interface CAstNode
This interface represents nodes of CAPA Abstract Syntax Trees. It is a deliberately minimal interface, simply assuming that the nodes form a tree and have some minimal state at each node. In particular, a node has a kind---which should be one of the symbolic constants in this file---and potentially has child nodes, a constant values, or possibly both.

Note that there is no support for mutating these trees. This is deliberate, and should not be changed. We do not want to force all clients of the capa ast to handle mutating programs. In particular, the DOMO infrastructure has many forms of caching and other operations that rely on the underlying program being immutable. If you need to mutate these trees for some reason---and think carefully if you really need to, since this is meant to be essentially a wire format between components---make specialized implementations that understand how to do that.

Also note that this interface does not assume that you need some great big class hierarchy to structure types of nodes in an ast. Some people prefer such hierarchies as a matter of taste, but this interface is designed to not inflict this design choice on others.

Finally note that the set of node types in this file is not meant to be exhaustive. As new languages are added, feel free to add new nodes types as needed.

Author:
Julian Dolby (dolby@us.ibm.com), Robert M. Fuhrer (rfuhrer@watson.ibm.com)