pub struct Parser { /* private fields */ }Expand description
Parser
Implementations§
Source§impl Parser
impl Parser
Sourcepub fn reverse_whitespace(&mut self)
pub fn reverse_whitespace(&mut self)
Reverses all whitespace (except the last) in the current position
Sourcepub fn reverse_line(&mut self)
pub fn reverse_line(&mut self)
Reverses to the start of the current line
Sourcepub fn loc(&self, pos: AstPos) -> ParserLoc
pub fn loc(&self, pos: AstPos) -> ParserLoc
Gets the position (0-indexed) of the parser at a position
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Returns if the parser is finished
Sourcepub fn update_with<F, O>(&mut self, f: F) -> (AstStr, O)
pub fn update_with<F, O>(&mut self, f: F) -> (AstStr, O)
Updates this parser from a string.
See Self::try_update_with for more details.
Sourcepub fn try_update_with<F, T>(
&mut self,
f: F,
) -> <T::Residual as Residual<(AstStr, T::Output)>>::TryType
pub fn try_update_with<F, T>( &mut self, f: F, ) -> <T::Residual as Residual<(AstStr, T::Output)>>::TryType
Updates this parser from a string.
The function f receives a string to update.
The value it is updated with must be a substring of the
received function.
§Success
When f returns successfully, the parser is updated from
the state of the string.
§Failure
If f returns unsuccessfully, an error will be returned
with the latest change to the string as it’s position.
Sourcepub fn parse<T: Parse>(&mut self) -> Result<T, ParserError<T>>
pub fn parse<T: Parse>(&mut self) -> Result<T, ParserError<T>>
Parses T from this parser
Sourcepub fn parse_with_peeked<T: ParsePeeked<U>, U>(
&mut self,
parsed: U,
) -> Result<T, ParserError<T>>
pub fn parse_with_peeked<T: ParsePeeked<U>, U>( &mut self, parsed: U, ) -> Result<T, ParserError<T>>
Parses T from this parser with a peeked value
Sourcepub fn try_parse_with<T, E: ParseError>(
&mut self,
parser: impl FnOnce(&mut Self) -> Result<T, E>,
) -> Result<Result<T, E>, E>
pub fn try_parse_with<T, E: ParseError>( &mut self, parser: impl FnOnce(&mut Self) -> Result<T, E>, ) -> Result<Result<T, E>, E>
Tries to parses T from this parser using parser for parsing.
On error, nothing is modified.
Sourcepub fn try_parse<T: Parse>(
&mut self,
) -> Result<Result<T, ParserError<T>>, ParserError<T>>
pub fn try_parse<T: Parse>( &mut self, ) -> Result<Result<T, ParserError<T>>, ParserError<T>>
Tries to parses T from this parser.
On error, nothing is modified.
Sourcepub fn peek_with<T, E: ParseError>(
&mut self,
parse: impl FnOnce(&mut Self) -> Result<T, E>,
) -> Result<Result<(T, PeekState), E>, E>
pub fn peek_with<T, E: ParseError>( &mut self, parse: impl FnOnce(&mut Self) -> Result<T, E>, ) -> Result<Result<(T, PeekState), E>, E>
Peeks a T from this parser using parser for parsing.
Parser is only advanced is a fatal error occurs
Sourcepub fn peek<T: Parse>(
&mut self,
) -> Result<Result<(T, PeekState), ParserError<T>>, ParserError<T>>
pub fn peek<T: Parse>( &mut self, ) -> Result<Result<(T, PeekState), ParserError<T>>, ParserError<T>>
Peeks a T from this parser.
Parser is only advanced is a fatal error occurs
Sourcepub const fn set_peeked(&mut self, peek_state: PeekState)
pub const fn set_peeked(&mut self, peek_state: PeekState)
Accepts a peeked state.
Returns all current tags
Calls f with tags tags added to this parser
Sourcepub fn with_tag<O>(
&mut self,
tag: impl Into<ParserTag>,
f: impl FnOnce(&mut Self) -> O,
) -> O
pub fn with_tag<O>( &mut self, tag: impl Into<ParserTag>, f: impl FnOnce(&mut Self) -> O, ) -> O
Calls f with tag tag added to this parser
Calls f with all tags removed.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Parser
impl RefUnwindSafe for Parser
impl Send for Parser
impl Sync for Parser
impl Unpin for Parser
impl UnsafeUnpin for Parser
impl UnwindSafe for Parser
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
Source§impl<R, T> FromRecursiveRoot<R> for Twhere
T: From<R>,
impl<R, T> FromRecursiveRoot<R> for Twhere
T: From<R>,
fn from_recursive_root(root: R, _parser: &mut Parser) -> T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more