class Interpreter
Constants
- DEFAULTS
- FORMS
Public Class Methods
new()
click to toggle source
# File lib/schemerald/Interpreter/Interpreter.rb, line 2 def initialize @environment = Environment.new(nil, DEFAULTS) @special_forms = Environment.new(nil, FORMS) end
Public Instance Methods
evaluate(string)
click to toggle source
# File lib/schemerald/Interpreter/Interpreter.rb, line 7 def evaluate(string) SXP::Reader::Scheme.read("(#{string})"). map{|x| x.consify.scheme_eval(@environment, @special_forms) } end
repl()
click to toggle source
# File lib/schemerald/Interpreter/Interpreter.rb, line 16 def repl print "> " STDIN.each_line do |line| begin return if line.start_with? "exit" scheme_print(evaluate(line)) rescue SchemeError => e puts "SchemeError: #{e}" rescue StandardError => e puts "ERROR: #{e}" end print "> " end end
scheme_print(output)
click to toggle source
# File lib/schemerald/Interpreter/Interpreter.rb, line 12 def scheme_print(output) output.each{|exp| puts exp.to_sxp } end