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>,
impl<StorageT: 'static + Hash + PrimInt + Unsigned> StateTable<StorageT>where
usize: AsPrimitive<StorageT>,
pub fn new( grm: &YaccGrammar<StorageT>, sg: &StateGraph<StorageT>, ) -> Result<Self, StateTableError<StorageT>>
sourcepub fn action(
&self,
stidx: StIdx<StorageT>,
tidx: TIdx<StorageT>,
) -> Action<StorageT>
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.
sourcepub fn state_actions(
&self,
stidx: StIdx<StorageT>,
) -> StateActionsIterator<'_, StorageT> ⓘ
pub fn state_actions( &self, stidx: StIdx<StorageT>, ) -> StateActionsIterator<'_, StorageT> ⓘ
Return an iterator over the indexes of all non-empty actions of stidx
.
sourcepub fn state_shifts(
&self,
stidx: StIdx<StorageT>,
) -> StateActionsIterator<'_, StorageT> ⓘ
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
.
sourcepub fn reduce_only_state(&self, stidx: StIdx<StorageT>) -> bool
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?
sourcepub fn core_reduces(
&self,
stidx: StIdx<StorageT>,
) -> CoreReducesIterator<'_, StorageT> ⓘ
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.
sourcepub fn goto(
&self,
stidx: StIdx<StorageT>,
ridx: RIdx<StorageT>,
) -> Option<StIdx<StorageT>>
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.
sourcepub fn start_state(&self) -> StIdx<StorageT>
pub fn start_state(&self) -> StIdx<StorageT>
Return this state table’s start state.