Struct expry::parser::ParserState

source ·
pub struct ParserState<'b, T, E, Context = ()>
where T: PartialEq + Debug,
{ pub reader: &'b str, pub context: Context, /* private fields */ }

Fields§

§reader: &'b str§context: Context

Implementations§

source§

impl<'b, T, E, Context> ParserState<'b, T, E, Context>
where T: PartialEq + Copy + Clone + Debug, E: Copy + Clone + Debug,

source

pub fn repeat<P>(&mut self, path: P) -> ParserResult<(), E>
where P: FnMut(&mut Self) -> ParserResult<bool, E>,

source

pub fn opt<S, P>(&mut self, path: P) -> ParserResult<Option<S>, E>
where P: FnOnce(&mut Self) -> ParserResult<S, E>,

source

pub fn choose<S>( &mut self, paths: &[fn(reader: &mut ParserState<'b, T, E, Context>) -> ParserResult<S, E>], err: fn() -> E ) -> ParserResult<S, E>

source

pub fn choose_with_state<S, State>( &mut self, paths: &[fn(parser: &mut ParserState<'b, T, E, Context>, state: &mut State) -> ParserResult<S, E>], state: &mut State, err: fn() -> E ) -> ParserResult<S, E>

source

pub fn call<S>( &mut self, path: fn(reader: &mut ParserState<'b, T, E, Context>) -> ParserResult<S, E> ) -> ParserResult<S, E>

Useful for recursive functions (like for parsing negation and the unary minus).

source

pub fn accept<F>( &mut self, expected: T, info: Option<&TokenInfo>, err: F ) -> ParserResult<TokenInfo, E>
where F: Fn() -> E,

source

pub fn get(&mut self) -> ParserResult<(T, TokenInfo), E>

source

pub fn undo_get(&mut self, token: T, info: TokenInfo)

source

pub fn error_token<F>( &mut self, token: T, info: TokenInfo, err: F ) -> ParserStatus<E>
where F: FnOnce(&mut Self) -> E,

source

pub fn error_other(&mut self, info: &TokenInfo, err: E) -> ParserStatus<E>

source

pub fn token_info(&mut self) -> ParserResult<TokenInfo, E>

source

pub fn context(&mut self) -> &mut Context

source

pub fn consume(self) -> Context

source

pub fn new_with( reader: &'b str, tokenize: fn(reader: &mut &'b str, context: &mut Context) -> Result<(T, usize), (E, usize, usize)>, context: Context ) -> Self

source

pub fn parse<R>( &mut self, f: fn(_: &mut Self) -> ParserResult<R, E>, unexpected_token: E, depth_limit_reached: E ) -> Result<R, (E, usize, usize, Option<(usize, usize)>)>

Trait Implementations§

source§

impl<'b, T, E, Context> Debug for ParserState<'b, T, E, Context>
where T: Debug + PartialEq,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'b, T, E, Context> Freeze for ParserState<'b, T, E, Context>
where Context: Freeze, T: Freeze,

§

impl<'b, T, E, Context> RefUnwindSafe for ParserState<'b, T, E, Context>
where Context: RefUnwindSafe, T: RefUnwindSafe,

§

impl<'b, T, E, Context> Send for ParserState<'b, T, E, Context>
where Context: Send, T: Send,

§

impl<'b, T, E, Context> Sync for ParserState<'b, T, E, Context>
where Context: Sync, T: Sync,

§

impl<'b, T, E, Context> Unpin for ParserState<'b, T, E, Context>
where Context: Unpin, T: Unpin,

§

impl<'b, T, E, Context> UnwindSafe for ParserState<'b, T, E, Context>
where Context: UnwindSafe, T: UnwindSafe,

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

§

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

§

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.