Class: Antlr4::Runtime::DFAState

Inherits:
Object
  • Object
show all
Defined in:
lib/antlr4/runtime/dfa_state.rb

Defined Under Namespace

Classes: PredPrediction

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x = nil) ⇒ DFAState


19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/antlr4/runtime/dfa_state.rb', line 19

def initialize(x = nil)
  @is_accept_state = false
  @edges = []
  @state_number = -1

  if x.nil?
    @configs = ATNConfigSet.new
  elsif x.is_a?(ATNConfigSet)
    @configs = x
  else
    @state_number = x
  end
end

Instance Attribute Details

#configsObject

Returns the value of attribute configs


5
6
7
# File 'lib/antlr4/runtime/dfa_state.rb', line 5

def configs
  @configs
end

#edgesObject

Returns the value of attribute edges


7
8
9
# File 'lib/antlr4/runtime/dfa_state.rb', line 7

def edges
  @edges
end

#is_accept_stateObject

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_executorObject

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

#predicatesObject

Returns the value of attribute predicates


17
18
19
# File 'lib/antlr4/runtime/dfa_state.rb', line 17

def predicates
  @predicates
end

#predictionObject

Returns the value of attribute prediction


11
12
13
# File 'lib/antlr4/runtime/dfa_state.rb', line 11

def prediction
  @prediction
end

#requires_full_contextObject

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_numberObject

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_setObject


55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/antlr4/runtime/dfa_state.rb', line 55

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


85
86
87
88
89
90
# File 'lib/antlr4/runtime/dfa_state.rb', line 85

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

#hashObject


70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/antlr4/runtime/dfa_state.rb', line 70

def hash
  return @_hash unless @_hash.nil?

  hash_code = MurmurHash.hash_int(configs.hash)

  if !@_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


51
52
53
# File 'lib/antlr4/runtime/dfa_state.rb', line 51

def initialize_configs(configs)
  @configs = configs
end

#initialize_state_number(stateNumber) ⇒ Object


47
48
49
# File 'lib/antlr4/runtime/dfa_state.rb', line 47

def initialize_state_number(stateNumber)
  @state_number = stateNumber
end

#to_sObject


92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/antlr4/runtime/dfa_state.rb', line 92

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