basic/step9_try.bas
basic/stepA_mal.bas
basic/*.prg
+common-lisp/*.image
# Settings
#
-IMPLS = ada awk bash basic c d chuck clojure coffee clisp cpp crystal cs dart \
+IMPLS = ada awk bash basic c d chuck clojure coffee clisp common-lisp cpp crystal cs dart \
erlang elisp elixir es6 factor forth fsharp go groovy guile haskell \
haxe io java julia js kotlin logo lua make mal ocaml matlab miniMAL \
nim objc objpascal perl perl6 php pil plpgsql plsql powershell ps \
clojure_STEP_TO_PROG = clojure/target/$($(1)).jar
coffee_STEP_TO_PROG = coffee/$($(1)).coffee
clisp_STEP_TO_PROG = clisp/$($(1)).fas
+common-lisp_STEP_TO_PROG = common-lisp/$($(1))
cpp_STEP_TO_PROG = cpp/$($(1))
crystal_STEP_TO_PROG = crystal/$($(1))
cs_STEP_TO_PROG = cs/$($(1)).exe
--- /dev/null
+ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
+
+step% : step%.lisp
+ cl-launch -v -l sbcl +Q -S $(ROOT_DIR) -s $@ -d $@.image -o $@ -E 'mal:main'
--- /dev/null
+#!/bin/bash
+exec $(dirname $0)/${STEP:-stepA_mal} "${@}"
--- /dev/null
+#-quicklisp
+(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp"
+ (user-homedir-pathname))))
+ (when (probe-file quicklisp-init)
+ (load quicklisp-init)))
+
+(ql:quickload :cl-readline)
+(ql:quickload :uiop)
+
+(defpackage #:mal-asd
+ (:use :cl :asdf))
+
+(in-package :mal-asd)
+
+(defsystem "step0_repl"
+ :name "MAL"
+ :version "1.0"
+ :author "Iqbal Ansari"
+ :description "Implementation of step 0 of MAL in Common Lisp"
+ :serial t
+ :components ((:file "step0_repl"))
+ :depends-on (:uiop :cl-readline))
--- /dev/null
+(defpackage :mal
+ (:use :common-lisp
+ :uiop)
+ (:export :main))
+
+(in-package :mal)
+
+(defun mal-read (string)
+ string)
+
+(defun mal-eval (ast)
+ ast)
+
+(defun mal-print (expression)
+ expression)
+
+(defun rep (string)
+ (mal-print (mal-eval (mal-read string))))
+
+(defvar *use-readline-p* nil)
+
+(defun raw-input (prompt)
+ (format *standard-output* prompt)
+ (force-output *standard-output*)
+ (read-line *standard-input* nil))
+
+(defun mal-readline (prompt)
+ (if *use-readline-p*
+ (cl-readline:readline :prompt prompt
+ :add-history t
+ :novelty-check (lambda (old new)
+ (not (string= old new))))
+ (raw-input prompt)))
+
+(defun mal-writeline (string)
+ (when string
+ (write-line string)
+ (force-output *standard-output*)))
+
+(defun main (&optional (argv nil argv-provided-p))
+ (declare (ignorable argv argv-provided-p))
+ (setf *use-readline-p* (not (or (string= (uiop:getenv "PERL_RL") "false")
+ (string= (uiop:getenv "TERM") "dumb"))))
+ (loop do (let ((line (mal-readline "user> ")))
+ (if line (mal-writeline (rep line)) (return)))))