Struct expry::parser::ParserState
source · pub struct ParserState<'b, T, E, Context = ()>{
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>
impl<'b, T, E, Context> ParserState<'b, T, E, Context>
pub fn repeat<P>(&mut self, path: P) -> ParserResult<(), E>
pub fn opt<S, P>(&mut self, path: P) -> ParserResult<Option<S>, E>
pub fn choose<S>( &mut self, paths: &[fn(reader: &mut ParserState<'b, T, E, Context>) -> ParserResult<S, E>], err: fn() -> E ) -> ParserResult<S, E>
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>
sourcepub fn call<S>(
&mut self,
path: fn(reader: &mut ParserState<'b, T, E, Context>) -> ParserResult<S, E>
) -> ParserResult<S, E>
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).
pub fn accept<F>(
&mut self,
expected: T,
info: Option<&TokenInfo>,
err: F
) -> ParserResult<TokenInfo, E>where
F: Fn() -> E,
pub fn get(&mut self) -> ParserResult<(T, TokenInfo), E>
pub fn undo_get(&mut self, token: T, info: TokenInfo)
pub fn error_token<F>( &mut self, token: T, info: TokenInfo, err: F ) -> ParserStatus<E>
pub fn error_other(&mut self, info: &TokenInfo, err: E) -> ParserStatus<E>
pub fn token_info(&mut self) -> ParserResult<TokenInfo, E>
pub fn context(&mut self) -> &mut Context
pub fn consume(self) -> Context
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
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§
Auto Trait Implementations§
impl<'b, T, E, Context> Freeze for ParserState<'b, T, E, Context>
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>
impl<'b, T, E, Context> Sync for ParserState<'b, T, E, Context>
impl<'b, T, E, Context> Unpin for ParserState<'b, T, E, Context>
impl<'b, T, E, Context> UnwindSafe for ParserState<'b, T, E, Context>where
Context: UnwindSafe,
T: UnwindSafe,
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