Class: Wallace::Koza::NonTerminal

Inherits:
KozaNodeValue show all
Defined in:
lib/modules/koza/koza_node_value.rb

Overview

Holds an option from the non-terminal set.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label, arity, function) ⇒ NonTerminal

Constructs a non-terminal.

Parameters:

  • label, the label of the non-terminal.

  • arity, the number of inputs to the non-terminal.

  • function, the function object for this non-terminal.



58
59
60
61
62
# File 'lib/modules/koza/koza_node_value.rb', line 58

def initialize(label, arity, function)
  @label = label
  @arity = arity
  @function = function
end

Instance Attribute Details

#arityObject (readonly)

Returns the value of attribute arity.



48
49
50
# File 'lib/modules/koza/koza_node_value.rb', line 48

def arity
  @arity
end

#functionObject (readonly)

Returns the value of attribute function.



48
49
50
# File 'lib/modules/koza/koza_node_value.rb', line 48

def function
  @function
end

#labelObject (readonly)

Returns the value of attribute label.



48
49
50
# File 'lib/modules/koza/koza_node_value.rb', line 48

def label
  @label
end

Instance Method Details

#eval(inputs) ⇒ Object

Evaluates this non-terminal.

Parameters:

  • inputs, the input values to this non-terminal function.



68
69
70
# File 'lib/modules/koza/koza_node_value.rb', line 68

def eval(inputs)
  @function.call(*inputs)
end