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

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Node representing alternation between two nodes.

Generates options from either node1 or node2. Created by Node#or or | operator.

Instance Method Summary collapse

Constructor Details

#initialize(node1, node2) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • node1 (Node)

    first alternative

  • node2 (Node)

    second alternative



598
599
600
601
602
# File 'lib/musa-dsl/generative/generative-grammar.rb', line 598

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

Instance Method Details

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
# File 'lib/musa-dsl/generative/generative-grammar.rb', line 605

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