aboutsummaryrefslogtreecommitdiff
path: root/ruby/step0_repl.rb
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-04-10 20:34:29 -0500
committerJoel Martin <github@martintribe.org>2014-04-10 20:34:29 -0500
commitf705f0fce151863091ad77753105f0d15270edec (patch)
tree788691596846567abec1606131c972d24211604c /ruby/step0_repl.rb
parent712af9efbe15a9a65c25ab92ee2a49c8e749ed3d (diff)
downloadmal-f705f0fce151863091ad77753105f0d15270edec.tar.gz
mal-f705f0fce151863091ad77753105f0d15270edec.zip
Ruby: step0, step1
Diffstat (limited to 'ruby/step0_repl.rb')
-rw-r--r--ruby/step0_repl.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/ruby/step0_repl.rb b/ruby/step0_repl.rb
new file mode 100644
index 0000000..dd32b27
--- /dev/null
+++ b/ruby/step0_repl.rb
@@ -0,0 +1,25 @@
+require "readline"
+
+# read
+def READ(str)
+ return str
+end
+
+# eval
+def EVAL(ast, env)
+ return ast
+end
+
+# print
+def PRINT(exp)
+ return exp
+end
+
+# repl
+def REP(str)
+ return PRINT(EVAL(READ(str), {}))
+end
+
+while line = Readline.readline("user> ", true)
+ puts REP(line)
+end