Class: Spectre::ClosureAction

Inherits:
Object
  • Object
show all
Defined in:
lib/spectre/generic/semanticaction.rb

Overview

This semantic action will be instantiated everytime a symbol is given to Parser#[]. It stores the value it receives inside the closure.

Instance Method Summary collapse

Constructor Details

#initialize(sym) ⇒ ClosureAction

sym is the Symbol under which the parsed value will be stored in the Closure.



32
33
34
# File 'lib/spectre/generic/semanticaction.rb', line 32

def initialize sym
    @sym = sym
end

Instance Method Details

#call(match, closure) ⇒ Object



36
37
38
39
# File 'lib/spectre/generic/semanticaction.rb', line 36

def call match, closure
    raise "no closure set for ClosureAction" unless closure
    closure[@sym] = match.value
end