Skip to main content

StateTable

Struct StateTable 

Source
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, __WincodeConfig: Config> SchemaRead<'de, __WincodeConfig> for StateTable<StorageT>
where StorageT: SchemaRead<'de, __WincodeConfig, Dst = StorageT>,

Source§

const TYPE_META: TypeMeta

Metadata about the type’s serialization. Read more
Source§

type Dst = StateTable<StorageT>

Source§

fn read( reader: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> ReadResult<()>

Read into dst from reader. Read more
§

fn get(reader: impl Reader<'de>) -> Result<Self::Dst, ReadError>

Read Self::Dst from reader into a new Self::Dst.
Source§

impl<StorageT, __WincodeConfig: Config> SchemaWrite<__WincodeConfig> for StateTable<StorageT>
where StorageT: SchemaWrite<__WincodeConfig, Src = StorageT>,

Source§

const TYPE_META: TypeMeta

Metadata about the type’s serialization. Read more
Source§

type Src = StateTable<StorageT>

Source§

fn size_of(src: &Self::Src) -> WriteResult<usize>

Get the serialized size of Self::Src. Read more
Source§

fn write(writer: impl Writer, src: &Self::Src) -> WriteResult<()>

Write Self::Src to writer.

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

impl<'de, T> Deserialize<'de> for T
where T: SchemaRead<'de, Configuration>,

§

fn deserialize(src: &'de [u8]) -> Result<Self::Dst, ReadError>

Deserialize the input src bytes into a new Self::Dst.
§

fn deserialize_into( src: &'de [u8], dst: &mut MaybeUninit<Self::Dst>, ) -> Result<(), ReadError>

Deserialize the input src bytes into dst.
§

impl<'de, T, C> Deserialize<'de, C> for T
where C: Config, T: SchemaRead<'de, C>,

§

fn deserialize(src: &'de [u8], config: C) -> Result<Self::Dst, ReadError>

Deserialize the input bytes into a new Self::Dst.
§

fn deserialize_into( src: &'de [u8], dst: &mut MaybeUninit<Self::Dst>, config: C, ) -> Result<(), ReadError>

Deserialize the input bytes into dst.
§

impl<T, C> DeserializeOwned<C> for T
where C: Config, T: SchemaReadOwned<C>,

§

fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>

Deserialize from the given [Reader] into a new Self::Dst.
§

fn deserialize_from_into<'de>( src: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> Result<(), ReadError>

Deserialize from the given [Reader] into dst.
§

impl<T> DeserializeOwned for T
where T: SchemaReadOwned<Configuration>,

§

fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>

Deserialize from the given [Reader] into a new Self::Dst.
§

fn deserialize_from_into<'de>( src: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> Result<(), ReadError>

Deserialize from the given [Reader] into dst.
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.

§

impl<T, C> Serialize<C> for T
where C: Config, T: SchemaWrite<C> + ?Sized,

§

fn serialize(src: &Self::Src, config: C) -> Result<Vec<u8>, WriteError>

Serialize a serializable type into a Vec of bytes.
§

fn serialize_into( dst: impl Writer, src: &Self::Src, config: C, ) -> Result<(), WriteError>

Serialize a serializable type into the given [Writer].
§

fn serialized_size(src: &Self::Src, config: C) -> Result<u64, WriteError>

Get the size in bytes of the type when serialized.
§

impl<T> Serialize for T
where T: SchemaWrite<Configuration> + ?Sized,

§

fn serialize(src: &Self::Src) -> Result<Vec<u8>, WriteError>

Serialize a serializable type into a Vec of bytes.
§

fn serialize_into(dst: impl Writer, src: &Self::Src) -> Result<(), WriteError>

Serialize a serializable type into the given byte buffer.
§

fn serialized_size(src: &Self::Src) -> Result<u64, WriteError>

Get the size in bytes of the type when serialized.
Source§

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

Source§

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

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

impl<T, C> SchemaReadOwned<C> for T
where C: ConfigCore, T: for<'de> SchemaRead<'de, C>,