Struct rustemo::Forest

source ·
pub struct Forest<'i, I, P, TK>
where I: Input + ?Sized, TK: Copy,
{ /* private fields */ }
Expand description

Shared Packed Parse Forest (SPPF) returned by the GLR parser.

A forest is an ordered collection of trees. Basically, a wrapper around GSS structure to provide information about number of trees/solutions, ambiguities and to provide tree extraction/navigation.

Trees of the forest are ordered and each tree can be extracted as either an eager or a lazy tree given its index.

Implementations§

source§

impl<'i, I, P, TK> Forest<'i, I, P, TK>
where I: Input + ?Sized, TK: Copy,

source

pub fn new(results: Vec<Rc<SPPFTree<'i, I, P, TK>>>) -> Self

source

pub fn get_first_tree(&self) -> Option<Tree<'i, I, P, TK>>

source

pub fn get_tree(&self, idx: usize) -> Option<Tree<'i, I, P, TK>>

Extracts a tree with the given index

source

pub fn is_empty(&self) -> bool

source

pub fn solutions(&self) -> usize

The total number of trees/solutions in this forest.

source

pub fn ambiguities(&self) -> usize

Total number of ambiguous places/nodes in this forest.

Extracted trees are unambiguous but forests may have ambiguities. If there is >1 trees in the forest there are ambiguities.

source§

impl<'i, I, P, TK> Forest<'i, I, P, TK>
where I: Input + ?Sized, TK: Copy,

Support for iter()

source

pub fn iter<'f>(&'f self) -> ForestIterator<'i, 'f, I, P, TK>

Trait Implementations§

source§

impl<'i, I, P: Debug, TK> Debug for Forest<'i, I, P, TK>
where I: Input + ?Sized + Debug, TK: Copy + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'i, 'f, I, P, TK> IntoIterator for &'f Forest<'i, I, P, TK>
where I: Input + ?Sized, TK: Copy,

For loop iteration over borrowed Forest

§

type Item = Tree<'i, I, P, TK>

The type of the elements being iterated over.
§

type IntoIter = ForestIterator<'i, 'f, I, P, TK>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'i, I, P, TK> IntoIterator for Forest<'i, I, P, TK>
where I: Input + ?Sized, TK: Copy,

§

type Item = Tree<'i, I, P, TK>

The type of the elements being iterated over.
§

type IntoIter = ForestIntoIter<'i, I, P, TK>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<'i, I, P, TK> !RefUnwindSafe for Forest<'i, I, P, TK>

§

impl<'i, I, P, TK> !Send for Forest<'i, I, P, TK>

§

impl<'i, I, P, TK> !Sync for Forest<'i, I, P, TK>

§

impl<'i, I: ?Sized, P, TK> Unpin for Forest<'i, I, P, TK>

§

impl<'i, I, P, TK> !UnwindSafe for Forest<'i, I, P, TK>

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>,

§

type Error = Infallible

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>,

§

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.