Parser

Struct Parser 

Source
pub struct Parser<'a> {
    pub exts: Extensions,
    src: &'a str,
    cursor: ParserCursor,
}

Fields§

§exts: Extensions

Bits set according to the Extensions enum.

§src: &'a str§cursor: ParserCursor

Implementations§

Source§

impl<'a> Parser<'a>

constructor and parsing utilities

Source

pub fn new(src: &'a str) -> SpannedResult<Self>

Source

fn set_cursor(&mut self, cursor: ParserCursor)

Source

pub fn span_error(&self, code: Error) -> SpannedError

Source

pub fn advance_bytes(&mut self, bytes: usize)

Source

pub fn next_char(&mut self) -> Result<char>

Source

pub fn skip_next_char(&mut self)

Source

pub fn peek_char(&self) -> Option<char>

Source

pub fn peek_char_or_eof(&self) -> Result<char>

Source

pub fn check_char(&self, c: char) -> bool

Source

pub fn check_str(&self, s: &str) -> bool

Source

pub fn src(&self) -> &'a str

Source

pub fn pre_ws_src(&self) -> &'a str

Source

pub fn consume_str(&mut self, s: &str) -> bool

Source

pub fn consume_char(&mut self, c: char) -> bool

Source

fn consume_all(&mut self, all: &[&str]) -> Result<bool>

Source

pub fn expect_char(&mut self, expected: char, error: Error) -> Result<()>

Source

pub fn next_chars_while_len(&self, condition: fn(char) -> bool) -> usize

Source

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

Source

fn parse_integer_digits<T: Num>( &mut self, s: &str, base: u8, f: fn(&mut T, u8) -> bool, ) -> Result<T>

Source

fn parse_integer<T: Num>(&mut self, sign: i8) -> Result<T>

Source

pub fn integer<T: Integer>(&mut self) -> Result<T>

Source

pub fn any_number(&mut self) -> Result<Number>

Source

pub fn bool(&mut self) -> Result<bool>

Source

pub fn char(&mut self) -> Result<char>

Source

pub fn comma(&mut self) -> Result<bool>

Source

pub fn check_ident(&mut self, ident: &str) -> bool

Only returns true if the char after ident cannot belong to an identifier.

Source

fn check_ident_other_char(&self, index: usize) -> bool

Source

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.

Source

pub fn consume_ident(&mut self, ident: &str) -> bool

Only returns true if the char after ident cannot belong to an identifier.

Source

pub fn consume_struct_name(&mut self, ident: &'static str) -> Result<bool>

Source

fn extensions(&mut self) -> Result<Extensions>

Returns the extensions bit mask.

Source

pub fn float<T: Float>(&mut self) -> Result<T>

Source

pub fn skip_identifier(&mut self) -> Option<&'a str>

Source

pub fn identifier(&mut self) -> Result<&'a str>

Source

pub fn next_bytes_is_float(&mut self) -> bool

Source

pub fn skip_ws(&mut self) -> Result<()>

Source

pub fn has_unclosed_line_comment(&self) -> bool

Source

pub fn byte_string(&mut self) -> Result<ParsedByteStr<'a>>

Source

pub fn byte_string_no_base64(&mut self) -> Result<ParsedByteStr<'a>>

Source

fn escaped_byte_string(&mut self) -> Result<ParsedByteStr<'a>>

Source

fn raw_byte_string(&mut self) -> Result<ParsedByteStr<'a>>

Source

pub fn string(&mut self) -> Result<ParsedStr<'a>>

Source

fn escaped_string(&mut self) -> Result<ParsedStr<'a>>

Source

fn raw_string(&mut self) -> Result<ParsedStr<'a>>

Source

fn escaped_byte_buf( &mut self, encoding: EscapeEncoding, ) -> Result<(ParsedByteStr<'a>, usize)>

Source

fn raw_byte_buf(&mut self) -> Result<(ParsedByteStr<'a>, usize)>

Source

fn decode_ascii_escape(&mut self) -> Result<u8>

Source

fn decode_hex(c: char) -> Result<u8>

Source

fn parse_escape( &mut self, encoding: EscapeEncoding, is_char: bool, ) -> Result<EscapeCharacter>

Source

fn skip_comment(&mut self) -> Result<Option<Comment>>

Auto Trait Implementations§

§

impl<'a> Freeze for Parser<'a>

§

impl<'a> RefUnwindSafe for Parser<'a>

§

impl<'a> Send for Parser<'a>

§

impl<'a> Sync for Parser<'a>

§

impl<'a> Unpin for Parser<'a>

§

impl<'a> UnwindSafe for Parser<'a>

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