Class: Antlr4ruby::ATNState
Abstract
- Inherits:
-
Object
- Object
- Antlr4ruby::ATNState
show all
- Defined in:
- lib/antlr4ruby/atn/state/atn_state.rb
Overview
Constant Summary
collapse
- INITIAL_NUM_TRANSITIONS =
4
- INVALID_TYPE =
0
- BASIC =
1
- RULE_START =
2
- BLOCK_START =
3
- PLUS_BLOCK_START =
4
- STAR_BLOCK_START =
5
- TOKEN_START =
6
- RULE_STOP =
7
- BLOCK_END =
8
- STAR_LOOP_BACK =
9
- STAR_LOOP_ENTRY =
10
- PLUS_LOOP_BACK =
11
- LOOP_END =
12
- INVALID_STATE_NUMBER =
-1
- @@serialization_names =
%w[INVALID BASIC RULE_START BLOCK_START PLUS_BLOCK_START STAR_BLOCK_START TOKEN_START RULE_STOP BLOCK_END STAR_LOOP_BACK STAR_LOOP_ENTRY PLUS_LOOP_BACK LOOP_END]
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
34
35
36
37
|
# File 'lib/antlr4ruby/atn/state/atn_state.rb', line 34
def initialize
@atn, @state_number, @rule_index, @epsilon_only_transitions, @transitions, @next_token_within_rule =
nil, INVALID_STATE_NUMBER, 0, false, [], RangeSet.new
end
|
Instance Attribute Details
#atn ⇒ Object
Returns the value of attribute atn.
32
33
34
|
# File 'lib/antlr4ruby/atn/state/atn_state.rb', line 32
def atn
@atn
end
|
#epsilon_only_transitions ⇒ Object
Returns the value of attribute epsilon_only_transitions.
32
33
34
|
# File 'lib/antlr4ruby/atn/state/atn_state.rb', line 32
def epsilon_only_transitions
@epsilon_only_transitions
end
|
#next_token_within_rule ⇒ Object
Returns the value of attribute next_token_within_rule.
32
33
34
|
# File 'lib/antlr4ruby/atn/state/atn_state.rb', line 32
def next_token_within_rule
@next_token_within_rule
end
|
#rule_index ⇒ Object
Returns the value of attribute rule_index.
32
33
34
|
# File 'lib/antlr4ruby/atn/state/atn_state.rb', line 32
def rule_index
@rule_index
end
|
#state_number ⇒ Object
Returns the value of attribute state_number.
32
33
34
|
# File 'lib/antlr4ruby/atn/state/atn_state.rb', line 32
def state_number
@state_number
end
|
Instance Method Details
#add_transition(transition, index = transitions.length) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/antlr4ruby/atn/state/atn_state.rb', line 47
def add_transition(transition, index = transitions.length)
if transitions.empty?
@epsilon_only_transitions = transition.is_epsilon?
elsif epsilon_only_transitions != transition.is_epsilon?
p "ATN state #{state_number} has both epsilon and non-epsilon transitions."
@epsilon_only_transitions = false
end
already_present = false
transitions.each do |t|
if t.target.state_number == transition.target.state_number
if t.label && transition.label && t.label.eql?(transition.label)
already_present = true
break
elsif t.is_epsilon? && transition.is_epsilon?
already_present = true
break
end
end
end
transitions[index] = transition unless already_present
end
|
#eql?(other) ⇒ Boolean
98
99
100
101
|
# File 'lib/antlr4ruby/atn/state/atn_state.rb', line 98
def eql?(other)
return false unless other.instance_of?(ATNState)
@state_number == other.state_number
end
|
#get_number_of_transitions ⇒ Object
43
44
45
|
# File 'lib/antlr4ruby/atn/state/atn_state.rb', line 43
def get_number_of_transitions
transitions.length
end
|
#get_state_type ⇒ Object
39
40
41
|
# File 'lib/antlr4ruby/atn/state/atn_state.rb', line 39
def get_state_type
raise NotImplementedError.new("#{self.class.name}#get_state_type is abstract method")
end
|
#get_transition(i) ⇒ Object
71
72
73
|
# File 'lib/antlr4ruby/atn/state/atn_state.rb', line 71
def get_transition(i)
transitions[i]
end
|
#hash ⇒ Object
94
95
96
|
# File 'lib/antlr4ruby/atn/state/atn_state.rb', line 94
def hash
@state_number
end
|
#only_has_epsilon_transitions? ⇒ Boolean
85
86
87
|
# File 'lib/antlr4ruby/atn/state/atn_state.rb', line 85
def only_has_epsilon_transitions?
@epsilon_only_transitions
end
|
#remove_transition(i) ⇒ Object
79
80
81
82
83
|
# File 'lib/antlr4ruby/atn/state/atn_state.rb', line 79
def remove_transition(i)
result = transitions[i]
transitions.delete_at(i)
result
end
|
#set_rule_index(rule_index) ⇒ Object
89
90
91
|
# File 'lib/antlr4ruby/atn/state/atn_state.rb', line 89
def set_rule_index(rule_index)
@rule_index = rule_index
end
|
#set_transition(i, transition) ⇒ Object
75
76
77
|
# File 'lib/antlr4ruby/atn/state/atn_state.rb', line 75
def set_transition(i, transition)
transitions[i] = transition
end
|
#to_s ⇒ Object
103
104
105
|
# File 'lib/antlr4ruby/atn/state/atn_state.rb', line 103
def to_s
state_number.to_s
end
|