Struct rowan::GreenNodeBuilder [−][src]
pub struct GreenNodeBuilder<'cache> { /* fields omitted */ }
Expand description
A builder for a green tree.
Implementations
Creates new builder.
Reusing NodeCache
between different GreenNodeBuilder
s saves memory.
It allows to structurally share underlying trees.
Adds new token to the current branch.
Start new node and make it current.
Finish current branch and restore previous branch as current.
Prepare for maybe wrapping the next node.
The way wrapping works is that you first of all get a checkpoint,
then you place all tokens you want to wrap, and then maybe call
start_node_at
.
Example:
let checkpoint = builder.checkpoint();
parser.parse_expr();
if parser.peek() == Some(PLUS) {
// 1 + 2 = Add(1, 2)
builder.start_node_at(checkpoint, OPERATION);
parser.parse_expr();
builder.finish_node();
}
Wrap the previous branch marked by checkpoint
in a new branch and
make it current.
Trait Implementations
Returns the “default value” for a type. Read more