Parser

Struct Parser 

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

Parser.

Implementations§

Source§

impl<'a> Parser<'a>

Source

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

Makes a new Parser instance.

Source

pub fn current_position(&self) -> Position

Returns the current position.

Source

pub fn is_eos(&self) -> bool

Returns true if the parser has reached EOS, otherwise false.

Source

pub fn text(&self) -> &str

Returns the full text.

Source

pub fn remaining_text(&self) -> &str

Returns the remaining, un-parsed text.

Source

pub fn peek_char(&self) -> Option<char>

Peeks the next character.

Source

pub fn read_char(&mut self) -> Option<char>

Reads the next character.

Source

pub fn parse<T: Parse>(&mut self) -> Option<T>

Parses an item.

Source

pub fn parsed_items<T: Parse>(&self) -> impl Iterator<Item = (Position, &T)>

Returns parsed items of which type is T.

Source

pub fn into_parse_error(self) -> ParseError

Converts Parser into ParseError.

You should call this method only when Parser::parse() returned None.

Trait Implementations§

Source§

impl<'a> Debug for Parser<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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.