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