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 GreenNodeBuilders 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.

Complete tree building. Make sure that start_node_at and finish_node calls are paired!

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.