aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-04-14 23:04:48 -0500
committerJoel Martin <github@martintribe.org>2014-04-14 23:04:48 -0500
commita2849f89e7892feee256169398b1d2d82a2b8231 (patch)
treeb0e83dad80af83ba6529502b36b91c7d761d2342
parent166398b84f0ada81ca25db201b1dad895d0acde1 (diff)
downloadmal-a2849f89e7892feee256169398b1d2d82a2b8231.tar.gz
mal-a2849f89e7892feee256169398b1d2d82a2b8231.zip
Mal space cleanup. Ruby Makefile. TODO updates.
-rw-r--r--docs/TODO5
-rw-r--r--mal/step6_file.mal2
-rw-r--r--mal/step7_quote.mal2
-rw-r--r--mal/step8_macros.mal16
-rw-r--r--mal/stepA_more.mal16
-rw-r--r--ruby/Makefile20
6 files changed, 40 insertions, 21 deletions
diff --git a/docs/TODO b/docs/TODO
index 5b5a240..05c0820 100644
--- a/docs/TODO
+++ b/docs/TODO
@@ -46,7 +46,7 @@ PHP:
Postscript:
- negative numbers
- - fix self-hosting of mal step1
+ - self-hosting issues in steps 8,A
Python:
@@ -88,8 +88,7 @@ Future Implementations:
* C#
* Python
- C++
- - Ruby
- - http://www.ruby-doc.org/stdlib-1.9.3/libdoc/readline/rdoc/Readline.html
+ * Ruby
* C
- Objective-C
- Perl
diff --git a/mal/step6_file.mal b/mal/step6_file.mal
index 2f53c4d..fa5991a 100644
--- a/mal/step6_file.mal
+++ b/mal/step6_file.mal
@@ -57,7 +57,7 @@
(EVAL (nth ast 3) env)
nil)
(EVAL (nth ast 2) env)))
-
+
(= 'fn* a0)
(fn* [& args]
(EVAL (nth ast 2) (new-env env (nth ast 1) args)))
diff --git a/mal/step7_quote.mal b/mal/step7_quote.mal
index 553248c..5195d38 100644
--- a/mal/step7_quote.mal
+++ b/mal/step7_quote.mal
@@ -85,7 +85,7 @@
(EVAL (nth ast 3) env)
nil)
(EVAL (nth ast 2) env)))
-
+
(= 'fn* a0)
(fn* [& args]
(EVAL (nth ast 2) (new-env env (nth ast 1) args)))
diff --git a/mal/step8_macros.mal b/mal/step8_macros.mal
index 5c81138..d2b2bd4 100644
--- a/mal/step8_macros.mal
+++ b/mal/step8_macros.mal
@@ -80,20 +80,20 @@
(cond
(= 'def! a0)
(env-set env (nth ast 1) (EVAL (nth ast 2) env))
-
+
(= 'let* a0)
(let* [let-env (new-env env)]
(do
(LET let-env (nth ast 1))
(EVAL (nth ast 2) let-env)))
-
+
(= 'quote a0)
(nth ast 1)
-
+
(= 'quasiquote a0)
(let* [a1 (nth ast 1)]
(EVAL (QUASIQUOTE a1) env))
-
+
(= 'defmacro! a0)
(let* [a1 (nth ast 1)
a2 (nth ast 2)
@@ -101,7 +101,7 @@
m (or (meta f) {})
mac (with-meta f (assoc m "ismacro" true))]
(env-set env a1 mac))
-
+
(= 'macroexpand a0)
(let* [a1 (nth ast 1)]
(MACROEXPAND a1 env))
@@ -109,7 +109,7 @@
(= 'do a0)
(let* [el (eval-ast (rest ast) env)]
(nth el (- (count el) 1)))
-
+
(= 'if a0)
(let* [cond (EVAL (nth ast 1) env)]
(if (or (= cond nil) (= cond false))
@@ -117,11 +117,11 @@
(EVAL (nth ast 3) env)
nil)
(EVAL (nth ast 2) env)))
-
+
(= 'fn* a0)
(fn* [& args]
(EVAL (nth ast 2) (new-env env (nth ast 1) args)))
-
+
"else"
(let* [el (eval-ast ast env)
f (first el)
diff --git a/mal/stepA_more.mal b/mal/stepA_more.mal
index cd1e570..61eb029 100644
--- a/mal/stepA_more.mal
+++ b/mal/stepA_more.mal
@@ -80,20 +80,20 @@
(cond
(= 'def! a0)
(env-set env (nth ast 1) (EVAL (nth ast 2) env))
-
+
(= 'let* a0)
(let* [let-env (new-env env)]
(do
(LET let-env (nth ast 1))
(EVAL (nth ast 2) let-env)))
-
+
(= 'quote a0)
(nth ast 1)
-
+
(= 'quasiquote a0)
(let* [a1 (nth ast 1)]
(EVAL (QUASIQUOTE a1) env))
-
+
(= 'defmacro! a0)
(let* [a1 (nth ast 1)
a2 (nth ast 2)
@@ -101,7 +101,7 @@
m (or (meta f) {})
mac (with-meta f (assoc m "ismacro" true))]
(env-set env a1 mac))
-
+
(= 'macroexpand a0)
(let* [a1 (nth ast 1)]
(MACROEXPAND a1 env))
@@ -120,7 +120,7 @@
(= 'do a0)
(let* [el (eval-ast (rest ast) env)]
(nth el (- (count el) 1)))
-
+
(= 'if a0)
(let* [cond (EVAL (nth ast 1) env)]
(if (or (= cond nil) (= cond false))
@@ -128,11 +128,11 @@
(EVAL (nth ast 3) env)
nil)
(EVAL (nth ast 2) env)))
-
+
(= 'fn* a0)
(fn* [& args]
(EVAL (nth ast 2) (new-env env (nth ast 1) args)))
-
+
"else"
(let* [el (eval-ast ast env)
f (first el)
diff --git a/ruby/Makefile b/ruby/Makefile
new file mode 100644
index 0000000..bfaa826
--- /dev/null
+++ b/ruby/Makefile
@@ -0,0 +1,20 @@
+TESTS =
+
+SOURCES_BASE = types.rb reader.rb printer.rb
+SOURCES_LISP = env.rb core.rb stepA_more.rb
+SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
+
+#all: mal.rb
+
+.PHONY: stats tests $(TESTS)
+
+stats: $(SOURCES)
+ @wc $^
+stats-lisp: $(SOURCES_LISP)
+ @wc $^
+
+tests: $(TESTS)
+
+$(TESTS):
+ @echo "Running $@"; \
+ ruby $@ || exit 1; \