Struct Parser

Source
pub struct Parser<'s, 't> { /* private fields */ }
Expand description

Parser for jq programs.

Implementations§

Source§

impl<'s, 't> Parser<'s, 't>

Source

pub fn new(i: &'t [Token<&'s str>]) -> Self

Initialise a new parser on a sequence of Tokens.

Source

pub fn parse<T: Default, F>(self, f: F) -> Result<T, Vec<TError<'t, &'s str>>>
where F: FnOnce(&mut Self) -> Result<'s, 't, T>,

Parse tokens with the given function.

Returns Ok if the function consumes the whole output without producing any error.

Source

pub fn term(&mut self) -> Result<'s, 't, Term<&'s str>>

Parse a term such as .[] | .+1.

Source

pub fn defs(&mut self) -> Result<'s, 't, Vec<Def<&'s str>>>

Parse a sequence of definitions, such as def x: 1; def y: 2;.

Auto Trait Implementations§

§

impl<'s, 't> Freeze for Parser<'s, 't>

§

impl<'s, 't> RefUnwindSafe for Parser<'s, 't>

§

impl<'s, 't> Send for Parser<'s, 't>

§

impl<'s, 't> Sync for Parser<'s, 't>

§

impl<'s, 't> Unpin for Parser<'s, 't>

§

impl<'s, 't> UnwindSafe for Parser<'s, 't>

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.