;;; I'm trying to write an interpreter for a BBC BASIC subset ;;; initially following the design of ;;; https://caml.inria.fr/pub/docs/oreilly-book/html/book-ora058.html ;;; and later I can Frankenstein it with ;;; https://github.com/Henry/BuddKaminInterpreters (load "cutil.lisp") (load "cparse.lisp") (require "cparse") (defpackage #:cbasic (:use #:common-lisp) (:export #:main)) (in-package #:cbasic) ;;; Not sure if it's a good idea, ;;; but try to keep the number of top-level functions the same as in OCaml. (defun one-command (st) (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 () ((program :accessor program) (env :accessor env))) (defmethod initialize-object :after ((self ) initargs) (setf (program self) nil) (setf (env self) nil)) (defun main () (catch 'end (lambda () (format (standard-output) "BASIC version 0.1~%~%") (for ((st (create (class )))) (catch 'error (one-command st))))) (format (standard-output) "See you later...~%")) (provide "cbasic")