class Campa::Lisp::Label

Attributes

evaler[R]
printer[R]

Public Class Methods

new() click to toggle source
# File lib/campa/lisp/label.rb, line 4
def initialize
  @evaler = Evaler.new
  @printer = Printer.new
end

Public Instance Methods

call(label, expression, env:) click to toggle source
# File lib/campa/lisp/label.rb, line 13
def call(label, expression, env:)
  result = evaler.call(expression, env)
  raise Error::Reserved, printer.call(label) if reserved?(label, result)

  env[label] = result
end
macro?() click to toggle source
# File lib/campa/lisp/label.rb, line 9
def macro?
  true
end

Private Instance Methods

reserved?(symbol, result) click to toggle source
# File lib/campa/lisp/label.rb, line 24
def reserved?(symbol, result)
  symbol.label.match?(CR_REGEX) && result.is_a?(Lambda)
end