pub enum PredictionContext {
Empty,
Singleton {
parent: Rc<Self>,
return_state: usize,
},
Array {
parents: Vec<Rc<Self>>,
return_states: Vec<usize>,
},
}Variants§
Implementations§
Source§impl PredictionContext
impl PredictionContext
pub fn empty() -> Rc<Self>
pub fn singleton(parent: Rc<Self>, return_state: usize) -> Rc<Self>
pub const fn len(&self) -> usize
pub const fn is_empty(&self) -> bool
pub fn return_state(&self, index: usize) -> Option<usize>
pub fn parent(&self, index: usize) -> Option<Rc<Self>>
Sourcepub fn merge(left: Rc<Self>, right: Rc<Self>) -> Rc<Self>
pub fn merge(left: Rc<Self>, right: Rc<Self>) -> Rc<Self>
Merges two prediction contexts while preserving deterministic entry order.
This is a compact baseline for parser ATN work: equal contexts are reused directly, and unequal singleton/array contexts are flattened into a deduplicated array context.
Trait Implementations§
Source§impl Clone for PredictionContext
impl Clone for PredictionContext
Source§fn clone(&self) -> PredictionContext
fn clone(&self) -> PredictionContext
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PredictionContext
impl Debug for PredictionContext
Source§impl Hash for PredictionContext
impl Hash for PredictionContext
Source§impl Ord for PredictionContext
impl Ord for PredictionContext
Source§fn cmp(&self, other: &PredictionContext) -> Ordering
fn cmp(&self, other: &PredictionContext) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for PredictionContext
impl PartialEq for PredictionContext
Source§fn eq(&self, other: &PredictionContext) -> bool
fn eq(&self, other: &PredictionContext) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for PredictionContext
impl PartialOrd for PredictionContext
impl Eq for PredictionContext
impl StructuralPartialEq for PredictionContext
Auto Trait Implementations§
impl Freeze for PredictionContext
impl RefUnwindSafe for PredictionContext
impl !Send for PredictionContext
impl !Sync for PredictionContext
impl Unpin for PredictionContext
impl UnsafeUnpin for PredictionContext
impl UnwindSafe for PredictionContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more