Struct bend::fun::parser::TermParser

source ·
pub struct TermParser<'i> { /* private fields */ }

Implementations§

source§

impl<'a> TermParser<'a>

source

pub fn new(input: &'a str) -> Self

source

pub fn parse_book( &mut self, default_book: Book, builtin: bool ) -> ParseResult<Book>

source

pub fn parse_term(&mut self) -> ParseResult<Term>

Trait Implementations§

source§

impl<'a> Parser<'a> for TermParser<'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 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, String>

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

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

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

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

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

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

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

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

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

impl<'a> ParserCommons<'a> for TermParser<'a>

source§

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

source§

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

source§

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

source§

fn parse_exactly_name(&mut self) -> ParseResult<String>

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) -> Indent

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

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.
source§

fn skip_trivia_inline(&mut self)

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

fn skip_trivia_maybe_inline(&mut self, inline: bool)

source§

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

source§

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

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

fn parse_oper(&mut self) -> ParseResult<Op>

source§

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

source§

fn parse_u32(&mut self) -> 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.

Auto Trait Implementations§

§

impl<'i> Freeze for TermParser<'i>

§

impl<'i> RefUnwindSafe for TermParser<'i>

§

impl<'i> Send for TermParser<'i>

§

impl<'i> Sync for TermParser<'i>

§

impl<'i> Unpin for TermParser<'i>

§

impl<'i> UnwindSafe for TermParser<'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>,

§

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>,

§

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.