Module: Stamina::RegLang::Alternative

Includes:
Node
Defined in:
lib/stamina-induction/stamina/reg_lang/parser/alternative.rb

Instance Method Summary collapse

Methods included from Node

#to_cdfa, #to_dfa, #to_fa

Instance Method Details

#to_fa!(fa) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/stamina-induction/stamina/reg_lang/parser/alternative.rb', line 6

def to_fa!(fa)
  from, to = fa.add_n_states(2)
  f1, t1 = self.head.to_fa!(fa)
  f2, t2 = self.tail.to_fa!(fa)
  fa.connect(from, f1, nil)
  fa.connect(from, f2, nil)
  fa.connect(t1, to, nil)
  fa.connect(t2, to, nil)
  [from, to]
end