class Calyx::Syntax::Memo

A type of production rule representing a memoized subsitution which returns the first value selected on all subsequent lookups.

Constants

SIGIL

Public Class Methods

new(symbol, registry) click to toggle source

Construct a memoized rule, given the symbol to lookup and the registry to look it up in.

@param [Symbol] symbol @param [Calyx::Registry] registry

# File lib/calyx/syntax/memo.rb, line 13
def initialize(symbol, registry)
  @symbol = symbol.slice(1, symbol.length-1).to_sym
  @registry = registry
end

Public Instance Methods

evaluate(options) click to toggle source

Evaluate the memo, using the registry to handle the expansion.

@param [Calyx::Options] options @return [Array]

# File lib/calyx/syntax/memo.rb, line 22
def evaluate(options)
  [@symbol, @registry.memoize_expansion(@symbol)]
end