Expand description
Working with abstract syntax trees.
In rowan, syntax trees are transient objects. That means that we create trees when we need them, and tear them down to save memory. In this architecture, hanging on to a particular syntax node for a long time is ill-advisable, as that keeps the whole tree resident.
Instead, we provide a SyntaxNodePtr
type, which stores information about
the location of a particular syntax node in a tree. It’s a small type
which can be cheaply stored, and which can be resolved to a real
SyntaxNode
when necessary.
We also provide an AstNode
trait for typed AST wrapper APIs over rowan
nodes.
Modules§
Structs§
- Like
SyntaxNodePtr
, but remembers the type of node. - A “pointer” to a
SyntaxNode
, via location in the source code.
Traits§
- The main trait to go from untyped
SyntaxNode
to a typed AST. The conversion itself has zero runtime cost: AST and syntax nodes have exactly the same representation: a pointer to the tree root and a pointer to the node itself.