Struct rowan::GreenNodeBuilder

source ·
pub struct GreenNodeBuilder<T: Types> { /* private fields */ }
Expand description

A builder for a green tree.

Implementations

Creates new builder.

Adds new leaf to the current branch.

Start new branch 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_internal_at. Example:

let checkpoint = builder.checkpoint();
self.parse_expr();
if self.peek() == Some(Token::Plus) {
  // 1 + 2 = Add(1, 2)
  builder.start_internal_at(checkpoint, Token::Operation);
  self.parse_expr();
  builder.finish_internal();
}

Wrap the previous branch marked by checkpoint in a new branch and make it current.

Complete tree building. Make sure that start_internal and finish_internal calls are paired!

Trait Implementations

Formats the value using the given formatter. 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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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.