pub struct ParserGen { /* private fields */ }Implementations§
Source§impl ParserGen
impl ParserGen
Sourcepub fn build_from_tree(tree: RuleTreeSet<General>, name: String) -> Self
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.
Sourcepub fn build_from_rules<T>(rules: ProdRuleSet<T>, name: String) -> Self
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
pub fn set_name(&mut self, name: String)
pub fn get_name(&self) -> &str
pub fn get_symbol_table(&self) -> Option<&SymbolTable>
pub fn get_parsing_table(&self) -> &LLParsingTable
pub fn add_header<T: Into<String>>(&mut self, header: T)
pub fn extend_headers<I: IntoIterator<Item = T>, T: Into<String>>( &mut self, headers: I, )
pub fn add_lib<T: Into<String>>(&mut self, lib: T)
pub fn extend_libs<I: IntoIterator<Item = T>, T: Into<String>>( &mut self, libs: I, )
Sourcepub fn add_nt_type<T: Into<String>>(&mut self, org_var: VarId, var_type: T)
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.
pub fn get_nt_type(&self, v: VarId) -> &str
pub fn set_nt_has_value(&mut self, v: VarId, has_value: bool)
pub fn set_parents_have_value(&mut self)
Sourcepub fn set_gen_span_params(&mut self, gen_span_params: bool)
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.
pub fn get_nt_parent(&self, v: VarId) -> Option<VarId>
Sourcepub fn set_include_alts(&mut self, include_alts: bool)
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.
pub fn use_full_lib(&mut self, use_full_lib: bool)
pub fn set_crate(&mut self, lcrate: LexigramCrate)
pub fn gen_source_code(&mut self, indent: usize, wrapper: bool) -> String
pub fn try_gen_source_code( self, indent: usize, wrapper: bool, ) -> Result<(BufLog, String), BuildError>
Trait Implementations§
Source§impl BuildFrom<ParserGen> for ParserTables
impl BuildFrom<ParserGen> for ParserTables
Source§fn build_from(parser_gen: ParserGen) -> Self
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
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 HasBuildErrorSource for ParserGen
impl HasBuildErrorSource for ParserGen
const SOURCE: BuildErrorSource = BuildErrorSource::ParserGen
fn get_build_error_source() -> BuildErrorSource
Source§impl TryBuildFrom<ParserGen> for ParserTables
impl TryBuildFrom<ParserGen> for ParserTables
Source§type Error = BuildError
type Error = BuildError
Auto Trait Implementations§
impl Freeze for ParserGen
impl !RefUnwindSafe for ParserGen
impl Send for ParserGen
impl !Sync for ParserGen
impl Unpin for ParserGen
impl UnwindSafe for ParserGen
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].