Trait Parser

Source
pub trait Parser<'i, I, C, S, TK>
where I: Input + ?Sized, C: Context<'i, I, S, TK>, S: State,
{ type Output; // Required methods fn parse(&self, input: &'i I) -> Result<Self::Output>; fn parse_with_context( &self, context: &mut C, input: &'i I, ) -> Result<Self::Output>; fn parse_file<'a, F: AsRef<Path>>( &'a mut self, file: F, ) -> Result<Self::Output> where 'a: 'i; }
Expand description

The trait implemented by all Rustemo parsers.

Required Associated Types§

Required Methods§

Source

fn parse(&self, input: &'i I) -> Result<Self::Output>

Parse the given input and produce the result. The output type is set by the parser implementers and it is usually defined by the builder if the building is done during the parse process.

Source

fn parse_with_context( &self, context: &mut C, input: &'i I, ) -> Result<Self::Output>

Parse with the given context which has information about the current parsing state (e.g. position, location). Used in situation when we need to continue parsing from a specific state, like in parsing the layout from the current location.

Source

fn parse_file<'a, F: AsRef<Path>>(&'a mut self, file: F) -> Result<Self::Output>
where 'a: 'i,

A convenience method for loading the content from the given file and calling parse. The parser will own the content being parsed and thus has to outlive Self::Output if it borrows from the content loaded from the file.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'i, C, S, P, I, TK, NTK, D, L, B> Parser<'i, I, C, S, TK> for LRParser<'i, C, S, P, TK, NTK, D, L, B, I>
where C: Context<'i, I, S, TK>, S: State + Debug, P: Debug + Copy + Into<NTK>, I: Input + ?Sized + Debug + 'i, TK: Debug + Copy + Default + PartialEq + 'i, D: ParserDefinition<S, P, TK, NTK>, L: Lexer<'i, C, S, TK, Input = I>, B: LRBuilder<'i, I, C, S, P, TK>,

Source§

impl<'i, I, S, TK, NTK, L, P, D, B> Parser<'i, I, GssHead<'i, I, S, TK>, S, TK> for GlrParser<'i, S, L, P, TK, NTK, D, I, B>
where I: Input + ?Sized + Debug, L: Lexer<'i, GssHead<'i, I, S, TK>, S, TK, Input = I>, S: State + Debug + Ord, P: Copy + Debug + Into<NTK> + PartialEq, TK: Copy + Debug + Ord + Default + 'i, D: ParserDefinition<S, P, TK, NTK>,

Source§

type Output = Forest<'i, I, P, TK>