pub struct Parser<'a> { /* private fields */ }
Expand description
Parser for the rune language.
§Examples
use rune::ast;
use rune::SourceId;
use rune::parse::Parser;
let mut parser = Parser::new("fn foo() {}", SourceId::empty(), false);
let ast = parser.parse::<ast::ItemFn>()?;
Implementations§
Source§impl<'a> Parser<'a>
impl<'a> Parser<'a>
Sourcepub fn new(source: &'a str, source_id: SourceId, shebang: bool) -> Self
pub fn new(source: &'a str, source_id: SourceId, shebang: bool) -> Self
Construct a new parser around the given source.
shebang
indicates if the parser should try and parse a shebang or not.
Sourcepub fn from_token_stream(token_stream: &'a TokenStream, span: Span) -> Self
pub fn from_token_stream(token_stream: &'a TokenStream, span: Span) -> Self
Construct a parser from a token stream. The second argument span
is
the span to use if the stream is empty.
Sourcepub fn parse_all<T>(&mut self) -> Result<T>where
T: Parse,
pub fn parse_all<T>(&mut self) -> Result<T>where
T: Parse,
Parse a specific item from the parser and then expect end of input.
Sourcepub fn is_eof(&mut self) -> Result<bool>
pub fn is_eof(&mut self) -> Result<bool>
Test if the parser is at end-of-file, after which there is no more input to parse.
Sourcepub fn try_consume<T>(&mut self) -> Result<bool>
pub fn try_consume<T>(&mut self) -> Result<bool>
Try to consume a single thing matching T
, returns true
if any tokens
were consumed.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Parser<'a>
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§
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