perplex_runtime

Struct ParserMachine

Source
pub struct ParserMachine<I: ParserInput, S: StateSpace> { /* private fields */ }
Expand description

A parser state machine.

This struct implements the parse stack and driver for the parser. It is generic over the means by which terminals arrive at the input.

Implementations§

Source§

impl<I: ParserInput<Item = S::Terminal>, S: StateSpace> ParserMachine<I, S>

Source

pub fn new(input: I) -> ParserMachine<I, S>

Create a new parser state machine.

Source

pub fn run(self) -> S::Nonterminal

Run the parser to completion.

Source§

impl<I: Iterator, S: StateSpace<Terminal = Option<I::Item>>> ParserMachine<IterInput<I>, S>

Source

pub fn from_iter(input: I) -> ParserMachine<IterInput<I>, S>

Create a new parser state machine from an iterator.

Trait Implementations§

Source§

impl<I, S> Parser for ParserMachine<I, S>
where I: ParserInput<Item = S::Terminal>, S: StateSpace,

Source§

type Terminal = <S as StateSpace>::Terminal

The type of terminals the parser emits.
Source§

type Nonterminal = <S as StateSpace>::Nonterminal

The type of nonterminals the parser emits. This is likely an enum over all nonterminals generated automatically.
Source§

fn peek(&mut self) -> &S::Terminal

Peek at the next terminal in the sequence without shifting it.
Source§

fn shift( &mut self, state_fn: fn(_: &mut Self), goto_fn: fn(_: &mut Self, _: S::Nonterminal), )

Push the next terminal onto the stack. Read more
Source§

fn goto( &mut self, nonterminal: S::Nonterminal, state_fn: fn(_: &mut Self), goto_fn: fn(_: &mut Self, _: S::Nonterminal), )

Push a nonterminal onto the stack. Read more
Source§

fn reduce<F: Fn(Vec<Symbol<S::Terminal, S::Nonterminal>>) -> S::Nonterminal>( &mut self, length: usize, f: F, )

Reduce the tail of the stack to a nonterminal. Read more
Source§

fn accept(&mut self)

Accept the last symbol on the stack as the parse result. Read more

Auto Trait Implementations§

§

impl<I, S> Freeze for ParserMachine<I, S>
where I: Freeze, <S as StateSpace>::Nonterminal: Freeze,

§

impl<I, S> RefUnwindSafe for ParserMachine<I, S>

§

impl<I, S> Send for ParserMachine<I, S>
where I: Send, <S as StateSpace>::Nonterminal: Send, <S as StateSpace>::Terminal: Send,

§

impl<I, S> Sync for ParserMachine<I, S>
where I: Sync, <S as StateSpace>::Nonterminal: Sync, <S as StateSpace>::Terminal: Sync,

§

impl<I, S> Unpin for ParserMachine<I, S>
where I: Unpin, <S as StateSpace>::Nonterminal: Unpin, <S as StateSpace>::Terminal: Unpin,

§

impl<I, S> UnwindSafe for ParserMachine<I, S>

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.