diff options
author | Darren Bane <darren.bane@gmail.com> | 2020-08-21 23:57:52 +0100 |
---|---|---|
committer | Darren Bane <darren.bane@gmail.com> | 2020-08-21 23:57:52 +0100 |
commit | d737f1ab887c1d3e7b97cfaa443e6037d5f53c5b (patch) | |
tree | 779782540833971a982888c1662c0519d1838dd3 /cbasic.lisp | |
parent | e6931993d7193b60881d0303110974b6af6af852 (diff) | |
download | lsp-d737f1ab887c1d3e7b97cfaa443e6037d5f53c5b.tar.gz |
Chose a project
Diffstat (limited to 'cbasic.lisp')
-rw-r--r-- | cbasic.lisp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/cbasic.lisp b/cbasic.lisp index ddbd900..1974c24 100644 --- a/cbasic.lisp +++ b/cbasic.lisp @@ -1,24 +1,28 @@ +;;; I'm trying to write an interpreter for a BBC BASIC subset +;;; using a Frankenstein design following +;;; https://caml.inria.fr/pub/docs/oreilly-book/html/book-ora058.html and +;;; https://github.com/Henry/BuddKaminInterpreters + ;;; Not sure yet if it's a good idea or not, ;;; but I'm trying to keep the number of top-level functions the same as in OCaml. (defun one-command (st) - (with-handler #'error-handler - (let ((l parse (read-line))) - (case (car l) - ((line) (insert (cadr c))) - ((p-end) (throw 'end nil)))))) ; throw and conditions are orthogonal + (format (standard-output) "> ") + (with-handler #'error-handler + (let ((l (parse (read-line)))) + (case (car l) + ((line) (insert (cadr c))) + ((p-end) (throw 'end nil)))))) ; throw and conditions are orthogonal -(defclass <state> () ((program :accessor prog) +(defclass <state> () ((program :accessor program) (env :accessor env))) (defmethod initialize-object :after ((self <state>) initargs) - (setf (program self) nil) - (setf (env self) nil)) + (setf (program self) nil) + (setf (env self) nil)) (defun main () - (catch 'end (lambda () - (format (standard-output) "BASIC version 0.1~%~%") - (for ((st (create (class <state>)))) - (()) - (format (standard-output) "> ") - (catch 'error (one-command st))))) - (format (standard-output) "See you later...~%")) + (catch 'end (lambda () + (format (standard-output) "BASIC version 0.1~%~%") + (for ((st (create (class <state>)))) + (catch 'error (one-command st))))) + (format (standard-output) "See you later...~%")) |