From a0fb419b1be8ed53f580c509b7a55cde8e06d4c9 Mon Sep 17 00:00:00 2001 From: mRnea Date: Thu, 18 Jul 2024 13:50:14 +0300 Subject: =?UTF-8?q?ba=C5=9Flang=C4=B1=C3=A7,=20push=20pop=20+=20-=20.=20vb?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- util.lisp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 util.lisp (limited to 'util.lisp') diff --git a/util.lisp b/util.lisp new file mode 100644 index 0000000..813f55b --- /dev/null +++ b/util.lisp @@ -0,0 +1,47 @@ +(in-package :cl-forth) + +(eval-when (:compile-toplevel :load-toplevel :execute) + (defmacro eval-always (&body body) + `(eval-when (:compile-toplevel :load-toplevel :execute) + ,@body))) + +(eval-always + (defmacro with-gensyms (syms &body body) + `(let ,(mapcar (lambda (sym) `(,sym (gensym ,(string sym)))) syms) + ,@body))) + +(defmacro init-hash (&body body) + (with-gensyms (table) + `(let ((,table (make-hash-table))) + ,@(iter (for (k v) in body) + (collect `(setf (gethash ',k ,table) ,v))) + ,table))) + +(defun mklist (form) + (if (listp form) form (list form))) + +;; (defmacro run (args) +;; (let ((sym (gensym))) +;; `(let ((,sym ,args)) +;; (format t "~{~a~^ ~}~%" ,sym) +;; (uiop:run-program ,sym)))) + +(defun run (args) + (format t "~{~a~^ ~}~%" args) + (uiop:run-program args :output *standard-output*)) + +;; ,(file-namestring +;; (make-pathname :name (pathname-name path) +;; :type "o")) + +(defparameter *test-program* + '((push 34) + (push 35) + (plus) + (dump) + (push 500) + (push 80) + (minus) + (dump))) + + -- cgit v1.2.3