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.
Trait Implementations§
Source§impl<'de, StorageT, __WincodeConfig: Config> SchemaRead<'de, __WincodeConfig> for StateTable<StorageT>where
StorageT: SchemaRead<'de, __WincodeConfig, Dst = StorageT>,
impl<'de, StorageT, __WincodeConfig: Config> SchemaRead<'de, __WincodeConfig> for StateTable<StorageT>where
StorageT: SchemaRead<'de, __WincodeConfig, Dst = StorageT>,
type Dst = StateTable<StorageT>
Source§fn read(
reader: impl Reader<'de>,
dst: &mut MaybeUninit<Self::Dst>,
) -> ReadResult<()>
fn read( reader: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> ReadResult<()>
Source§impl<StorageT, __WincodeConfig: Config> SchemaWrite<__WincodeConfig> for StateTable<StorageT>where
StorageT: SchemaWrite<__WincodeConfig, Src = StorageT>,
impl<StorageT, __WincodeConfig: Config> SchemaWrite<__WincodeConfig> for StateTable<StorageT>where
StorageT: SchemaWrite<__WincodeConfig, Src = StorageT>,
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> UnsafeUnpin for StateTable<StorageT>where
StorageT: UnsafeUnpin,
impl<StorageT> UnwindSafe for StateTable<StorageT>where
StorageT: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<'de, T> Deserialize<'de> for Twhere
T: SchemaRead<'de, Configuration>,
impl<'de, T> Deserialize<'de> for Twhere
T: SchemaRead<'de, Configuration>,
§fn deserialize(src: &'de [u8]) -> Result<Self::Dst, ReadError>
fn deserialize(src: &'de [u8]) -> Result<Self::Dst, ReadError>
src bytes into a new Self::Dst.§fn deserialize_into(
src: &'de [u8],
dst: &mut MaybeUninit<Self::Dst>,
) -> Result<(), ReadError>
fn deserialize_into( src: &'de [u8], dst: &mut MaybeUninit<Self::Dst>, ) -> Result<(), ReadError>
src bytes into dst.§impl<'de, T, C> Deserialize<'de, C> for Twhere
C: Config,
T: SchemaRead<'de, C>,
impl<'de, T, C> Deserialize<'de, C> for Twhere
C: Config,
T: SchemaRead<'de, C>,
§fn deserialize(src: &'de [u8], config: C) -> Result<Self::Dst, ReadError>
fn deserialize(src: &'de [u8], config: C) -> Result<Self::Dst, ReadError>
Self::Dst.§fn deserialize_into(
src: &'de [u8],
dst: &mut MaybeUninit<Self::Dst>,
config: C,
) -> Result<(), ReadError>
fn deserialize_into( src: &'de [u8], dst: &mut MaybeUninit<Self::Dst>, config: C, ) -> Result<(), ReadError>
dst.§impl<T, C> DeserializeOwned<C> for Twhere
C: Config,
T: SchemaReadOwned<C>,
impl<T, C> DeserializeOwned<C> for Twhere
C: Config,
T: SchemaReadOwned<C>,
§fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
Reader] into a new Self::Dst.§fn deserialize_from_into<'de>(
src: impl Reader<'de>,
dst: &mut MaybeUninit<Self::Dst>,
) -> Result<(), ReadError>
fn deserialize_from_into<'de>( src: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> Result<(), ReadError>
Reader] into dst.§impl<T> DeserializeOwned for Twhere
T: SchemaReadOwned<Configuration>,
impl<T> DeserializeOwned for Twhere
T: SchemaReadOwned<Configuration>,
§fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
Reader] into a new Self::Dst.§fn deserialize_from_into<'de>(
src: impl Reader<'de>,
dst: &mut MaybeUninit<Self::Dst>,
) -> Result<(), ReadError>
fn deserialize_from_into<'de>( src: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> Result<(), ReadError>
Reader] into dst.§impl<T, C> Serialize<C> for Twhere
C: Config,
T: SchemaWrite<C> + ?Sized,
impl<T, C> Serialize<C> for Twhere
C: Config,
T: SchemaWrite<C> + ?Sized,
§fn serialize(src: &Self::Src, config: C) -> Result<Vec<u8>, WriteError>
fn serialize(src: &Self::Src, config: C) -> Result<Vec<u8>, WriteError>
Vec of bytes.§fn serialize_into(
dst: impl Writer,
src: &Self::Src,
config: C,
) -> Result<(), WriteError>
fn serialize_into( dst: impl Writer, src: &Self::Src, config: C, ) -> Result<(), WriteError>
Writer].§fn serialized_size(src: &Self::Src, config: C) -> Result<u64, WriteError>
fn serialized_size(src: &Self::Src, config: C) -> Result<u64, WriteError>
§impl<T> Serialize for Twhere
T: SchemaWrite<Configuration> + ?Sized,
impl<T> Serialize for Twhere
T: SchemaWrite<Configuration> + ?Sized,
§fn serialize(src: &Self::Src) -> Result<Vec<u8>, WriteError>
fn serialize(src: &Self::Src) -> Result<Vec<u8>, WriteError>
Vec of bytes.