pub struct PyParser<'i> {
pub input: &'i str,
pub index: usize,
}
Fields§
§input: &'i str
§index: usize
Implementations§
source§impl<'a> PyParser<'a>
impl<'a> PyParser<'a>
pub fn parse_def(&mut self, indent: Indent) -> ParseResult<(Definition, Indent)>
pub fn parse_type(&mut self, indent: Indent) -> ParseResult<(Enum, Indent)>
pub fn parse_object(&mut self, indent: Indent) -> ParseResult<(Variant, Indent)>
pub fn add_def( &mut self, def: Definition, book: &mut Book, ini_idx: usize, end_idx: usize ) -> ParseResult<()>
pub fn add_type( &mut self, enum: Enum, book: &mut Book, ini_idx: usize, end_idx: usize, builtin: bool ) -> ParseResult<()>
pub fn add_object( &mut self, obj: Variant, book: &mut Book, ini_idx: usize, end_idx: usize, builtin: bool ) -> ParseResult<()>
Trait Implementations§
source§impl<'a> Parser<'a> for PyParser<'a>
impl<'a> Parser<'a> for PyParser<'a>
source§fn expected<T>(&mut self, exp: &str) -> ParseResult<T>
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<()>
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.
fn input(&mut self) -> &'a str
fn index(&mut self) -> &mut usize
source§fn skip_trivia(&mut self)
fn skip_trivia(&mut self)
Skips whitespace & comments in the text.
source§fn peek_one(&mut self) -> Option<char>
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>
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>
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>
fn advance_many(&mut self, count: usize) -> Option<&'i str>
Advances the parser by
count
characters, consuming them.source§fn skip_spaces(&mut self)
fn skip_spaces(&mut self)
Skips spaces in the text.
source§fn starts_with(&mut self, text: &str) -> bool
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
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>
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>
fn parse_u64(&mut self) -> Result<u64, String>
Parses a u64 from the input, supporting dec, hex (0xNUM), and bin (0bNUM).
source§impl<'a> ParserCommons<'a> for PyParser<'a>
impl<'a> ParserCommons<'a> for PyParser<'a>
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>
source§fn 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<()>
source§fn advance_newlines(&mut self) -> Indent
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
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)
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>
source§fn 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.
source§fn 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<()>
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>>
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
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>
source§fn 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.
Auto Trait Implementations§
impl<'i> Freeze for PyParser<'i>
impl<'i> RefUnwindSafe for PyParser<'i>
impl<'i> Send for PyParser<'i>
impl<'i> Sync for PyParser<'i>
impl<'i> Unpin for PyParser<'i>
impl<'i> UnwindSafe for PyParser<'i>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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