class Antlr4::Runtime::ATN
Constants
- INVALID_ALT_NUMBER
Attributes
_a[RW]
decision_to_state[RW]
grammar_type[RW]
max_token_type[RW]
mode_name_to_start_state[RW]
mode_to_start_state[RW]
rule_to_start_state[RW]
rule_to_stop_state[RW]
rule_to_token_type[RW]
states[RW]
Public Class Methods
new(grammar_type, max_token_type)
click to toggle source
# File lib/antlr4/runtime/atn.rb, line 20 def initialize(grammar_type, max_token_type) @states = [] @decision_to_state = [] @rule_to_start_state = [] @rule_to_stop_state = [] @mode_name_to_start_state = {} @grammar_type = grammar_type @max_token_type = max_token_type @rule_to_token_type = [] @_a = [] @mode_to_start_state = [] end
Public Instance Methods
add_state(state)
click to toggle source
# File lib/antlr4/runtime/atn.rb, line 45 def add_state(state) unless state.nil? state.atn = self state.state_number = @states.length end @states << state end
decision_state(decision)
click to toggle source
# File lib/antlr4/runtime/atn.rb, line 63 def decision_state(decision) @decision_to_state[decision] unless @decision_to_state.empty? end
define_decision_state(s)
click to toggle source
# File lib/antlr4/runtime/atn.rb, line 58 def define_decision_state(s) @decision_to_state << s s.decision = @decision_to_state.length - 1 end
expected_tokens(state_number, context)
click to toggle source
# File lib/antlr4/runtime/atn.rb, line 71 def expected_tokens(state_number, context) if state_number < 0 || state_number >= @states.length raise IllegalArgumentException, 'Invalid state number.' end ctx = context s = @states[state_number] following = next_tokens(s) return following unless following.contains(Token::EPSILON) expected = IntervalSet.new expected.add_all(following) expected.remove(Token::EPSILON) while !ctx.nil? && ctx.invoking_state >= 0 && following.contains(Token::EPSILON) invoking_state = @states[ctx.invoking_state] rt = invoking_state.transition(0) following = next_tokens(rt.follow_state) expected.add_all(following) expected.remove(Token::EPSILON) ctx = ctx.parent end expected << Token::EOF if following.contains(Token::EPSILON) expected end
next_tokens(s)
click to toggle source
# File lib/antlr4/runtime/atn.rb, line 37 def next_tokens(s) return s.next_token_within_rule unless s.next_token_within_rule.nil? s.next_token_within_rule = next_tokens_ctx(s, nil) s.next_token_within_rule.readonly(true) s.next_token_within_rule end
next_tokens_ctx(s, ctx)
click to toggle source
# File lib/antlr4/runtime/atn.rb, line 33 def next_tokens_ctx(s, ctx) LL1Analyzer.new(self).look(s, nil, ctx) end
number_of_decisions()
click to toggle source
# File lib/antlr4/runtime/atn.rb, line 67 def number_of_decisions @decision_to_state.length end
remove_state(state)
click to toggle source
# File lib/antlr4/runtime/atn.rb, line 54 def remove_state(state) @states[state.state_number] = nil end