Commit | Line | Data |
---|---|---|
31690700 JM |
1 | # |
2 | # mal (Make Lisp) | |
3 | # | |
4 | _TOP_DIR := $(dir $(lastword $(MAKEFILE_LIST))) | |
5 | include $(_TOP_DIR)types.mk | |
6 | include $(_TOP_DIR)reader.mk | |
ea81a808 | 7 | include $(_TOP_DIR)printer.mk |
31690700 JM |
8 | |
9 | SHELL := /bin/bash | |
10 | INTERACTIVE ?= yes | |
11 | ||
12 | # READ: read and parse input | |
13 | define READ | |
14 | $(if $(READLINE_EOF)$(__ERROR),,$(call READ_STR,$(if $(1),$(1),$(call READLINE,"user> ")))) | |
15 | endef | |
16 | ||
17 | # EVAL: just return the input | |
18 | define EVAL | |
19 | $(if $(READLINE_EOF)$(__ERROR),,$(1)) | |
20 | endef | |
21 | ||
22 | # PRINT: | |
23 | define PRINT | |
24 | $(if $(__ERROR),Error: $(call _pr_str,$(__ERROR),yes),$(if $(1),$(call _pr_str,$(1),yes)))$(if $(__ERROR),$(eval __ERROR :=),) | |
25 | endef | |
26 | ||
27 | # REPL: read, eval, print, loop | |
28 | REP = $(call PRINT,$(strip $(call EVAL,$(strip $(call READ,$(1))),$(REPL_ENV)))) | |
29 | REPL = $(info $(call REP,$(call READLINE,"user> ")))$(if $(READLINE_EOF),,$(call REPL)) | |
30 | ||
86b689f3 | 31 | # repl loop |
31690700 | 32 | $(if $(strip $(INTERACTIVE)),$(call REPL)) |