Trait wagon_parser::parser::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§
sourcefn parse(lexer: &mut LexerBridge<'_>) -> ParseResult<Self>where
Self: Sized,
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§
sourcefn parse_sep(
lexer: &mut LexerBridge<'_>,
join: Tokens
) -> ParseResult<Vec<Self>>where
Self: Sized,
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.
sourcefn parse_sep_end(
lexer: &mut LexerBridge<'_>,
join: Tokens,
end: Tokens
) -> ParseResult<Vec<Self>>where
Self: Sized,
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.