class Antlr4::Runtime::ATNState

Constants

BASIC
BLOCK_END
BLOCK_START
INITIAL_NUM_TRANSITIONS
INVALID_TYPE
LOOP_END
PLUS_BLOCK_START
PLUS_LOOP_BACK
RULE_START
RULE_STOP
STAR_BLOCK_START
STAR_LOOP_BACK
STAR_LOOP_ENTRY
TOKEN_START

Attributes

invalid_state_number[RW]
atn[RW]
next_token_within_rule[RW]
rule_index[RW]
state_number[RW]
transitions[R]

Public Class Methods

new() click to toggle source
# File lib/antlr4/runtime/atn_state.rb, line 32
def initialize
  @atn = nil
  @state_number = @@invalid_state_number
  @rule_index = 0
  @epsilon_only_transitions = false
  @transitions = []
  @next_token_within_rule = nil
end

Public Instance Methods

add_transition(e) click to toggle source
# File lib/antlr4/runtime/atn_state.rb, line 63
def add_transition(e)
  add_transition_at(@transitions.length, e)
end
add_transition_at(index, e) click to toggle source
# File lib/antlr4/runtime/atn_state.rb, line 67
def add_transition_at(index, e)
  if @transitions.empty?

    @epsilon_only_transitions = e.epsilon?

  elsif @epsilon_only_transitions != e.epsilon?

    STDERR.puts format("ATN state %d has both epsilon and non-epsilon transitions.\n", state_number)
    @epsilon_only_transitions = false
  end
  already_present = false

  i = 0
  while i < @transitions.length
    t = @transitions[i]
    if t.target.state_number == e.target.state_number

      if !t.label.nil? && !e.label.nil? && t.label.eql?(e.label)
        already_present = true
        break
      elsif t.epsilon? && e.epsilon?
        already_present = true
        break
      end
    end
    i += 1
  end

  @transitions[index] = e unless already_present
end
eql?(other_key) click to toggle source
# File lib/antlr4/runtime/atn_state.rb, line 45
def eql?(other_key)
  @state_number == other_key.state_number
end
hash() click to toggle source
# File lib/antlr4/runtime/atn_state.rb, line 41
def hash
  @state_number
end
non_greedy_exit_state?() click to toggle source
# File lib/antlr4/runtime/atn_state.rb, line 49
def non_greedy_exit_state?
  false
end
number_of_transitions() click to toggle source
# File lib/antlr4/runtime/atn_state.rb, line 59
def number_of_transitions
  @transitions.length
end
only_has_epsilon_transitions() click to toggle source
# File lib/antlr4/runtime/atn_state.rb, line 110
def only_has_epsilon_transitions
  @epsilon_only_transitions
end
remove_transition(index) click to toggle source
# File lib/antlr4/runtime/atn_state.rb, line 106
def remove_transition(index)
  @transitions.delete_at index
end
set_rule_index(rule_index) click to toggle source
# File lib/antlr4/runtime/atn_state.rb, line 114
def set_rule_index(rule_index)
  @rule_index = rule_index
end
set_transition(i, e) click to toggle source
# File lib/antlr4/runtime/atn_state.rb, line 102
def set_transition(i, e)
  @transitions[i] = e
end
to_s() click to toggle source
# File lib/antlr4/runtime/atn_state.rb, line 53
def to_s
  @state_number.to_s
end
transition(i) click to toggle source
# File lib/antlr4/runtime/atn_state.rb, line 98
def transition(i)
  @transitions[i]
end