Struct rune::Parser[][src]

pub struct Parser<'a> { /* fields omitted */ }

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]

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]

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]

Parse a specific item from the parser.

pub fn parse_all<T>(&mut self) -> Result<T, ParseError> where
    T: Parse
[src]

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]

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

impl<'a> Debug for Parser<'a>[src]

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.