Trait menhir_runtime::EntryPoint [] [src]

pub trait EntryPoint<Parser: LRParser> {
    type Output;
    fn extract_output(
        stack: Stack<Parser::YYType, Parser::State>
    ) -> Self::Output;
fn initial() -> Parser::State; fn new<Lexer>() -> ParserState<Lexer, Parser, Self>
    where
        Lexer: Lexer,
        Lexer::Location: Clone,
        Lexer::Token: Into<(Parser::YYType, Parser::Terminal)>,
        Self: Sized
, { ... }
fn run<Lexer>(lex: Lexer) -> Result<Self::Output, Error<Lexer, Parser>>
    where
        Lexer: Lexer,
        Lexer::Token: Into<(Parser::YYType, Parser::Terminal)>,
        Lexer::Location: Clone,
        Parser: LRParser,
        Self: Sized
, { ... } }

The trait of the entry points of a grammar file.

This trait describes the main interface of a Menhir parser. Menhir will generate one type implementing this trait for each possible entry point of the grammar file.

Associated Types

The type of the semantic value produced by a successful parsing.

Required Methods

Extracts the semantic value produced by a succesful parsing from the resulting stack.

Calling this function on a stack which is not the result of a successful parse will most likely panic, but might also return an unspecified but valid value.

Returns the initial state of the parser automaton for this entry point.

Provided Methods

Creates a new parser for this entry point from the given lexer.

This function is similar to run but instead of running the parsing process, it does nothing and returns a ParserState instead that exposes the current state of the parser. However, the interface of ParserState should not be considered stable for the moment.

Runs the parsing process for this entry point from the given lexer.

This requires that the tokens returned by the lexer can be converted into the Terminal type of the parser, which is the internal representation of tokens. Menhir should have generated an implementation of Into for the good token type.

If a syntax error is encountered in the input stream, a Menhir parser will try to recover from it by applying the default strategy which consists in unwinding the stack until finding a state which accepts a shift or reduce action on the special error token. If the bottom of the stack is reached, a syntax error is returned. See the relevant section of the manual for more details.

This function will parse input until one of the following events: * The parser successfully recognized the start production, in which case it will return a value of Ok(v), where v is the semantic value. * The parser encountered an unrecoverable error, such as a lexer error or a syntax error which it failed to recover from, in which case it will return Err(e). See Error for more details.

Implementors