about summary refs log tree commit diff stats
path: root/basic.lsp
diff options
context:
space:
mode:
authorDarren Bane <dbane@tilde.institute>2020-07-30 23:01:26 +0100
committerDarren Bane <dbane@tilde.institute>2020-07-30 23:01:26 +0100
commit628c87c1a75e48c34888031f2aca3695b5a704cf (patch)
tree52d0841ee0bd19c2dbe46871d4108379bef29465 /basic.lsp
parentbd88ae0b1da3e48032a251ce779f347329a52ed7 (diff)
downloadlsp-628c87c1a75e48c34888031f2aca3695b5a704cf.tar.gz
Maybe CL is better after all
Diffstat (limited to 'basic.lsp')
-rw-r--r--basic.lsp26
1 files changed, 26 insertions, 0 deletions
diff --git a/basic.lsp b/basic.lsp
new file mode 100644
index 0000000..571d4a6
--- /dev/null
+++ b/basic.lsp
@@ -0,0 +1,26 @@
+#!/home/snuc/openlisp-10.9.0/uxlisp -shell
+
+;;; 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
+
+(defclass <state> () ((prog :accessor prog)
+                      (env :accessor env)))
+(defmethod initialize-object :after ((self <state>) initargs)
+   (setf (prog self) nil)
+   (setf (env self) nil))
+
+(defun main ()
+   (catch 'end (lambda ()
+                  (format (standard-output) "OpenCOMAL version 0.4~%~%")
+                  (for ((st (create (class <state>))))
+                       (())
+                       (format (standard-output) "> ")
+                       (catch 'error (one-command st)))))
+   (format (standard-output) "See you later...~%"))