Class: Stamina::Automaton::Determinize::CompoundState

Inherits:
Object
  • Object
show all
Defined in:
lib/stamina-core/stamina/automaton/determinize.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fa, states, initial = false) ⇒ CompoundState

Returns a new instance of CompoundState.



11
12
13
14
15
# File 'lib/stamina-core/stamina/automaton/determinize.rb', line 11

def initialize(fa, states, initial = false)
  @fa = fa
  @states = states.sort
  @initial = initial
end

Instance Attribute Details

#faObject (readonly)

Returns the value of attribute fa.



7
8
9
# File 'lib/stamina-core/stamina/automaton/determinize.rb', line 7

def fa
  @fa
end

#initialObject (readonly)

Returns the value of attribute initial.



9
10
11
# File 'lib/stamina-core/stamina/automaton/determinize.rb', line 9

def initial
  @initial
end

#statesObject (readonly)

Returns the value of attribute states.



8
9
10
# File 'lib/stamina-core/stamina/automaton/determinize.rb', line 8

def states
  @states
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



39
40
41
42
43
# File 'lib/stamina-core/stamina/automaton/determinize.rb', line 39

def ==(other)
  other.is_a?(CompoundState) &&
  (other.fa == self.fa) &&
  (other.states == self.states)
end

#delta(symbol) ⇒ Object



31
32
33
# File 'lib/stamina-core/stamina/automaton/determinize.rb', line 31

def delta(symbol)
  CompoundState.new(fa, fa.delta(states, symbol))
end

#empty?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/stamina-core/stamina/automaton/determinize.rb', line 17

def empty?
  states.empty?
end

#hashObject



35
36
37
# File 'lib/stamina-core/stamina/automaton/determinize.rb', line 35

def hash
  @states.hash
end

#marksObject



21
22
23
24
25
26
27
28
29
# File 'lib/stamina-core/stamina/automaton/determinize.rb', line 21

def marks
  @marks ||= begin
    marks = {}
    marks[:initial] = initial
    marks[:accepting] = states.any?{|s| s.accepting?}
    marks[:error] = states.any?{|s| s.error?}
    marks
  end
end