[][src]Struct antlr_rust::atn::ATN

pub struct ATN {
    pub decision_to_state: Vec<ATNStateRef>,
    pub grammar_type: ATNType,
    pub max_token_type: isize,
    pub mode_name_to_start_state: HashMap<String, ATNStateRef>,
    pub mode_to_start_state: Vec<ATNStateRef>,
    pub rule_to_start_state: Vec<ATNStateRef>,
    pub rule_to_stop_state: Vec<ATNStateRef>,
    pub rule_to_token_type: Vec<isize>,
    pub states: Vec<Box<dyn ATNState>>,
    // some fields omitted
}

Fields

decision_to_state: Vec<ATNStateRef>grammar_type: ATNTypemax_token_type: isizemode_name_to_start_state: HashMap<String, ATNStateRef>mode_to_start_state: Vec<ATNStateRef>rule_to_start_state: Vec<ATNStateRef>rule_to_stop_state: Vec<ATNStateRef>rule_to_token_type: Vec<isize>states: Vec<Box<dyn ATNState>>

Methods

impl ATN[src]

pub fn new_atn(grammar_type: ATNType, max_token_type: isize) -> ATN[src]

pub fn next_tokens<'a>(&self, s: &'a dyn ATNState) -> &'a IntervalSet[src]

Compute the set of valid tokens that can occur starting in s and staying in same rule. Token::EPSILON is in set if we reach end of rule.

pub fn next_tokens_in_ctx(
    &self,
    s: &dyn ATNState,
    _ctx: Option<&dyn ParserRuleContext>
) -> IntervalSet
[src]

Compute the set of valid tokens that can occur starting in state s. If ctx is null, the set of tokens will not include what can follow the rule surrounding s. In other words, the set will be restricted to tokens reachable staying within s's rule.

pub fn get_decision_state(&self, decision: usize) -> ATNStateRef[src]

pub fn get_expected_tokens(
    &self,
    state_number: isize,
    _ctx: &Rc<dyn ParserRuleContext>
) -> IntervalSet
[src]

Computes the set of input symbols which could follow ATN state number {@code stateNumber} in the specified full {@code context}. This method considers the complete parser context, but does not evaluate semantic predicates (i.e. all predicates encountered during the calculation are assumed true). If a path in the ATN exists from the starting state to the {@link RuleStopState} of the outermost context without matching any symbols, {@link Token#EOF} is added to the returned set.

If {@code context} is {@code null}, it is treated as {@link ParserRuleContext#EMPTY}.

Note that this does NOT give you the set of all tokens that could appear at a given token position in the input phrase. In other words, it does not answer:

"Given a specific partial input phrase, return the set of all tokens that can follow the last token in the input phrase."

The big difference is that with just the input, the parser could land right in the middle of a lookahead decision. Getting all possible tokens given a partial input stream is a separate computation. See https://github.com/antlr/antlr4/issues/1428

For this function, we are specifying an ATN state and call stack to compute what token(s) can come next and specifically: outside of a lookahead decision. That is what you want for error reporting and recovery upon parse error.

@param stateNumber the ATN state number @param context the full parse context @return The set of potentially valid input symbols which could follow the specified state in the specified context. @throws IllegalArgumentException if the ATN does not contain a state with number {@code stateNumber}

Auto Trait Implementations

impl !RefUnwindSafe for ATN

impl Send for ATN

impl Sync for ATN

impl Unpin for ATN

impl !UnwindSafe for ATN

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.