Skip to main content

ParserAtnSimulator

Struct ParserAtnSimulator 

Source
pub struct ParserAtnSimulator<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> ParserAtnSimulator<'a>

Source

pub fn new(atn: &'a Atn) -> Self

Source

pub const fn set_exact_ambig_detection(&mut self, exact: bool)

Switches the full-context resolution strategy (Java’s LL_EXACT_AMBIG_DETECTION versus plain LL).

Source

pub fn dump_dfa_java_style(&self, vocabulary: &Vocabulary) -> String

Creates a simulator that starts from, and publishes back into, a thread-local DFA cache keyed by a generated parser’s static ATN.

Generated parsers usually create a fresh parser object per parse. Without this cache every parse relearns the same adaptive DFA; with it, later parser instances reuse the SLL cache learned by earlier instances while still keeping mutable simulator state local to the parser during a parse.

The DFAs are checked OUT of the cache by move (and back in on drop): cloning a warm DFA per parser instance costs O(learned states) — ~10% of a small parse. A second simulator created for the same ATN while one is alive finds the slot empty and starts cold; the drop-time check-in then keeps whichever tables learned more. Renders every non-empty learned decision DFA in the format of Java’s Parser.dumpDFA() / DFASerializerDecision N: headers followed by s0-'else'->:s1^=>1 edge lines — which the runtime testsuite’s showDFA descriptors byte-compare.

Source

pub fn new_shared(atn: &'static Atn) -> Self

Source

pub fn decision_dfas(&self) -> &[Dfa]

Source

pub fn adaptive_predict( &mut self, decision: usize, lookahead: impl IntoIterator<Item = i32>, ) -> Result<usize, ParserAtnSimulatorError>

Source

pub fn adaptive_predict_stream<T: IntStream>( &mut self, decision: usize, input: &mut T, ) -> Result<usize, ParserAtnSimulatorError>

Source

pub fn adaptive_predict_stream_with_precedence<T: IntStream>( &mut self, decision: usize, precedence: usize, input: &mut T, ) -> Result<usize, ParserAtnSimulatorError>

Source

pub fn adaptive_predict_stream_info_with_precedence<T: IntStream>( &mut self, decision: usize, precedence: usize, input: &mut T, ) -> Result<ParserAtnPrediction, ParserAtnSimulatorError>

Source

pub fn adaptive_predict_stream_info_sll_probe<T: IntStream>( &mut self, decision: usize, precedence: usize, input: &mut T, ) -> Result<ParserAtnPrediction, ParserAtnSimulatorError>

SLL-probe variant of Self::adaptive_predict_stream_info_with_precedence.

Identical to the precedence entry except that, when the SLL walk reaches a conflict state requiring full context, it returns the SLL prediction (carrying requires_full_context = true) WITHOUT running the full-context LL loop. The generated two-stage prediction calls this for stage 1 and only consults requires_full_context to decide whether to re-run with the real outer context, so the empty-context LL pass this skips would be discarded anyway. Avoids the double LL pass per escalation.

Source

pub fn adaptive_predict_stream_info_with_context<T: IntStream>( &mut self, decision: usize, precedence: usize, input: &mut T, outer_context: &Rc<PredictionContext>, ) -> Result<ParserAtnPrediction, ParserAtnSimulatorError>

Source

pub fn adaptive_predict_with_precedence( &mut self, decision: usize, precedence: usize, lookahead: impl IntoIterator<Item = i32>, ) -> Result<usize, ParserAtnSimulatorError>

Source

pub fn adaptive_predict_info_with_precedence( &mut self, decision: usize, precedence: usize, lookahead: impl IntoIterator<Item = i32>, ) -> Result<ParserAtnPrediction, ParserAtnSimulatorError>

Trait Implementations§

Source§

impl<'a> Debug for ParserAtnSimulator<'a>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for ParserAtnSimulator<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for ParserAtnSimulator<'a>

§

impl<'a> !Send for ParserAtnSimulator<'a>

§

impl<'a> !Sync for ParserAtnSimulator<'a>

§

impl<'a> !UnwindSafe for ParserAtnSimulator<'a>

§

impl<'a> Freeze for ParserAtnSimulator<'a>

§

impl<'a> Unpin for ParserAtnSimulator<'a>

§

impl<'a> UnsafeUnpin for ParserAtnSimulator<'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.