Struct lrpar::RTParserBuilder
source · pub struct RTParserBuilder<'a, StorageT: 'static + Eq + Debug + Hash + PrimInt + Unsigned, LexerTypesT: LexerTypes<StorageT = StorageT>>where
usize: AsPrimitive<StorageT>,{ /* private fields */ }
Expand description
A run-time parser builder.
Implementations§
source§impl<'a, StorageT: 'static + Debug + Hash + PrimInt + Unsigned, LexerTypesT: LexerTypes<StorageT = StorageT>> RTParserBuilder<'a, StorageT, LexerTypesT>where
usize: AsPrimitive<StorageT>,
impl<'a, StorageT: 'static + Debug + Hash + PrimInt + Unsigned, LexerTypesT: LexerTypes<StorageT = StorageT>> RTParserBuilder<'a, StorageT, LexerTypesT>where
usize: AsPrimitive<StorageT>,
sourcepub fn new(
grm: &'a YaccGrammar<StorageT>,
stable: &'a StateTable<StorageT>,
) -> Self
pub fn new( grm: &'a YaccGrammar<StorageT>, stable: &'a StateTable<StorageT>, ) -> Self
Create a new run-time parser from a YaccGrammar
, and a StateTable
.
sourcepub fn recoverer(self, rk: RecoveryKind) -> Self
pub fn recoverer(self, rk: RecoveryKind) -> Self
Set the recoverer for this parser to rk
.
pub fn term_costs(self, f: &'a dyn Fn(TIdx<StorageT>) -> u8) -> Self
sourcepub fn parse_generictree(
&self,
lexer: &dyn NonStreamingLexer<'_, LexerTypesT>,
) -> (Option<Node<LexerTypesT::LexemeT, StorageT>>, Vec<LexParseError<StorageT, LexerTypesT>>)
pub fn parse_generictree( &self, lexer: &dyn NonStreamingLexer<'_, LexerTypesT>, ) -> (Option<Node<LexerTypesT::LexemeT, StorageT>>, Vec<LexParseError<StorageT, LexerTypesT>>)
Parse input, and (if possible) return a generic parse tree. See the arguments for
parse_actions
for more details about the return value.
sourcepub fn parse_noaction(
&self,
lexer: &dyn NonStreamingLexer<'_, LexerTypesT>,
) -> Vec<LexParseError<StorageT, LexerTypesT>>
pub fn parse_noaction( &self, lexer: &dyn NonStreamingLexer<'_, LexerTypesT>, ) -> Vec<LexParseError<StorageT, LexerTypesT>>
Parse input, returning any errors found. See the arguments for
parse_actions
for more details about the return value.
sourcepub fn parse_actions<'b: 'a, 'input: 'b, ActionT: 'a, ParamT: Clone>(
&self,
lexer: &'b dyn NonStreamingLexer<'input, LexerTypesT>,
actions: &'a [&'a dyn Fn(RIdx<StorageT>, &'b dyn NonStreamingLexer<'input, LexerTypesT>, Span, Drain<'_, AStackType<<LexerTypesT as LexerTypes>::LexemeT, ActionT>>, ParamT) -> ActionT],
param: ParamT,
) -> (Option<ActionT>, Vec<LexParseError<StorageT, LexerTypesT>>)
pub fn parse_actions<'b: 'a, 'input: 'b, ActionT: 'a, ParamT: Clone>( &self, lexer: &'b dyn NonStreamingLexer<'input, LexerTypesT>, actions: &'a [&'a dyn Fn(RIdx<StorageT>, &'b dyn NonStreamingLexer<'input, LexerTypesT>, Span, Drain<'_, AStackType<<LexerTypesT as LexerTypes>::LexemeT, ActionT>>, ParamT) -> ActionT], param: ParamT, ) -> (Option<ActionT>, Vec<LexParseError<StorageT, LexerTypesT>>)
Parse input, execute actions, and return the associated value (if possible) and/or any
lexing/parsing errors encountered. Note that the two parts of the (value, errors) return
pair are entirely independent: one can encounter errors without a value being produced
(None, [...]
), errors and a value (Some(...), [...]
), as well as a value and no errors
(Some(...), []
). Errors are sorted by the position they were found in the input and can
be a mix of lexing and parsing errors.