Skip to main content

ParserAtnBuilder

Struct ParserAtnBuilder 

Source
pub struct ParserAtnBuilder { /* private fields */ }
Expand description

Centralized construction API for packed parser ATNs.

States never own transition collections; edges are grouped into contiguous ranges only when the final packed stream is emitted.

Implementations§

Source§

impl ParserAtnBuilder

Source

pub const fn new(max_token_type: i32) -> Self

Source

pub fn add_state( &mut self, kind: AtnStateKind, rule_index: Option<usize>, ) -> Result<AtnStateId, ParserAtnError>

Source

pub fn set_end_state( &mut self, state: usize, end_state: usize, ) -> Result<(), ParserAtnError>

Source

pub fn set_loop_back_state( &mut self, state: usize, loop_back_state: usize, ) -> Result<(), ParserAtnError>

Source

pub fn set_non_greedy(&mut self, state: usize) -> Result<(), ParserAtnError>

Source

pub fn set_left_recursive_rule( &mut self, state: usize, ) -> Result<(), ParserAtnError>

Source

pub fn set_precedence_rule_decision( &mut self, state: usize, ) -> Result<(), ParserAtnError>

Source

pub fn add_interval_set( &mut self, ranges: impl IntoIterator<Item = (i32, i32)>, ) -> Result<ParserIntervalSetId, ParserAtnError>

Source

pub fn add_transition( &mut self, source: usize, transition: ParserTransitionSpec, ) -> Result<TransitionId, ParserAtnError>

Source

pub fn set_rule_to_start_state( &mut self, states: Vec<usize>, ) -> Result<(), ParserAtnError>

Source

pub fn set_rule_to_stop_state( &mut self, states: Vec<usize>, ) -> Result<(), ParserAtnError>

Source

pub fn add_decision_state(&mut self, state: usize) -> Result<(), ParserAtnError>

Source

pub fn state_kind(&self, state: usize) -> Option<AtnStateKind>

Source

pub const fn state_count(&self) -> usize

Source

pub fn state_rule_index(&self, state: usize) -> Option<usize>

Source

pub fn rule_stop_state(&self, rule: usize) -> Option<usize>

Source

pub fn transitions_from( &self, source: usize, ) -> impl DoubleEndedIterator<Item = ParserTransitionSpec> + '_

Source

pub fn finish(self) -> Result<ParserAtn, ParserAtnError>

Trait Implementations§

Source§

impl Debug for ParserAtnBuilder

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.