Struct sway_parse::Parser
source · [−]pub struct Parser<'a, 'e> { /* private fields */ }
Implementations
sourceimpl<'a, 'e> Parser<'a, 'e>
impl<'a, 'e> Parser<'a, 'e>
pub fn new(token_stream: &'a TokenStream, handler: &'e Handler) -> Parser<'a, 'e>
pub fn emit_error(&mut self, kind: ParseErrorKind) -> ErrorEmitted
pub fn emit_error_with_span(
&mut self,
kind: ParseErrorKind,
span: Span
) -> ErrorEmitted
sourcepub fn take<P: Peek>(&mut self) -> Option<P>
pub fn take<P: Peek>(&mut self) -> Option<P>
Eats a P
in its canonical way by peeking.
Unlike Parser::peek
, this method advances the parser on success, but not on failure.
sourcepub fn peek<P: Peek>(&self) -> Option<P>
pub fn peek<P: Peek>(&self) -> Option<P>
Tries to peek a P
in its canonical way.
Either way, on success or failure, the parser is not advanced.
sourcepub fn guarded_parse<G: Peek, T: Parse>(
&mut self
) -> Result<Option<T>, ErrorEmitted>
pub fn guarded_parse<G: Peek, T: Parse>(
&mut self
) -> Result<Option<T>, ErrorEmitted>
Parses T
given that the guard G
was successfully peeked.
Useful to parse e.g., $keyword $stuff
as a unit where $keyword
is your guard.
pub fn parse_to_end<T: ParseToEnd>(
self
) -> Result<(T, ParserConsumed<'a>), ErrorEmitted>
pub fn try_parse_to_end<T: Parse>(
self
) -> Result<Option<(T, ParserConsumed<'a>)>, ErrorEmitted>
pub fn enter_delimited(
&mut self,
expected_delimiter: Delimiter
) -> Option<(Parser<'_, '_>, Span)>
pub fn is_empty(&self) -> bool
pub fn check_empty(&self) -> Option<ParserConsumed<'a>>
pub fn debug_tokens(&self) -> &[TokenTree]
Auto Trait Implementations
impl<'a, 'e> !RefUnwindSafe for Parser<'a, 'e>
impl<'a, 'e> !Send for Parser<'a, 'e>
impl<'a, 'e> !Sync for Parser<'a, 'e>
impl<'a, 'e> Unpin for Parser<'a, 'e>
impl<'a, 'e> !UnwindSafe for Parser<'a, 'e>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more