pub struct Atn { /* private fields */ }Expand description
Deserialized ANTLR Abstract Transition Network.
The structure keeps the state graph plus ANTLR side tables such as rule-to-start, rule-to-token, mode-to-start, decisions, and lexer actions. The side tables are part of the runtime contract because generated grammars should only need to provide metadata; simulation stays in this crate.
Implementations§
Source§impl Atn
impl Atn
Sourcepub const fn new(grammar_type: AtnType, max_token_type: i32) -> Self
pub const fn new(grammar_type: AtnType, max_token_type: i32) -> Self
Creates an empty ATN with the grammar kind and maximum token type read from the serialized header.
pub const fn grammar_type(&self) -> AtnType
pub const fn max_token_type(&self) -> i32
pub fn states(&self) -> &[AtnState]
pub fn state(&self, state_number: usize) -> Option<&AtnState>
pub fn state_mut(&mut self, state_number: usize) -> Option<&mut AtnState>
Sourcepub fn add_state(&mut self, state: AtnState) -> usize
pub fn add_state(&mut self, state: AtnState) -> usize
Appends a state and returns the state number assigned by insertion order.
pub fn decision_to_state(&self) -> &[usize]
pub fn add_decision_state(&mut self, state_number: usize)
pub fn rule_to_start_state(&self) -> &[usize]
pub fn set_rule_to_start_state(&mut self, rule_to_start_state: Vec<usize>)
pub fn rule_to_stop_state(&self) -> &[usize]
pub fn set_rule_to_stop_state(&mut self, rule_to_stop_state: Vec<usize>)
pub fn rule_to_token_type(&self) -> &[i32]
pub fn set_rule_to_token_type(&mut self, rule_to_token_type: Vec<i32>)
pub fn mode_to_start_state(&self) -> &[usize]
pub fn add_mode_start_state(&mut self, state_number: usize)
pub fn lexer_actions(&self) -> &[LexerAction]
pub fn set_lexer_actions(&mut self, lexer_actions: Vec<LexerAction>)
Trait Implementations§
impl Eq for Atn
impl StructuralPartialEq for Atn
Auto Trait Implementations§
impl Freeze for Atn
impl RefUnwindSafe for Atn
impl Send for Atn
impl Sync for Atn
impl Unpin for Atn
impl UnsafeUnpin for Atn
impl UnwindSafe for Atn
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