Struct cfg::prediction::FirstSetsCollector
source · pub struct FirstSetsCollector<'a, G> { /* private fields */ }
Expand description
Collector of FIRST sets.
Implementations§
source§impl<'a, G> FirstSetsCollector<'a, G>where
G: RuleContainer + Default,
&'a G: RuleContainerRef<'a, Target = G>,
impl<'a, G> FirstSetsCollector<'a, G>where G: RuleContainer + Default, &'a G: RuleContainerRef<'a, Target = G>,
sourcepub fn new(grammar: &'a G) -> Self
pub fn new(grammar: &'a G) -> Self
Compute all FIRST sets of the grammar.
We define a binary relation FIRST(N, S), in which N is related to S
if the grammar has a production of the form N ⸬= α S β
, where
α is a nullable string of symbols.
We compute the transitive closure of this relation.
sourcepub fn first_set_for_string(
&self,
string: &[Symbol]
) -> BTreeSet<Option<Symbol>>
pub fn first_set_for_string( &self, string: &[Symbol] ) -> BTreeSet<Option<Symbol>>
Calculates a FIRST set for a string of symbols.
sourcepub fn first_sets(&self) -> &PerSymbolSets
pub fn first_sets(&self) -> &PerSymbolSets
Returns a FIRST sets structure.
Auto Trait Implementations§
impl<'a, G> RefUnwindSafe for FirstSetsCollector<'a, G>where G: RefUnwindSafe,
impl<'a, G> Send for FirstSetsCollector<'a, G>where G: Sync,
impl<'a, G> Sync for FirstSetsCollector<'a, G>where G: Sync,
impl<'a, G> Unpin for FirstSetsCollector<'a, G>
impl<'a, G> UnwindSafe for FirstSetsCollector<'a, G>where G: RefUnwindSafe,
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