ParserGen

Struct ParserGen 

Source
pub struct ParserGen { /* private fields */ }

Implementations§

Source§

impl ParserGen

Source

pub fn build_from_tree(tree: RuleTreeSet<General>, name: String) -> Self

Creates a ParserGen from a set of rules and gives it a specific name, which is used to name the user listener trait in the generated code.

Source

pub fn build_from_rules<T>(rules: ProdRuleSet<T>, name: String) -> Self

Creates a ParserGen from a set of production rules and gives it a specific name, which is used to name the user listener trait in the generated code.

If [rules] already has a name, it is best to use the BuildFrom<ProdRuleSet> trait.

Source

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

Source

pub fn get_name(&self) -> &str

Source

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

Source

pub fn get_parsing_table(&self) -> &LLParsingTable

Source

pub fn add_header<T: Into<String>>(&mut self, header: T)

Source

pub fn extend_headers<I: IntoIterator<Item = T>, T: Into<String>>( &mut self, headers: I, )

Source

pub fn add_lib<T: Into<String>>(&mut self, lib: T)

Source

pub fn extend_libs<I: IntoIterator<Item = T>, T: Into<String>>( &mut self, libs: I, )

Source

pub fn add_nt_type<T: Into<String>>(&mut self, org_var: VarId, var_type: T)

Declares the type of a non-terminal. The index of the NT, org_var, is the original index in the ruletree set, which is the index originally assigned when parsing the grammar file.

Source

pub fn get_nt_type(&self, v: VarId) -> &str

Source

pub fn get_nt_extra_info(&self, nt: VarId) -> Option<&(String, Vec<String>)>

NT source type and source code including doc comment and empty template type definition.

§Example:
let (type_src, src) = parger_gen.get_nt_extra_info(var_id);
  • type_src = “SynHeader”
  • src =
    /// User-defined type for `header`
    #[derive(Debug, PartialEq)]
    pub struct SynHeader();
Source

pub fn set_nt_has_value(&mut self, v: VarId, has_value: bool)

Source

pub fn set_parents_have_value(&mut self)

Source

pub fn set_gen_span_params(&mut self, gen_span_params: bool)

Generates code to give the location of nonterminals and tokens as extra parameters of listener methods.

Source

pub fn get_nt_parent(&self, v: VarId) -> Option<VarId>

Source

pub fn set_include_alts(&mut self, include_alts: bool)

Include the definitions of the alternatives in the parser, for debugging purposes: allows to print out the alternatives in VERBOSE mode.

Source

pub fn use_full_lib(&mut self, use_full_lib: bool)

Source

pub fn set_crate(&mut self, lcrate: LexigramCrate)

Source

pub fn gen_source_code(&mut self, indent: usize, wrapper: bool) -> String

Source

pub fn try_gen_source_code( self, indent: usize, wrapper: bool, ) -> Result<(BufLog, String), BuildError>

Trait Implementations§

Source§

impl BuildFrom<ParserGen> for ParserTables

Source§

fn build_from(parser_gen: ParserGen) -> Self

Creates a ParserTables, from which a parser can be created dynamically with parser_table.make_parser().

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 Debug for ParserGen

Source§

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

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

impl HasBuildErrorSource for ParserGen

Source§

impl LogReader for ParserGen

Source§

type Item = BufLog

Source§

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

Source§

fn give_log(self) -> Self::Item

Source§

impl TryBuildFrom<ParserGen> for ParserTables

Source§

type Error = BuildError

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

fn try_build_from(source: ParserGen) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

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> 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<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.