Trait Parse

Source
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§