ImpParser

Struct ImpParser 

Source
pub struct ImpParser<'i> {
    pub file: Name,
    pub input: &'i str,
    pub index: usize,
    pub builtin: bool,
}

Fields§

§file: Name§input: &'i str§index: usize§builtin: bool

Implementations§

Source§

impl<'a> ImpParser<'a>

Source

pub fn new(file: Name, input: &'a str, builtin: bool) -> Self

Source

pub fn parse_function_def( &mut self, indent: Indent, ) -> ParseResult<(Definition, Indent)>

Source

pub fn parse_type_def(&mut self, indent: Indent) -> ParseResult<(Adt, Indent)>

Source

pub fn parse_object(&mut self, indent: Indent) -> ParseResult<(Adt, Indent)>

Source

pub fn parse_hvm(&mut self) -> ParseResult<(HvmDefinition, Indent)>

Trait Implementations§

Source§

impl<'a> Parser<'a> for ImpParser<'a>

Source§

fn expected<T>(&mut self, exp: &str) -> ParseResult<T>

Generates an error message for parsing failures, including the highlighted context.

Override to have our own error message.

Source§

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

Consumes an instance of the given string, erroring if it is not found.

Override to have our own error message.

Source§

fn input(&mut self) -> &'a str

Source§

fn index(&mut self) -> &mut usize

Source§

fn skip_trivia(&mut self)

Skips whitespace & comments in the text.
Source§

fn expected_and<T>(&mut self, exp: &str, msg: &str) -> Result<T, ParseError>

Generates an error message with an additional custom message.
Source§

fn peek_one(&mut self) -> Option<char>

Inspects the next character in the text without consuming it.
Source§

fn peek_many(&mut self, count: usize) -> Option<&'i str>

Inspects the next count characters in the text without consuming them.
Source§

fn advance_one(&mut self) -> Option<char>

Consumes the next character in the text.
Source§

fn advance_many(&mut self, count: usize) -> Option<&'i str>

Advances the parser by count characters, consuming them.
Source§

fn skip_spaces(&mut self)

Skips spaces in the text.
Source§

fn is_eof(&mut self) -> bool

Checks if the parser has reached the end of the input.
Source§

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

Checks if the next characters in the input start with the given string.
Source§

fn take_while(&mut self, f: impl FnMut(char) -> bool) -> &'i str

Consumes all contiguous characters matching a given predicate.
Source§

fn parse_name(&mut self) -> Result<String, ParseError>

Parses a name from the input, supporting alphanumeric characters, underscores, periods, and hyphens.
Source§

fn parse_u64(&mut self) -> Result<u64, ParseError>

Parses a u64 from the input, supporting dec, hex (0xNUM), and bin (0bNUM).
Source§

fn parse_char(&mut self) -> Result<char, ParseError>

Parses a single unicode character, supporting scape sequences.
Source§

fn parse_quoted_char(&mut self) -> Result<char, ParseError>

Parses a quoted character, like ‘x’.
Source§

fn parse_quoted_string(&mut self) -> Result<String, ParseError>

Parses a quoted string, like “foobar”.
Source§

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

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. Read more
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

Auto Trait Implementations§

§

impl<'i> Freeze for ImpParser<'i>

§

impl<'i> RefUnwindSafe for ImpParser<'i>

§

impl<'i> Send for ImpParser<'i>

§

impl<'i> Sync for ImpParser<'i>

§

impl<'i> Unpin for ImpParser<'i>

§

impl<'i> UnwindSafe for ImpParser<'i>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<'t, T> Place<'t, T> for T

Source§

fn place(loaned: LoanedMut<'t, T>, place: &'t mut T)

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.