pub trait Parse {
    // Required method
    fn parse(lexer: &mut LexerBridge<'_>) -> ParseResult<Self>
       where Self: Sized;

    // Provided methods
    fn parse_sep(
        lexer: &mut LexerBridge<'_>,
        join: Tokens
    ) -> ParseResult<Vec<Self>>
       where Self: Sized { ... }
    fn parse_sep_end(
        lexer: &mut LexerBridge<'_>,
        join: Tokens,
        end: Tokens
    ) -> ParseResult<Vec<Self>>
       where Self: Sized { ... }
}
Expand description

The main trait for parsing.

Any node that can be parsed must implement this trait.

Required Methods§

source

fn parse(lexer: &mut LexerBridge<'_>) -> ParseResult<Self>
where Self: Sized,

Given a lexer, try to parse a valid instance of this node.

§Errors

Should return a WagParseError if the parsing fails.

Provided Methods§

source

fn parse_sep( lexer: &mut LexerBridge<'_>, join: Tokens ) -> ParseResult<Vec<Self>>
where Self: Sized,

Parse multiple instances of this node, separated by a Tokens.

§Errors

Should return a WagParseError if the parsing fails.

source

fn parse_sep_end( lexer: &mut LexerBridge<'_>, join: Tokens, end: Tokens ) -> ParseResult<Vec<Self>>
where Self: Sized,

Parse multiple instances of this node, separated by a Tokens end ended by a (possibly different) Tokens.

§Errors

Should return a WagParseError if the parsing fails.

Implementations on Foreign Types§

source§

impl Parse for Ident

source§

fn parse(lexer: &mut LexerBridge<'_>) -> ParseResult<Self>

source§

impl Parse for String

source§

fn parse(lexer: &mut LexerBridge<'_>) -> ParseResult<Self>

Implementors§