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§
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)>
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) -> ParseResult<Indent>
fn advance_newlines(&mut self) -> ParseResult<Indent>
Skips trivia, returns the number of trivia characters skipped in the last line.
Sourcefn advance_trivia_inline(&mut self) -> ParseResult<isize>
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.
Sourcefn skip_trivia_inline(&mut self) -> ParseResult<()>
fn skip_trivia_inline(&mut self) -> ParseResult<()>
Skips until the next non-trivia character in the same line.
fn expected_spanned<T>( &mut self, exp: &str, span: Range<usize>, ) -> ParseResult<T>
Sourcefn expected_spanned_and<T>(
&mut self,
exp: &str,
msg: &str,
span: Range<usize>,
) -> ParseResult<T>
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.
Sourcefn err_msg_spanned<T>(
&mut self,
msg: &str,
span: Range<usize>,
) -> ParseResult<T>
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.
Sourcefn with_ctx<T>(
&mut self,
res: Result<T, impl Display>,
span: Range<usize>,
) -> ParseResult<T>
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.
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<()>
fn starts_with_keyword(&mut self, keyword: &str) -> bool
Sourcefn 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 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.
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>
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.
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
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.