Method: Kleene::DSL#union
- Defined in:
- lib/kleene/dsl.rb
#union(*nfas) ⇒ Object
Build a new machine consisting of a new start state with epsilon transitions to the start state of all the given NFAs in ‘nfas`. The resulting machine’s final states are the set of final states from all the NFAs in ‘nfas`.
Implements Union, as defined in the Ragel manual in section 2.5.1 of www.colm.net/files/ragel/ragel-guide-6.10.pdf: The union operation produces a machine that matches any string in machine one or machine two. The operation first creates a new start state. Epsilon transitions are drawn from the new start state to the start states of both input machines. The resulting machine has a final state setequivalent to the union of the final state sets of both input machines.
172 173 174 175 176 |
# File 'lib/kleene/dsl.rb', line 172 def union(*nfas) nfas.flatten! nfas = nfas.map(&:deep_clone) union!(nfas) end |