Struct GrammarAnalysis

Source
pub struct GrammarAnalysis<'g> { /* private fields */ }
Expand description

A structure for calculating the set of nullable nonterminals as well as the FIRST and FOLLOW sets for each nonterminal.

Implementations§

Source§

impl<'g> GrammarAnalysis<'g>

Source

pub fn build(grammar: &'g Grammar) -> GrammarAnalysis<'g>

The constructor for GrammarAnalysis. This builds the nullable set and the FIRST and FOLLOW sets for grammar.

Source

pub fn nullables(&self) -> HashSet<Symbol<'g>>

Returns the set of nullable symbols.

The result is a set of nonterminals. A Symbol is nullable if it can expand into an empty string of terminals through the application of some sequence of production rules.

Source

pub fn is_nullable(&self, symbol: Symbol<'g>) -> bool

Returns whether the given symbol is nullable.

Source

pub fn first_seq(&self, seq: &[Symbol<'g>]) -> HashSet<Symbol<'g>>

Source

pub fn is_nullable_seq(&self, seq: &[Symbol<'g>]) -> bool

Source

pub fn first(&self, symbol: Symbol<'g>) -> HashSet<Symbol<'g>>

Returns the FIRST set for a nonterminal Symbol.

The result is a set of terminals. A terminal is in the FIRST set of a nonterminal if some sequence of production rules starting with that nonterminal expands to a string of terminals starting with that terminal.

Source

pub fn follow(&self, symbol: Symbol<'g>) -> HashSet<Symbol<'g>>

Returns the FOLLOW set for a nonterminal Symbol.

The result is a set of terminals. A terminal is in the FOLLOW set of a nonterminal that terminal could legally follow the nonterminal during parsing.

Source

pub fn can_end_with(&self, start_symbol: Symbol<'g>, symbol: Symbol<'g>) -> bool

Auto Trait Implementations§

§

impl<'g> Freeze for GrammarAnalysis<'g>

§

impl<'g> RefUnwindSafe for GrammarAnalysis<'g>

§

impl<'g> Send for GrammarAnalysis<'g>

§

impl<'g> Sync for GrammarAnalysis<'g>

§

impl<'g> Unpin for GrammarAnalysis<'g>

§

impl<'g> UnwindSafe for GrammarAnalysis<'g>

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.