Class: Hoozuki::Node::Concatenation
- Inherits:
-
Object
- Object
- Hoozuki::Node::Concatenation
- Defined in:
- lib/hoozuki/node/concatenation.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
Instance Method Summary collapse
-
#initialize(children) ⇒ Concatenation
constructor
A new instance of Concatenation.
- #to_nfa(state) ⇒ Object
Constructor Details
#initialize(children) ⇒ Concatenation
Returns a new instance of Concatenation.
8 9 10 |
# File 'lib/hoozuki/node/concatenation.rb', line 8 def initialize(children) @children = children end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
6 7 8 |
# File 'lib/hoozuki/node/concatenation.rb', line 6 def children @children end |
Instance Method Details
#to_nfa(state) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/hoozuki/node/concatenation.rb', line 12 def to_nfa(state) nfas = @children.map { |child| child.to_nfa(state) } nfa = nfas.first nfas.drop(1).each do |next_nfa| nfa.merge_transitions(next_nfa) nfa.accept.each do |accept_state| nfa.add_epsilon_transition(accept_state, next_nfa.start) end nfa.accept = next_nfa.accept end nfa end |