[−][src]Struct rowan::GreenNodeBuilder
A builder for a green tree.
Methods
impl<T: Types> GreenNodeBuilder<T>
[src]
impl<T: Types> GreenNodeBuilder<T>
pub fn new() -> Self | [src] |
Creates new builder.
pub fn leaf(&mut self, kind: T::Kind, text: SmolStr) | [src] |
Adds new leaf to the current branch.
pub fn start_internal(&mut self, kind: T::Kind) | [src] |
Start new branch and make it current.
pub fn finish_internal(&mut self) | [src] |
Finish current branch and restore previous branch as current.
pub fn checkpoint(&self) -> Checkpoint | [src] |
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:
ⓘThis example is not tested
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(); }
pub fn start_internal_at(&mut self, checkpoint: Checkpoint, kind: T::Kind) | [src] |
Wrap the previous branch marked by checkpoint
in a new branch and
make it current.
pub fn finish(self) -> GreenNode<T> | [src] |
Complete tree building. Make sure that
start_internal
and finish_internal
calls
are paired!
Trait Implementations
Auto Trait Implementations
impl<T> Send for GreenNodeBuilder<T> where
<T as Types>::Kind: Send + Sync,
impl<T> Send for GreenNodeBuilder<T> where
<T as Types>::Kind: Send + Sync,
impl<T> Sync for GreenNodeBuilder<T> where
<T as Types>::Kind: Send + Sync,
impl<T> Sync for GreenNodeBuilder<T> where
<T as Types>::Kind: Send + Sync,
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> | [src] |
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId | [src] |
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T | [src] |
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error> | [src] |
impl<T> Erased for T
impl<T> Erased for T