Class: Antlr4::Runtime::DFAState
- Inherits:
-
Object
- Object
- Antlr4::Runtime::DFAState
- Defined in:
- lib/antlr4/runtime/dfa_state.rb
Defined Under Namespace
Classes: PredPrediction
Instance Attribute Summary collapse
-
#configs ⇒ Object
Returns the value of attribute configs.
-
#edges ⇒ Object
Returns the value of attribute edges.
-
#is_accept_state ⇒ Object
Returns the value of attribute is_accept_state.
-
#lexer_action_executor ⇒ Object
Returns the value of attribute lexer_action_executor.
-
#predicates ⇒ Object
Returns the value of attribute predicates.
-
#prediction ⇒ Object
Returns the value of attribute prediction.
-
#requires_full_context ⇒ Object
Returns the value of attribute requires_full_context.
-
#state_number ⇒ Object
Returns the value of attribute state_number.
Instance Method Summary collapse
- #alt_set ⇒ Object
-
#equals?(o) ⇒ Boolean
compare set of ATN configurations in this set with other.
- #hash ⇒ Object
-
#initialize(x = nil) ⇒ DFAState
constructor
A new instance of DFAState.
- #initialize_configs(configs) ⇒ Object
- #initialize_state_number(stateNumber) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(x = nil) ⇒ DFAState
Returns a new instance of DFAState.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/antlr4/runtime/dfa_state.rb', line 19 def initialize(x = nil) @is_accept_state = false @edges = [] @state_number = -1 @_hash = nil if x.nil? @configs = ATNConfigSet.new elsif x.is_a?(ATNConfigSet) @configs = x else @state_number = x end end |
Instance Attribute Details
#configs ⇒ Object
Returns the value of attribute configs.
5 6 7 |
# File 'lib/antlr4/runtime/dfa_state.rb', line 5 def configs @configs end |
#edges ⇒ Object
Returns the value of attribute edges.
7 8 9 |
# File 'lib/antlr4/runtime/dfa_state.rb', line 7 def edges @edges end |
#is_accept_state ⇒ Object
Returns the value of attribute is_accept_state.
9 10 11 |
# File 'lib/antlr4/runtime/dfa_state.rb', line 9 def is_accept_state @is_accept_state end |
#lexer_action_executor ⇒ Object
Returns the value of attribute lexer_action_executor.
13 14 15 |
# File 'lib/antlr4/runtime/dfa_state.rb', line 13 def lexer_action_executor @lexer_action_executor end |
#predicates ⇒ Object
Returns the value of attribute predicates.
17 18 19 |
# File 'lib/antlr4/runtime/dfa_state.rb', line 17 def predicates @predicates end |
#prediction ⇒ Object
Returns the value of attribute prediction.
11 12 13 |
# File 'lib/antlr4/runtime/dfa_state.rb', line 11 def prediction @prediction end |
#requires_full_context ⇒ Object
Returns the value of attribute requires_full_context.
15 16 17 |
# File 'lib/antlr4/runtime/dfa_state.rb', line 15 def requires_full_context @requires_full_context end |
#state_number ⇒ Object
Returns the value of attribute state_number.
3 4 5 |
# File 'lib/antlr4/runtime/dfa_state.rb', line 3 def state_number @state_number end |
Instance Method Details
#alt_set ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/antlr4/runtime/dfa_state.rb', line 56 def alt_set alts = Set.new unless @configs.nil? i = 0 while i < @configs.length c = @configs[i] alts.add(c.alt) i += 1 end end return nil if alts.empty? alts end |
#equals?(o) ⇒ Boolean
compare set of ATN configurations in this set with other
87 88 89 90 91 92 |
# File 'lib/antlr4/runtime/dfa_state.rb', line 87 def equals?(o) # compare set of ATN configurations in this set with other return true if self == o return false unless o.is_a? DFAState @configs.eql?(o.configs) end |
#hash ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/antlr4/runtime/dfa_state.rb', line 71 def hash return @_hash unless @_hash.nil? hash_code = RumourHash.calculate([configs.hash]) unless @_hash.nil? if hash_code == @_hash puts 'Same hash_code for DFAState' else puts 'Different hash_code for DFAState' end end @_hash = hash_code end |
#initialize_configs(configs) ⇒ Object
52 53 54 |
# File 'lib/antlr4/runtime/dfa_state.rb', line 52 def initialize_configs(configs) @configs = configs end |
#initialize_state_number(stateNumber) ⇒ Object
48 49 50 |
# File 'lib/antlr4/runtime/dfa_state.rb', line 48 def initialize_state_number(stateNumber) @state_number = stateNumber end |
#to_s ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/antlr4/runtime/dfa_state.rb', line 94 def to_s buf = '' buf << @state_number.to_s << ':' << @configs.to_s if @is_accept_state buf << '=>' buf << if !@predicates.nil? @predicates.to_s else @prediction.to_s end end buf.to_s end |