pub(super) struct Parser<'a> {
tokens: Vec<Token<'a>>,
index: usize,
end: usize,
}Fields§
§tokens: Vec<Token<'a>>§index: usize§end: usizeImplementations§
Source§impl<'a> Parser<'a>
impl<'a> Parser<'a>
Sourcepub(super) fn parse(
source: &'a str,
dialect: Dialect,
) -> Result<Document, JsonError>
pub(super) fn parse( source: &'a str, dialect: Dialect, ) -> Result<Document, JsonError>
Parse source as one JSON5 document.
fn peek(&self) -> Option<&Token<'a>>
const fn advance(&mut self)
fn at(&self, kind: &TokenKind) -> bool
fn eat(&mut self, kind: &TokenKind) -> bool
Sourcefn unexpected(&self) -> JsonError
fn unexpected(&self) -> JsonError
The error for the current token, or for the end of input.
fn expect(&mut self, kind: &TokenKind) -> Result<(), JsonError>
Sourcefn split_line(&mut self) -> (String, String)
fn split_line(&mut self) -> (String, String)
Consume a run of trivia tokens and split it before its first line terminator that is not inside a comment.
Sourcefn tail(&mut self) -> (Tail, Next)
fn tail(&mut self) -> (Tail, Next)
Read what follows a value: an optional comma and the rest of the line.
fn value(&mut self, depth: usize, leading: Trivia) -> Result<Value, JsonError>
fn kind(&mut self, depth: usize) -> Result<Kind, JsonError>
fn scalar(&mut self, text: &str, offset: usize) -> Kind
fn key(&mut self) -> Result<Key, JsonError>
Sourcefn elements(
&mut self,
close: &TokenKind,
element: impl FnMut(&mut Self, Trivia) -> Result<Next, JsonError>,
) -> Result<Trivia, JsonError>
fn elements( &mut self, close: &TokenKind, element: impl FnMut(&mut Self, Trivia) -> Result<Next, JsonError>, ) -> Result<Trivia, JsonError>
Parse elements through the close token and return the trivia before
it. element reads one element, given the trivia before it.
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> UnsafeUnpin for Parser<'a>
impl<'a> UnwindSafe for Parser<'a>
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