From bde4a4bf8433a91cfe6f0996af8b53bc1b778903 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20V=C3=A1zquez?= Date: Tue, 18 Dec 2012 23:39:30 +0100 Subject: [PATCH] WHEN, UNLESS --- test.lisp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test.lisp b/test.lisp index 7a68a35..c99c892 100644 --- a/test.lisp +++ b/test.lisp @@ -21,6 +21,12 @@ (%compile-defun ',name)) (fsetq ,name (lambda ,args ,@body)))) +(defmacro when (condition &rest body) + `(if ,condition (progn ,@body))) + +(defmacro unless (condition &rest body) + `(if ,condition nil (progn ,@body))) + (defun = (x y) (= x y)) (defun + (x y) (+ x y)) (defun - (x y) (- x y)) @@ -227,3 +233,19 @@ (read-until stream (lambda (x) (char= x #\newline))) (skip-whitespaces stream) (setq ch (%peek-char stream))))) + +(defun %read-list (stream) + (skip-whitespaces-and-comments stream) + (let ((ch (%peek-char stream))) + (cond + ((char= ch #\)) + (%read-char stream) + nil) + ((char= ch #\.) + (%read-char stream) + (skip-whitespaces-and-comments stream) + (prog1 (ls-read stream) + (unless (char= (%read-char stream) #\)) + (error "')' was expected.")))) + (t + (cons (ls-read stream) (%read-list stream)))))) -- 1.7.10.4