diff options
Diffstat (limited to 'make/step0_repl.mk')
| -rw-r--r-- | make/step0_repl.mk | 26 |
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) |
