orelangを***で実装してみたをcommon lispで

プログラミング言語を作る。1時間で。 - Qiita

common lispでというよりはリードマクロを使ってcommon lispをorelang化していく

;;; orelang.lisp
(defpackage :orelang (:import-from :cl :+ :* :=))

(defvar *ore-readtable*
  (let ((*readtable* (copy-readtable nil)))
(set-macro-character #\] (get-macro-character #\)))
(set-macro-character #\[ (lambda (stream char)
               (declare (ignore char))
               (mapcar (lambda (x) (if (stringp x) (intern x :orelang) x))
                   (read-delimited-list #\] stream t))))
(set-macro-character #\, #'read)
*readtable*))

(defmacro orelang::|set| (var form) `(defparameter ,var ,form))
(defmacro orelang::|get| (var) var)
(defmacro orelang::|until| (test &body body)
  `(do ((#1=#:result nil (progn ,@body)))
   (,test #1#)))
(defmacro orelang::|step| (&body forms) `(progn ,@forms))

(defun orelang-run (&optional (stream *standard-input*))
  (let ((*readtable* *ore-readtable*))
(eval (read stream))))

CLIから使う

$ ros -l orelang.lisp -e '(print (orelang-run))'
["step",
  ["set", "i", 10],
  ["set", "sum", 0],
  ["until", ["=", ["get", "i"], 0], [
"step",
["set", "sum", ["+", ["get", "sum"], ["get", "i"]]],
["set", "i", ["+", ["get", "i"], -1]]
  ]],
  ["get", "sum"]
]

; => 55