Class: Calyx::Production::NonTerminal
- Inherits:
-
Object
- Object
- Calyx::Production::NonTerminal
- Defined in:
- lib/calyx/production/non_terminal.rb
Overview
A type of production rule that represents a non-terminal expansion, linking one rule to another.
Instance Method Summary collapse
-
#evaluate(random) ⇒ Array
Evaluate the non-terminal, using the registry to handle the expansion.
-
#initialize(symbol, registry) ⇒ NonTerminal
constructor
Construct a non-terminal node, given the symbol to lookup and the registry to look it up in.
Constructor Details
#initialize(symbol, registry) ⇒ NonTerminal
Construct a non-terminal node, given the symbol to lookup and the registry to look it up in.
11 12 13 14 |
# File 'lib/calyx/production/non_terminal.rb', line 11 def initialize(symbol, registry) @symbol = symbol.to_sym @registry = registry end |
Instance Method Details
#evaluate(random) ⇒ Array
Evaluate the non-terminal, using the registry to handle the expansion.
20 21 22 |
# File 'lib/calyx/production/non_terminal.rb', line 20 def evaluate(random) [@symbol, @registry.(@symbol).evaluate(random)] end |