pub struct FirstFollowSets<'a> {
pub grammar: &'a ContextFreeGrammar,
pub first: Vec<HashSet<Option<usize>>>,
pub follow: Vec<HashSet<Option<usize>>>,
}Expand description
Computes FIRST and FOLLOW sets for a context-free grammar.
Fields§
§grammar: &'a ContextFreeGrammarThe grammar.
first: Vec<HashSet<Option<usize>>>FIRST sets: nonterminal index → set of (Option<terminal_index>) None represents ε.
follow: Vec<HashSet<Option<usize>>>FOLLOW sets: nonterminal index → set of (Option<terminal_index>) None represents end-of-input ($).
Implementations§
Source§impl<'a> FirstFollowSets<'a>
impl<'a> FirstFollowSets<'a>
Sourcepub fn compute(grammar: &'a ContextFreeGrammar) -> Self
pub fn compute(grammar: &'a ContextFreeGrammar) -> Self
Compute FIRST and FOLLOW sets for the grammar.
Sourcepub fn get_follow(&self, nt: usize) -> &HashSet<Option<usize>>
pub fn get_follow(&self, nt: usize) -> &HashSet<Option<usize>>
Get FOLLOW set for a nonterminal.
Sourcepub fn is_nullable(&self, nt: usize) -> bool
pub fn is_nullable(&self, nt: usize) -> bool
Check if a nonterminal is nullable (ε ∈ FIRST(nt)).
Auto Trait Implementations§
impl<'a> Freeze for FirstFollowSets<'a>
impl<'a> RefUnwindSafe for FirstFollowSets<'a>
impl<'a> Send for FirstFollowSets<'a>
impl<'a> Sync for FirstFollowSets<'a>
impl<'a> Unpin for FirstFollowSets<'a>
impl<'a> UnsafeUnpin for FirstFollowSets<'a>
impl<'a> UnwindSafe for FirstFollowSets<'a>
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
Mutably borrows from an owned value. Read more