Class: Calyx::Production::NonTerminal

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(symbol, registry) ⇒ NonTerminal

Construct a non-terminal node, given the symbol to lookup and the registry to look it up in.

Parameters:



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.

Parameters:

  • random (Random)

Returns:

  • (Array)


20
21
22
# File 'lib/calyx/production/non_terminal.rb', line 20

def evaluate(random)
  [@symbol, @registry.expand(@symbol).evaluate(random)]
end