Created
March 10, 2016 06:00
-
-
Save topher6345/642f372cdedcd967ceda to your computer and use it in GitHub Desktop.
A basic 4 operator LISP implemented in ruby.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module LISPO | |
module ArrayCallable | |
refine Array do | |
def call | |
inject &shift | |
end | |
end | |
end | |
class Parser | |
def self.call(string) | |
string.gsub! '(', '[:' | |
string.gsub! ' ', ', ' | |
string.gsub! ')', '].call' | |
end | |
end | |
module VM | |
using ArrayCallable | |
def self.call(string) | |
module_eval Parser.call(string) | |
end | |
end | |
end | |
puts LISPO::VM.call <<-LISP | |
(+ 1 2 (* 2 9) 4 6 7) | |
LISP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment