Class: Musa::GenerativeGrammar::Implementation::OrNode

Inherits:
Node
  • Object
show all
Defined in:
lib/musa-dsl/generative/generative-grammar.rb

Instance Method Summary collapse

Methods inherited from Node

#[], #limit, #next, #options, #or, #repeat, #size, #to_serie

Constructor Details

#initialize(node1, node2) ⇒ OrNode

Returns a new instance of OrNode.



211
212
213
214
215
# File 'lib/musa-dsl/generative/generative-grammar.rb', line 211

def initialize(node1, node2)
  @node1 = node1
  @node2 = node2
  super()
end

Instance Method Details

#_options(parent: nil, &condition) ⇒ Object



217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/musa-dsl/generative/generative-grammar.rb', line 217

def _options(parent: nil, &condition)
  parent ||= []

  r = []

  @node1._options(parent: parent, &condition).each do |node_option|
    r << node_option if !block_given? || yield(parent + node_option)
  end

  @node2._options(parent: parent, &condition).each do |node_option|
    r << node_option if !block_given? || yield(parent + node_option)
  end

  r
end