Class: Campa::Lisp::Label

Inherits:
Object
  • Object
show all
Defined in:
lib/campa/lisp/label.rb

Instance Method Summary collapse

Constructor Details

#initializeLabel

Returns a new instance of Label.



4
5
6
7
# File 'lib/campa/lisp/label.rb', line 4

def initialize
  @evaler = Evaler.new
  @printer = Printer.new
end

Instance Method Details

#call(label, expression, env:) ⇒ Object

Raises:



13
14
15
16
17
18
# 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?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/campa/lisp/label.rb', line 9

def macro?
  true
end