aboutsummaryrefslogtreecommitdiff
path: root/make/step0_repl.mk
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-03-24 16:32:24 -0500
committerJoel Martin <github@martintribe.org>2014-03-24 16:32:24 -0500
commit3169070063b2cb877200117ebb384269d73bcb93 (patch)
tree23de3db1ea5c37afd21a45b6ed7771f56a08c0c4 /make/step0_repl.mk
downloadmal-3169070063b2cb877200117ebb384269d73bcb93.tar.gz
mal-3169070063b2cb877200117ebb384269d73bcb93.zip
Current state of mal for Clojure West lighting talk.
Diffstat (limited to 'make/step0_repl.mk')
-rw-r--r--make/step0_repl.mk26
1 files changed, 26 insertions, 0 deletions
diff --git a/make/step0_repl.mk b/make/step0_repl.mk
new file mode 100644
index 0000000..b8b1309
--- /dev/null
+++ b/make/step0_repl.mk
@@ -0,0 +1,26 @@
+#
+# mal (Make Lisp)
+#
+_TOP_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
+include $(_TOP_DIR)readline.mk
+
+SHELL := /bin/bash
+
+define READ
+$(call READLINE)
+endef
+
+define EVAL
+$(if $(READLINE_EOF),,\
+ $(if $(findstring =,$(1)),$(eval $(1))$($(word 1,$(1))),$(eval __return := $(1))$(__return)))
+endef
+
+define PRINT
+$(1)
+endef
+
+REP = $(call PRINT,$(strip $(call EVAL,$(strip $(call READ)))))
+REPL = $(info $(call REP))$(if $(READLINE_EOF),,$(call REPL))
+
+# Call the read-eval-print loop
+$(call REPL)