pub struct Parser<'a> {
pub exts: Extensions,
src: &'a str,
cursor: ParserCursor,
}Fields§
§exts: ExtensionsBits set according to the Extensions enum.
src: &'a str§cursor: ParserCursorImplementations§
Source§impl<'a> Parser<'a>
constructor and parsing utilities
impl<'a> Parser<'a>
constructor and parsing utilities
pub fn new(src: &'a str) -> SpannedResult<Self>
fn set_cursor(&mut self, cursor: ParserCursor)
pub fn span_error(&self, code: Error) -> SpannedError
pub fn advance_bytes(&mut self, bytes: usize)
pub fn next_char(&mut self) -> Result<char>
pub fn skip_next_char(&mut self)
pub fn peek_char(&self) -> Option<char>
pub fn peek_char_or_eof(&self) -> Result<char>
pub fn check_char(&self, c: char) -> bool
pub fn check_str(&self, s: &str) -> bool
pub fn src(&self) -> &'a str
pub fn pre_ws_src(&self) -> &'a str
pub fn consume_str(&mut self, s: &str) -> bool
pub fn consume_char(&mut self, c: char) -> bool
fn consume_all(&mut self, all: &[&str]) -> Result<bool>
pub fn expect_char(&mut self, expected: char, error: Error) -> Result<()>
pub fn next_chars_while_len(&self, condition: fn(char) -> bool) -> usize
pub fn next_chars_while_from_len( &self, from: usize, condition: fn(char) -> bool, ) -> usize
Source§impl<'a> Parser<'a>
actual parsing of ron tokens
impl<'a> Parser<'a>
actual parsing of ron tokens
fn parse_integer_digits<T: Num>( &mut self, s: &str, base: u8, f: fn(&mut T, u8) -> bool, ) -> Result<T>
fn parse_integer<T: Num>(&mut self, sign: i8) -> Result<T>
pub fn integer<T: Integer>(&mut self) -> Result<T>
pub fn any_number(&mut self) -> Result<Number>
pub fn bool(&mut self) -> Result<bool>
pub fn char(&mut self) -> Result<char>
pub fn comma(&mut self) -> Result<bool>
Sourcepub fn check_ident(&mut self, ident: &str) -> bool
pub fn check_ident(&mut self, ident: &str) -> bool
Only returns true if the char after ident cannot belong
to an identifier.
fn check_ident_other_char(&self, index: usize) -> bool
Sourcepub fn check_struct_type(
&mut self,
newtype: NewtypeMode,
tuple: TupleMode,
) -> Result<StructType>
pub fn check_struct_type( &mut self, newtype: NewtypeMode, tuple: TupleMode, ) -> Result<StructType>
Check which type of struct we are currently parsing. The parsing state is only changed in case of an error, to provide a better position.
NewtypeMode::NoParensMeanUnit detects (tuple) structs by a leading
opening bracket and reports a unit struct otherwise.
NewtypeMode::InsideNewtype skips an initial check for unit structs,
and means that any leading opening bracket is not considered to open
a (tuple) struct but to be part of the structs inner contents.
TupleMode::ImpreciseTupleOrNewtype only performs a cheap, O(1),
single-identifier lookahead check to distinguish tuple structs from
non-tuple structs.
TupleMode::DifferentiateNewtype performs an expensive, O(N), look-
ahead over the entire next value tree, which can span the entirety of
the remaining document in the worst case.
Sourcepub fn consume_ident(&mut self, ident: &str) -> bool
pub fn consume_ident(&mut self, ident: &str) -> bool
Only returns true if the char after ident cannot belong
to an identifier.
pub fn consume_struct_name(&mut self, ident: &'static str) -> Result<bool>
Sourcefn extensions(&mut self) -> Result<Extensions>
fn extensions(&mut self) -> Result<Extensions>
Returns the extensions bit mask.