ProdRuleSet

Struct ProdRuleSet 

Source
pub struct ProdRuleSet<T> { /* private fields */ }

Implementations§

Source§

impl<T> ProdRuleSet<T>

Source

pub fn get_start(&self) -> Option<VarId>

Returns the starting production rule.

Source

pub fn set_start(&mut self, start: VarId)

Sets the starting production rule.

Source

pub fn get_name(&self) -> Option<&String>

Source

pub fn set_name(&mut self, name: Option<String>)

Source

pub fn get_next_available_var(&self) -> VarId

Returns a variable ID that doesn’t exist yet.

Source

pub fn get_prules_iter(&self) -> impl Iterator<Item = (VarId, &ProdRule)>

Returns all the non-empty prules

Source

pub fn get_prules_iter_mut( &mut self, ) -> impl Iterator<Item = (VarId, &mut ProdRule)>

Source

pub fn get_alts(&self) -> impl Iterator<Item = (VarId, &Alternative)>

Source

pub fn set_symbol_table(&mut self, symbol_table: SymbolTable)

Source

pub fn get_symbol_table(&self) -> Option<&SymbolTable>

Source

pub fn get_num_nt(&self) -> usize

Source

pub fn get_num_t(&self) -> usize

Source

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.

Source

pub fn get_flags(&self, nt: VarId) -> u32

Source

pub fn calc_first(&mut self) -> HashMap<Symbol, HashSet<Symbol>>

Source

pub fn calc_follow( &self, first: &HashMap<Symbol, HashSet<Symbol>>, ) -> HashMap<Symbol, HashSet<Symbol>>

Source

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
Source

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>

Source

pub fn make_parsing_table(&mut self, error_recovery: bool) -> LLParsingTable

Source

pub fn gen_tables_source_code(&self, indent: usize) -> String

Source§

impl<T> ProdRuleSet<T>

Source

pub fn print_rules(&self, as_comment: bool, filter_empty_nt: bool)

Source

pub fn print_alts(&self)

Trait Implementations§

Source§

impl BuildFrom<ProdRuleSet<General>> for ProdRuleSet<LL1>

Source§

fn build_from(rules: ProdRuleSet<General>) -> Self

Converts to this type from the input type.
Source§

impl BuildFrom<ProdRuleSet<General>> for ProdRuleSet<LR>

Source§

fn build_from(rules: ProdRuleSet<General>) -> Self

Converts to this type from the input type.
Source§

impl<T> BuildFrom<ProdRuleSet<T>> for ParserGen

Source§

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>

Source§

fn build_from(source: ProdRuleSetTables) -> Self

Converts to this type from the input type.
Source§

impl BuildFrom<RuleTreeSet<General>> for ProdRuleSet<General>

Source§

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>

Source§

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>

Source§

fn clone(&self) -> ProdRuleSet<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for ProdRuleSet<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> HasBuildErrorSource for ProdRuleSet<T>

Source§

impl<T> LogReader for ProdRuleSet<T>

Source§

type Item = BufLog

Source§

fn get_log(&self) -> &Self::Item

Source§

fn give_log(self) -> Self::Item

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> 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<S> BuildFrom<S> for S

Source§

fn build_from(source: S) -> S

Converts to this type from the input type.
Source§

impl<S, T> BuildInto<T> for S
where T: BuildFrom<S>,

Source§

fn build_into(self) -> T

Calls T::from(self) to convert a [S] into a [T].

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> LogStatus for T
where T: LogReader + Debug,

Source§

fn num_notes(&self) -> usize

Source§

fn num_warnings(&self) -> usize

Source§

fn num_errors(&self) -> usize

Source§

fn has_no_errors(&self) -> bool

Source§

fn has_no_warnings(&self) -> bool

Source§

fn get_messages(&self) -> impl Iterator<Item = &LogMsg>

Source§

fn get_messages_str(&self) -> String

Source§

fn get_notes(&self) -> impl Iterator<Item = &String>

Source§

fn get_warnings(&self) -> impl Iterator<Item = &String>

Source§

fn get_errors(&self) -> impl Iterator<Item = &String>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<S, T> TryBuildFrom<S> for T

Source§

type Error = BuildError

The type returned in the event of a conversion error.
Source§

fn try_build_from(source: S) -> Result<T, <T as TryBuildFrom<S>>::Error>

Performs the conversion.
Source§

impl<S, T> TryBuildInto<T> for S
where T: TryBuildFrom<S>,

Source§

type Error = <T as TryBuildFrom<S>>::Error

The type returned in the event of a conversion error.
Source§

fn try_build_into(self) -> Result<T, <T as TryBuildFrom<S>>::Error>

Performs the conversion.
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.