Struct rune::Parser [−][src]
Parser for the rune language.
Examples
use rune::{ast, Parser}; let mut parser = Parser::new("fn foo() {}"); parser.parse::<ast::ItemFn>().unwrap();
Implementations
impl<'a> Parser<'a>
[src]
pub fn new(source: &'a str) -> Self
[src]
Construct a new parser around the given source.
pub fn try_consume<T>(&mut self) -> Result<bool, ParseError> where
T: Parse + Peek,
[src]
T: Parse + Peek,
Try to consume a single thing matching T
, returns true
if any tokens
were consumed.
pub fn try_consume_all<T>(&mut self) -> Result<bool, ParseError> where
T: Parse + Peek,
[src]
T: Parse + Peek,
Try to consume all things matching T
, returns true
if any tokens
were consumed.
pub fn from_token_stream(token_stream: &'a TokenStream) -> Self
[src]
Construct a parser from a token stream.
pub fn span(&mut self, range: Range<usize>) -> Span
[src]
Get the span for the given range offset of tokens.
pub fn parse<T>(&mut self) -> Result<T, ParseError> where
T: Parse,
[src]
T: Parse,
Parse a specific item from the parser.
pub fn parse_all<T>(&mut self) -> Result<T, ParseError> where
T: Parse,
[src]
T: Parse,
Parse a specific item from the parser and then expect end of input.
pub fn peek<T>(&mut self) -> Result<bool, ParseError> where
T: Peek,
[src]
T: Peek,
Peek for the given token.
pub fn peeker(&mut self) -> &mut Peeker<'a>
[src]
Access the interior peeker of the parser.
pub fn next(&mut self) -> Result<Token, ParseError>
[src]
Consume the next token from the parser.
pub fn is_eof(&mut self) -> Result<bool, ParseError>
[src]
Test if the parser is at end-of-file, after which there is no more input to parse.
pub fn eof(&mut self) -> Result<(), ParseError>
[src]
Assert that the parser has reached its end-of-file.
pub fn nth(&mut self, n: usize) -> Result<Kind, ParseError>
[src]
Peek the token kind at the given position.
pub fn span_at(&mut self, n: usize) -> Span
[src]
Get the span for the given offset.
pub fn tok_at(&mut self, n: usize) -> Result<Token, ParseError>
[src]
Get the span at the given position.
pub fn last_span(&self) -> Span
[src]
The last known span in this parser.
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for Parser<'a>
impl<'a> Send for Parser<'a>
impl<'a> Sync for Parser<'a>
impl<'a> Unpin for Parser<'a>
impl<'a> UnwindSafe for Parser<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,