class Ruspea::Code

Public Class Methods

new() click to toggle source
# File lib/ruspea/code.rb, line 3
def initialize
  @reader = Ruspea::Interpreter::Reader.new
  @evaler = Ruspea::Interpreter::Evaler.new
  @printer = Ruspea::Printer.new
end

Public Instance Methods

load(file_path) click to toggle source
# File lib/ruspea/code.rb, line 9
def load(file_path)
  raise "#{file_path} is not a file" if !File.exists?(file_path)
  exec(File.read(file_path))
end
run(code, env: Ruspea::Language::Core.new) click to toggle source
# File lib/ruspea/code.rb, line 14
def run(code, env: Ruspea::Language::Core.new)
  _, forms = @reader.call(code)
  @evaler.call(forms, context: env)
end