TermParser

Struct TermParser 

Source
pub struct TermParser<I>
where I: FusedIterator<Item = u8>,
{ /* private fields */ }

Implementations§

Source§

impl<I> TermParser<I>
where I: FusedIterator<Item = u8>,

Source

pub fn try_new(input: I, opers: Option<OperDefs>) -> Result<Self>

Source

pub fn try_collect_terms(&mut self, arena: &mut Arena) -> Result<Vec<Term>>

Source

pub fn try_next_term(&mut self, arena: &mut Arena) -> Result<Option<Term>>

Source

pub fn define_opers<J: FusedIterator<Item = u8>>( &mut self, arena: &mut Arena, defs_input: J, opers: Option<OperDefs>, ) -> Result<()>

Trait Implementations§

Source§

impl<I> Parser<Arena> for TermParser<I>
where I: FusedIterator<Item = u8>,

Source§

type Lexer = TermLexer<I>

The lexer used by this parser. Must be provided by the implementor and produce tokens compatible with ParserData::TokenID.
Source§

type ParserData = ParData

The parser data providing states, productions, tokens, and lookup tables. Must be provided by the implementor and be the struct generated by parlex-gen’s parser generator, ASLR.
Source§

fn ctx(&self) -> &ParserCtx<Self::Lexer, Self::ParserData, Arena>

Returns a shared reference to the parser context. Must be provided by the implementor and return &ParserCtx.
Source§

fn ctx_mut(&mut self) -> &mut ParserCtx<Self::Lexer, Self::ParserData, Arena>

Returns a mutable reference to the parser context. Must be provided by the implementor and return &mut ParserCtx.
Source§

fn stats(&self) -> ParserStats

Returns current parser statistics.
Source§

fn resolve_ambiguity( &mut self, _arena: &mut Arena, ambig: AmbigID, tok2: &TermToken, ) -> Result<Action>

Resolves an ambiguity using user-defined logic (e.g., precedence/associativity). Must be provided by the implementor.
Source§

fn reduce( &mut self, arena: &mut Arena, prod: ProdID, token: &TermToken, ) -> Result<()>

Performs a reduction for the specified production. Must be provided by the implementor.
Source§

fn tokens_peek<'a>( &'a self, index: usize, ) -> &'a <Self::Lexer as Lexer<U>>::Token
where U: 'a,

Returns a reference to a token counted from the end of the stack. 0 = last (top), 1 = second last, etc. Read more
Source§

fn tokens_mut_peek<'a>( &'a mut self, index: usize, ) -> &'a mut <Self::Lexer as Lexer<U>>::Token
where U: 'a,

Returns a mutable reference to a token counted from the end of the stack. 0 = last (top), 1 = second last, etc. Read more
Source§

fn tokens_pop(&mut self) -> Result<<Self::Lexer as Lexer<U>>::Token, Error>

Pops and returns the last (top) token from the stack. Read more
Source§

fn tokens_push(&mut self, token: <Self::Lexer as Lexer<U>>::Token)

Pushes a token onto the stack.
Source§

fn dump_state(&self, incoming: &<Self::Lexer as Lexer<U>>::Token)

Traces the current parser state and token stack for debugging. Formats the stack with states and tokens, marking the incoming token with <-.
Source§

fn try_collect( &mut self, user_data: &mut U, ) -> Result<Vec<<Self::Lexer as Lexer<U>>::Token>, Error>

Attempts to collect all tokens until exhaustion.
Source§

fn try_next( &mut self, user_data: &mut U, ) -> Result<Option<<Self::Lexer as Lexer<U>>::Token>, Error>

Attempts to parse the input and produce the next reduced (accepted) token.

Auto Trait Implementations§

§

impl<I> Freeze for TermParser<I>
where I: Freeze,

§

impl<I> RefUnwindSafe for TermParser<I>
where I: RefUnwindSafe,

§

impl<I> Send for TermParser<I>
where I: Send,

§

impl<I> Sync for TermParser<I>
where I: Sync,

§

impl<I> Unpin for TermParser<I>
where I: Unpin,

§

impl<I> UnwindSafe for TermParser<I>
where I: UnwindSafe,

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V