Trait bend::fun::parser::ParserCommons
source · pub trait ParserCommons<'a>: Parser<'a> {
Show 23 methods
// Provided methods
fn labelled<T>(
&mut self,
parser: impl Fn(&mut Self) -> ParseResult<T>,
label: &str
) -> ParseResult<T> { ... }
fn parse_top_level_name(&mut self) -> ParseResult<Name> { ... }
fn parse_bend_name(&mut self) -> ParseResult<Name> { ... }
fn parse_exactly_name(&mut self) -> ParseResult<String> { ... }
fn consume_exactly(&mut self, text: &str) -> ParseResult<()> { ... }
fn consume_new_line(&mut self) -> ParseResult<()> { ... }
fn advance_newlines(&mut self) -> Indent { ... }
fn advance_trivia_inline(&mut self) -> isize { ... }
fn skip_trivia_inline(&mut self) { ... }
fn skip_trivia_maybe_inline(&mut self, inline: bool) { ... }
fn expected_spanned<T>(
&mut self,
exp: &str,
ini_idx: usize,
end_idx: usize
) -> ParseResult<T> { ... }
fn with_ctx<T>(
&mut self,
res: Result<T, impl Display>,
ini_idx: usize,
end_idx: usize
) -> ParseResult<T> { ... }
fn try_consume(&mut self, text: &str) -> bool { ... }
fn try_consume_exactly(&mut self, text: &str) -> bool { ... }
fn try_parse_keyword(&mut self, keyword: &str) -> bool { ... }
fn parse_keyword(&mut self, keyword: &str) -> ParseResult<()> { ... }
fn list_like<T>(
&mut self,
parser: impl Fn(&mut Self) -> ParseResult<T>,
start: &str,
end: &str,
sep: &str,
hard_sep: bool,
min_els: usize
) -> ParseResult<Vec<T>> { ... }
fn parse_oper(&mut self) -> ParseResult<Op> { ... }
fn peek_oper(&mut self) -> Option<Op> { ... }
fn parse_u32(&mut self) -> ParseResult<u32> { ... }
fn parse_number(&mut self) -> ParseResult<Num> { ... }
fn num_range_err<T>(&mut self, ini_idx: usize, typ: &str) -> ParseResult<T> { ... }
fn parse_quoted_symbol(&mut self) -> ParseResult<u32> { ... }
}
Provided Methods§
fn labelled<T>( &mut self, parser: impl Fn(&mut Self) -> ParseResult<T>, label: &str ) -> ParseResult<T>
fn parse_top_level_name(&mut self) -> ParseResult<Name>
fn parse_bend_name(&mut self) -> ParseResult<Name>
fn parse_exactly_name(&mut self) -> ParseResult<String>
sourcefn consume_exactly(&mut self, text: &str) -> ParseResult<()>
fn consume_exactly(&mut self, text: &str) -> ParseResult<()>
Consumes exactly the text without skipping.
fn consume_new_line(&mut self) -> ParseResult<()>
sourcefn advance_newlines(&mut self) -> Indent
fn advance_newlines(&mut self) -> Indent
Skips trivia, returns the number of trivia characters skipped in the last line.
sourcefn advance_trivia_inline(&mut self) -> isize
fn advance_trivia_inline(&mut self) -> isize
Advances the parser to the next non-trivia character in the same line. Returns how many characters were advanced.
sourcefn skip_trivia_inline(&mut self)
fn skip_trivia_inline(&mut self)
Skips until the next non-trivia character in the same line.
fn skip_trivia_maybe_inline(&mut self, inline: bool)
fn expected_spanned<T>( &mut self, exp: &str, ini_idx: usize, end_idx: usize ) -> ParseResult<T>
fn with_ctx<T>( &mut self, res: Result<T, impl Display>, ini_idx: usize, end_idx: usize ) -> ParseResult<T>
sourcefn try_consume(&mut self, text: &str) -> bool
fn try_consume(&mut self, text: &str) -> bool
Consumes text if the input starts with it or trivia. Otherwise, do nothing.
sourcefn try_consume_exactly(&mut self, text: &str) -> bool
fn try_consume_exactly(&mut self, text: &str) -> bool
Consumes text if the input starts exactly with it. Otherwise, do nothing.
fn try_parse_keyword(&mut self, keyword: &str) -> bool
fn parse_keyword(&mut self, keyword: &str) -> ParseResult<()>
sourcefn list_like<T>(
&mut self,
parser: impl Fn(&mut Self) -> ParseResult<T>,
start: &str,
end: &str,
sep: &str,
hard_sep: bool,
min_els: usize
) -> ParseResult<Vec<T>>
fn list_like<T>( &mut self, parser: impl Fn(&mut Self) -> ParseResult<T>, start: &str, end: &str, sep: &str, hard_sep: bool, min_els: usize ) -> ParseResult<Vec<T>>
Parses a list-like structure like “[x1, x2, x3,]”. Since a list is always well terminated, we consume newlines.
parser
is a function that parses an element of the list.
If hard_sep
the separator between elements is mandatory.
Always accepts trailing separators.
min_els
determines how many elements must be parsed at minimum.
fn parse_oper(&mut self) -> ParseResult<Op>
fn peek_oper(&mut self) -> Option<Op>
fn parse_u32(&mut self) -> ParseResult<u32>
fn parse_number(&mut self) -> ParseResult<Num>
fn num_range_err<T>(&mut self, ini_idx: usize, typ: &str) -> ParseResult<T>
sourcefn parse_quoted_symbol(&mut self) -> ParseResult<u32>
fn parse_quoted_symbol(&mut self) -> ParseResult<u32>
Parses up to 4 base64 characters surrounded by “`”. Joins the characters into a u24 and returns it.