Class: Calyx::Syntax::Memo
- Inherits:
-
Object
- Object
- Calyx::Syntax::Memo
- Defined in:
- lib/calyx/syntax/memo.rb
Overview
A type of production rule representing a memoized subsitution which returns the first value selected on all subsequent lookups.
Constant Summary collapse
- SIGIL =
'@'.freeze
Instance Method Summary collapse
-
#evaluate(options) ⇒ Array
Evaluate the memo, using the registry to handle the expansion.
-
#initialize(symbol, registry) ⇒ Memo
constructor
Construct a memoized rule, given the symbol to lookup and the registry to look it up in.
Constructor Details
#initialize(symbol, registry) ⇒ Memo
Construct a memoized rule, given the symbol to lookup and the registry to look it up in.
13 14 15 16 |
# File 'lib/calyx/syntax/memo.rb', line 13 def initialize(symbol, registry) @symbol = symbol.slice(1, symbol.length-1).to_sym @registry = registry end |
Instance Method Details
#evaluate(options) ⇒ Array
Evaluate the memo, using the registry to handle the expansion.
22 23 24 |
# File 'lib/calyx/syntax/memo.rb', line 22 def evaluate() [@symbol, @registry.memoize_expansion(@symbol)] end |