Struct Parser

Source
pub struct Parser {
    pub rules: Vec<ProductionRule<&'static str, ChunkOrExpressionsNonTerminals>>,
    pub states: Vec<SparseState<ChunkOrExpressionsNonTerminals, SmallVecU8>>,
    pub classes: Vec<Vec<&'static str>>,
}
Expand description

A struct that holds the entire parser table and production rules.

Fields§

§rules: Vec<ProductionRule<&'static str, ChunkOrExpressionsNonTerminals>>

production rules

§states: Vec<SparseState<ChunkOrExpressionsNonTerminals, SmallVecU8>>

states

§classes: Vec<Vec<&'static str>>

terminal classes

Implementations§

Source§

impl ChunkOrExpressionsParser

A struct that holds the whole parser table.

Source

pub fn new() -> Self

Calculates the states and parser tables from the grammar.

Trait Implementations§

Source§

impl Parser for ChunkOrExpressionsParser

Source§

type Term = Token

The type of terminal symbols.
Source§

type NonTerm = ChunkOrExpressionsNonTerminals

The type of non-terminal symbols.
Source§

type State = SparseState<ChunkOrExpressionsNonTerminals, SmallVec<[u8; 16]>>

The type of the parser state.
Source§

type TerminalClassElement = &'static str

A type to represent single element in a terminal class. Read more
Source§

fn class_precedence(&self, class: TerminalSymbol<usize>) -> Option<usize>

Get the precedence level (priority) of the given terminal class None if the terminal class has no precedence defined.
Source§

fn precedence_types(&self, level: usize) -> Option<ReduceType>

Get the type of precedence for i’th level. None if i’th level was defined as %precedence (no reduce type).
Source§

fn get_rules( &self, ) -> &[ProductionRule<&'static str, ChunkOrExpressionsNonTerminals>]

Get list of production rules
Source§

fn get_states( &self, ) -> &[SparseState<ChunkOrExpressionsNonTerminals, SmallVecU8>]

Get list of states
Source§

fn get_terminals( &self, i: usize, ) -> Option<impl IntoIterator<Item = Self::TerminalClassElement> + '_>

Get set of terminals for i’th terminal class
Source§

fn to_terminal_class(&self, terminal: &Self::Term) -> usize

Get the terminal class of the given terminal
Source§

fn error_used() -> bool

whether the error token was used in the grammar.

Auto Trait Implementations§

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

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.