aboutsummaryrefslogtreecommitdiff
path: root/make/step0_repl.mk
blob: b8b1309eafe85087854faa46cbbb7f3a6722bda4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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)