pub struct ProdRuleSet<T> { /* private fields */ }Implementations§
Source§impl<T> ProdRuleSet<T>
impl<T> ProdRuleSet<T>
pub fn get_name(&self) -> Option<&String>
pub fn set_name(&mut self, name: Option<String>)
Sourcepub fn get_next_available_var(&self) -> VarId
pub fn get_next_available_var(&self) -> VarId
Returns a variable ID that doesn’t exist yet.
Sourcepub fn get_prules_iter(&self) -> impl Iterator<Item = (VarId, &ProdRule)>
pub fn get_prules_iter(&self) -> impl Iterator<Item = (VarId, &ProdRule)>
Returns all the non-empty prules
pub fn get_prules_iter_mut( &mut self, ) -> impl Iterator<Item = (VarId, &mut ProdRule)>
pub fn get_alts(&self) -> impl Iterator<Item = (VarId, &Alternative)>
pub fn set_symbol_table(&mut self, symbol_table: SymbolTable)
pub fn get_symbol_table(&self) -> Option<&SymbolTable>
pub fn get_num_nt(&self) -> usize
pub fn get_num_t(&self) -> usize
Sourcepub fn set_flags(&mut self, nt: VarId, new_flags: u32)
pub fn set_flags(&mut self, nt: VarId, new_flags: u32)
Adds new flags to flags[nt] by or’ing them.
If necessary, extends the flags array first.
pub fn get_flags(&self, nt: VarId) -> u32
pub fn calc_first(&mut self) -> HashMap<Symbol, HashSet<Symbol>>
pub fn calc_follow( &self, first: &HashMap<Symbol, HashSet<Symbol>>, ) -> HashMap<Symbol, HashSet<Symbol>>
Sourcepub fn left_factorize(&mut self)
pub fn left_factorize(&mut self)
Factorizes all the left symbols that are common to several alts by rejecting the non-common part to a new non-terminal. Updates the symbol table if provided.
After the factorization, every child has an NT index greater than its parent, even if the factorization is performed several times on the same rule.
Algorithm:
- for each NT
- sort alts
- repeat as long as there are common starting symbols:
- take first group of >1 alts starting with the same symbol
α[0] - extract the number of starting symbols common to all alts of the group (1 or more):
α - create a new NT with the group, where
αhas been removed at the beginning
- take first group of >1 alts starting with the same symbol
Sourcepub fn prs_alt_origins_str(&self, ansi: bool) -> Vec<String>
pub fn prs_alt_origins_str(&self, ansi: bool) -> Vec<String>
Generates a side-by-side comparison between the production rules and the original rule each alternative represents (or which part of that rule).
The output can be formatted with [indent_source].
Source§impl ProdRuleSet<LL1>
impl ProdRuleSet<LL1>
pub fn make_parsing_table(&mut self, error_recovery: bool) -> LLParsingTable
pub fn gen_tables_source_code(&self, indent: usize) -> String
Source§impl<T> ProdRuleSet<T>
impl<T> ProdRuleSet<T>
pub fn print_rules(&self, as_comment: bool, filter_empty_nt: bool)
pub fn print_alts(&self)
Trait Implementations§
Source§impl BuildFrom<ProdRuleSet<General>> for ProdRuleSet<LL1>
impl BuildFrom<ProdRuleSet<General>> for ProdRuleSet<LL1>
Source§fn build_from(rules: ProdRuleSet<General>) -> Self
fn build_from(rules: ProdRuleSet<General>) -> Self
Source§impl BuildFrom<ProdRuleSet<General>> for ProdRuleSet<LR>
impl BuildFrom<ProdRuleSet<General>> for ProdRuleSet<LR>
Source§fn build_from(rules: ProdRuleSet<General>) -> Self
fn build_from(rules: ProdRuleSet<General>) -> Self
Source§impl<T> BuildFrom<ProdRuleSet<T>> for ParserGen
impl<T> BuildFrom<ProdRuleSet<T>> for ParserGen
Source§fn build_from(rules: ProdRuleSet<T>) -> Self
fn build_from(rules: ProdRuleSet<T>) -> Self
Creates a ParserGen from a set of production rules.
If the rule set has a name, it’s transmitted to the parser generator to name the user
listener trait in the generated code. If the rule set has no name, a default “Parser” name
is used instead (unless the name is set with ParserGen::set_name().
Source§impl BuildFrom<ProdRuleSetTables> for ProdRuleSet<LL1>
impl BuildFrom<ProdRuleSetTables> for ProdRuleSet<LL1>
Source§fn build_from(source: ProdRuleSetTables) -> Self
fn build_from(source: ProdRuleSetTables) -> Self
Source§impl BuildFrom<RuleTreeSet<General>> for ProdRuleSet<General>
impl BuildFrom<RuleTreeSet<General>> for ProdRuleSet<General>
Source§fn build_from(rules: RuleTreeSet<General>) -> Self
fn build_from(rules: RuleTreeSet<General>) -> Self
Builds a ProdRuleSet<General> from a RuleTreeSet<General>.
If an error is encountered or was already encountered before, an empty shell object is built with the log detailing the error(s).
Source§impl BuildFrom<RuleTreeSet<Normalized>> for ProdRuleSet<General>
impl BuildFrom<RuleTreeSet<Normalized>> for ProdRuleSet<General>
Source§fn build_from(rules: RuleTreeSet<Normalized>) -> Self
fn build_from(rules: RuleTreeSet<Normalized>) -> Self
Builds a ProdRuleSet<General> from a RuleTreeSet<Normalized>.
If an error is encountered or was already encountered before, an empty shell object is built with the log detailing the error(s).
Source§impl<T: Clone> Clone for ProdRuleSet<T>
impl<T: Clone> Clone for ProdRuleSet<T>
Source§fn clone(&self) -> ProdRuleSet<T>
fn clone(&self) -> ProdRuleSet<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T: Debug> Debug for ProdRuleSet<T>
impl<T: Debug> Debug for ProdRuleSet<T>
Source§impl<T> HasBuildErrorSource for ProdRuleSet<T>
impl<T> HasBuildErrorSource for ProdRuleSet<T>
const SOURCE: BuildErrorSource = BuildErrorSource::ProdRuleSet
fn get_build_error_source() -> BuildErrorSource
Auto Trait Implementations§
impl<T> Freeze for ProdRuleSet<T>
impl<T> !RefUnwindSafe for ProdRuleSet<T>
impl<T> Send for ProdRuleSet<T>where
T: Send,
impl<T> !Sync for ProdRuleSet<T>
impl<T> Unpin for ProdRuleSet<T>where
T: Unpin,
impl<T> UnwindSafe for ProdRuleSet<T>where
T: UnwindSafe,
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
Source§impl<S> BuildFrom<S> for S
impl<S> BuildFrom<S> for S
Source§fn build_from(source: S) -> S
fn build_from(source: S) -> S
Source§impl<S, T> BuildInto<T> for Swhere
T: BuildFrom<S>,
impl<S, T> BuildInto<T> for Swhere
T: BuildFrom<S>,
Source§fn build_into(self) -> T
fn build_into(self) -> T
Calls T::from(self) to convert a [S] into a [T].