ParserCommons

Trait ParserCommons 

Source
pub trait ParserCommons<'a>: Parser<'a> {
Show 33 methods // Provided methods fn labelled<T>( &mut self, parser: impl Fn(&mut Self) -> ParseResult<T>, label: &str, ) -> ParseResult<T> { ... } fn parse_restricted_name(&mut self, kind: &str) -> ParseResult<Name> { ... } fn parse_top_level_name(&mut self) -> ParseResult<Name> { ... } fn parse_var_name(&mut self) -> ParseResult<Name> { ... } fn parse_name_maybe_alias( &mut self, label: &str, ) -> ParseResult<(Name, Option<Name>)> { ... } fn parse_import_name( &mut self, label: &str, ) -> ParseResult<(Name, Option<Name>, bool)> { ... } fn consume_exactly(&mut self, text: &str) -> ParseResult<()> { ... } fn consume_new_line(&mut self) -> ParseResult<()> { ... } fn advance_newlines(&mut self) -> ParseResult<Indent> { ... } fn advance_trivia_inline(&mut self) -> ParseResult<isize> { ... } fn skip_trivia_inline(&mut self) -> ParseResult<()> { ... } fn expected_spanned<T>( &mut self, exp: &str, span: Range<usize>, ) -> ParseResult<T> { ... } fn expected_spanned_and<T>( &mut self, exp: &str, msg: &str, span: Range<usize>, ) -> ParseResult<T> { ... } fn err_msg_spanned<T>( &mut self, msg: &str, span: Range<usize>, ) -> ParseResult<T> { ... } fn with_ctx<T>( &mut self, res: Result<T, impl Display>, span: Range<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 starts_with_keyword(&mut self, keyword: &str) -> bool { ... } fn list_like<T>( &mut self, parser: impl FnMut(&mut Self) -> ParseResult<T>, start: &str, end: &str, sep: &str, hard_sep: bool, min_els: usize, ) -> ParseResult<Vec<T>> { ... } fn try_parse_oper(&mut self) -> Option<Op> { ... } fn peek_oper(&mut self) -> Option<Op> { ... } fn parse_u32(&mut self) -> ParseResult<u32> { ... } fn u32_with_radix(&mut self, radix: Radix) -> 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> { ... } fn check_repeated_ctr_fields( &mut self, fields: &[CtrField], ctr_name: &Name, span: Range<usize>, ) -> ParseResult<()> { ... } fn redefinition_of_function_msg( builtin: bool, function_name: &str, ) -> String { ... } fn redefinition_of_hvm_msg(builtin: bool, function_name: &str) -> String { ... } fn redefinition_of_constructor_msg(constructor_name: &str) -> String { ... } fn redefinition_of_type_msg(type_name: &str) -> String { ... }
}

Provided Methods§

Source

fn labelled<T>( &mut self, parser: impl Fn(&mut Self) -> ParseResult<T>, label: &str, ) -> ParseResult<T>

Source

fn parse_restricted_name(&mut self, kind: &str) -> ParseResult<Name>

Source

fn parse_top_level_name(&mut self) -> ParseResult<Name>

Source

fn parse_var_name(&mut self) -> ParseResult<Name>

Source

fn parse_name_maybe_alias( &mut self, label: &str, ) -> ParseResult<(Name, Option<Name>)>

Source

fn parse_import_name( &mut self, label: &str, ) -> ParseResult<(Name, Option<Name>, bool)>

Source

fn consume_exactly(&mut self, text: &str) -> ParseResult<()>

Consumes exactly the text without skipping.

Source

fn consume_new_line(&mut self) -> ParseResult<()>

Source

fn advance_newlines(&mut self) -> ParseResult<Indent>

Skips trivia, returns the number of trivia characters skipped in the last line.

Source

fn advance_trivia_inline(&mut self) -> ParseResult<isize>

Advances the parser to the next non-trivia character in the same line. Returns how many characters were advanced.

Source

fn skip_trivia_inline(&mut self) -> ParseResult<()>

Skips until the next non-trivia character in the same line.

Source

fn expected_spanned<T>( &mut self, exp: &str, span: Range<usize>, ) -> ParseResult<T>

Source

fn expected_spanned_and<T>( &mut self, exp: &str, msg: &str, span: Range<usize>, ) -> ParseResult<T>

Same as expected_spanned but adds an information message before the expected message.

Source

fn err_msg_spanned<T>( &mut self, msg: &str, span: Range<usize>, ) -> ParseResult<T>

If the parser result is an error, adds code location information to the error message.

Source

fn with_ctx<T>( &mut self, res: Result<T, impl Display>, span: Range<usize>, ) -> ParseResult<T>

If the parser result is an error, adds highlighted code context to the message.

Source

fn try_consume(&mut self, text: &str) -> bool

Consumes text if the input starts with it or trivia. Otherwise, do nothing.

Source

fn try_consume_exactly(&mut self, text: &str) -> bool

Consumes text if the input starts exactly with it. Otherwise, do nothing.

Source

fn try_parse_keyword(&mut self, keyword: &str) -> bool

Source

fn parse_keyword(&mut self, keyword: &str) -> ParseResult<()>

Source

fn starts_with_keyword(&mut self, keyword: &str) -> bool

Source

fn list_like<T>( &mut self, parser: impl FnMut(&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.

Source

fn try_parse_oper(&mut self) -> Option<Op>

Source

fn peek_oper(&mut self) -> Option<Op>

Source

fn parse_u32(&mut self) -> ParseResult<u32>

Source

fn u32_with_radix(&mut self, radix: Radix) -> ParseResult<u32>

Source

fn parse_number(&mut self) -> ParseResult<Num>

Source

fn num_range_err<T>(&mut self, ini_idx: usize, typ: &str) -> ParseResult<T>

Source

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.

Source

fn check_repeated_ctr_fields( &mut self, fields: &[CtrField], ctr_name: &Name, span: Range<usize>, ) -> ParseResult<()>

Source

fn redefinition_of_function_msg(builtin: bool, function_name: &str) -> String

Source

fn redefinition_of_hvm_msg(builtin: bool, function_name: &str) -> String

Source

fn redefinition_of_constructor_msg(constructor_name: &str) -> String

Source

fn redefinition_of_type_msg(type_name: &str) -> String

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a> ParserCommons<'a> for ImpParser<'a>

Source§

impl<'a> ParserCommons<'a> for FunParser<'a>