pub struct StateTable<StorageT> { /* private fields */ }
Expand description

A representation of a StateTable for a grammar. actions and gotos are split into two separate hashmaps, rather than a single table, due to the different types of their values.

Implementations§

source§

impl<StorageT: 'static + Hash + PrimInt + Unsigned> StateTable<StorageT>
where usize: AsPrimitive<StorageT>,

source

pub fn new( grm: &YaccGrammar<StorageT>, sg: &StateGraph<StorageT> ) -> Result<Self, StateTableError<StorageT>>

source

pub fn action( &self, stidx: StIdx<StorageT>, tidx: TIdx<StorageT> ) -> Action<StorageT>

Return the action for stidx and sym, or None if there isn’t any.

source

pub fn state_actions( &self, stidx: StIdx<StorageT> ) -> StateActionsIterator<'_, StorageT>

Return an iterator over the indexes of all non-empty actions of stidx.

source

pub fn state_shifts( &self, stidx: StIdx<StorageT> ) -> StateActionsIterator<'_, StorageT>

Return an iterator over the indexes of all shift actions of stidx. By definition this is a subset of the indexes produced by state_actions.

source

pub fn reduce_only_state(&self, stidx: StIdx<StorageT>) -> bool

Does the state stidx 1) only contain reduce (and error) actions 2) do those reductions all reduce to the same production?

source

pub fn core_reduces( &self, stidx: StIdx<StorageT> ) -> CoreReducesIterator<'_, StorageT>

Return an iterator over a set of “core” reduces of stidx. This is a minimal set of reduce actions which explore all possible reductions from a given state. Note that these are chosen non-deterministically from a set of equivalent reduce actions: you must not rely on always seeing the same reduce actions. For example if a state has these three items:

[E -> a ., $] [E -> b ., $] [F -> c ., $]

then the core reduces will be:

One of: [E -> a., $] or [E -> b., $] And: [F -> c., $]

since the two [E -> …] items both have the same effects on a parse stack.

source

pub fn goto( &self, stidx: StIdx<StorageT>, ridx: RIdx<StorageT> ) -> Option<StIdx<StorageT>>

Return the goto state for stidx and ridx, or None if there isn’t any.

source

pub fn start_state(&self) -> StIdx<StorageT>

Return this state table’s start state.

source

pub fn conflicts(&self) -> Option<&Conflicts<StorageT>>

Return a struct containing all conflicts or None if there aren’t any.

Trait Implementations§

source§

impl<'de, StorageT> Deserialize<'de> for StateTable<StorageT>
where StorageT: Deserialize<'de>,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<StorageT> Serialize for StateTable<StorageT>
where StorageT: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<StorageT> Freeze for StateTable<StorageT>
where StorageT: Freeze,

§

impl<StorageT> RefUnwindSafe for StateTable<StorageT>
where StorageT: RefUnwindSafe,

§

impl<StorageT> Send for StateTable<StorageT>
where StorageT: Send,

§

impl<StorageT> Sync for StateTable<StorageT>
where StorageT: Sync,

§

impl<StorageT> Unpin for StateTable<StorageT>
where StorageT: Unpin,

§

impl<StorageT> UnwindSafe for StateTable<StorageT>
where StorageT: UnwindSafe,

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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,