Skip to main content

EvalNode

Struct EvalNode 

pub struct EvalNode<'a, T> { /* private fields */ }
Expand description

One node under ParseResult::eval: dispatch on name, fold children on demand with eval.

Implementations§

§

impl<'a, T> EvalNode<'a, T>

pub fn name(&self) -> &'a str

The rule display name for a tree node, the token TYPE name (e.g. "NUMBER") for a token — rule names are lowercase and terminal names uppercase by Lark convention, so one match dispatches both — and "" for a placeholder hole.

pub fn len(&self) -> usize

Number of children (0 for a leaf).

pub fn is_empty(&self) -> bool

pub fn eval(&self, i: usize) -> T

Fold child i by re-entering the evaluator closure. Children not evaled are never visited — arms may skip subtrees.

§Panics

On a leaf node or an out-of-range index (like slice indexing).

pub fn eval_all(&self) -> Vec<T>

Fold every child, in order.

pub fn token(&self) -> Option<&'a Token>

The token behind this node, when it is a token leaf.

pub fn text(&self) -> &'a str

The token text, or "" for non-token nodes.

Auto Trait Implementations§

§

impl<'a, T> !RefUnwindSafe for EvalNode<'a, T>

§

impl<'a, T> !Send for EvalNode<'a, T>

§

impl<'a, T> !Sync for EvalNode<'a, T>

§

impl<'a, T> !UnwindSafe for EvalNode<'a, T>

§

impl<'a, T> Freeze for EvalNode<'a, T>
where &'a dyn Fn(&EvalNode<'_, T>) -> T: Freeze,

§

impl<'a, T> Unpin for EvalNode<'a, T>
where &'a dyn Fn(&EvalNode<'_, T>) -> T: Unpin,

§

impl<'a, T> UnsafeUnpin for EvalNode<'a, T>
where &'a dyn Fn(&EvalNode<'_, T>) -> T: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.