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>
impl<'g> GrammarAnalysis<'g>
Sourcepub fn build(grammar: &'g Grammar) -> GrammarAnalysis<'g>
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.
Sourcepub fn nullables(&self) -> HashSet<Symbol<'g>>
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.
Sourcepub fn is_nullable(&self, symbol: Symbol<'g>) -> bool
pub fn is_nullable(&self, symbol: Symbol<'g>) -> bool
Returns whether the given symbol is nullable.
pub fn first_seq(&self, seq: &[Symbol<'g>]) -> HashSet<Symbol<'g>>
pub fn is_nullable_seq(&self, seq: &[Symbol<'g>]) -> bool
Sourcepub fn first(&self, symbol: Symbol<'g>) -> HashSet<Symbol<'g>>
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.
Sourcepub fn follow(&self, symbol: Symbol<'g>) -> HashSet<Symbol<'g>>
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.