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(rng) ⇒ Array

Evaluate the non-terminal, using the registry to handle the expansion.

Returns:

  • (Array)


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

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