Struct Parser

Source
pub struct Parser<'a> { /* private fields */ }
Expand description

Wrapper around Logos and Rowan to for parsing with 1 lookahead.

Implementations§

Source§

impl<'a> Parser<'a>

Source

pub fn new(input: &'a str) -> Self

Source

pub fn finish(self) -> Parse

Finishes the parse, any remaining content will be consumed as an error.

Source

pub fn peek_is(&mut self, token: Token) -> bool

True if the next token is token.

Source

pub fn peek_is_not(&mut self, token: Token) -> bool

True if the next token is not token or end-of-file.

Source

pub fn peek(&mut self) -> Option<Token>

Peek at the first unprocessed token

Source

pub fn token(&mut self, token: Token)

Parse a specific token and skip trailing insignificants

Source

pub fn error(&mut self)

Add the next significant token in an error node.

Source

pub fn skip_insignificant(&mut self)

Skip insignificant tokens

Source

pub fn bump(&mut self)

Advance one token, adding it to the current branch of the tree builder.

§Panics

Panics when called on end-of-file.

Source

pub fn checkpoint(&self) -> Checkpoint

Prepare for maybe wrapping the next node.

Source

pub fn start_node_at(&mut self, checkpoint: Checkpoint, node: Node)

Wrap the previous branch marked by checkpoint in a new branch and make it current.

Source

pub fn start_node(&mut self, node: Node)

Add a new parent node to the tree and decent.

Source

pub fn finish_node(&mut self)

Finish the current branch and ascent to the parent node.

Source

pub fn add_token(&mut self, token: Token, slice: &str)

Add a token to the current branch of the tree builder.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.