Class: Wallace::Koza::NonTerminal
- Inherits:
-
KozaNodeValue
- Object
- KozaNodeValue
- Wallace::Koza::NonTerminal
- Defined in:
- lib/modules/koza/koza_node_value.rb
Overview
Holds an option from the non-terminal set.
Instance Attribute Summary collapse
-
#arity ⇒ Object
readonly
Returns the value of attribute arity.
-
#function ⇒ Object
readonly
Returns the value of attribute function.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
Instance Method Summary collapse
-
#eval(inputs) ⇒ Object
Evaluates this non-terminal.
-
#initialize(label, arity, function) ⇒ NonTerminal
constructor
Constructs a non-terminal.
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
#arity ⇒ Object (readonly)
Returns the value of attribute arity.
48 49 50 |
# File 'lib/modules/koza/koza_node_value.rb', line 48 def arity @arity end |
#function ⇒ Object (readonly)
Returns the value of attribute function.
48 49 50 |
# File 'lib/modules/koza/koza_node_value.rb', line 48 def function @function end |
#label ⇒ Object (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 |