X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=lml.cl;h=8efdc39a063e09a594c30b37eec09f84dc1eecc7;hb=8f2c887a5500d1cba7c1e53e18233085de87a783;hp=2c30bbb644cf6d37d6519e6aef119b6ade7987b7;hpb=17b424bd0a2fbdf20bb945dcac07d8ccb239b68c;p=lml.git diff --git a/lml.cl b/lml.cl index 2c30bbb..8efdc39 100644 --- a/lml.cl +++ b/lml.cl @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Aug 2002 ;;;; -;;;; $Id: lml.cl,v 1.5 2002/09/16 08:16:49 kevin Exp $ +;;;; $Id: lml.cl,v 1.7 2002/09/16 09:43:51 kevin Exp $ ;;;; ;;;; This file, part of LML, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -200,3 +200,46 @@ (xhtml-prologue) (html :xmlns "http://www.w3.org/1999/xhtml" ,@body))) + +(set-macro-character #\[ + #'(lambda (stream char) + (declare (ignore char)) + (let ((curr-string (make-array 1024 :fill-pointer 0 :adjustable t :element-type 'character)) + (got-comma nil)) + (do ((ch (read-char stream t nil t) (read-char stream t nil t))) + ((eql ch #\])) + (if got-comma + (if (eql ch #\() + ;; Starting top-level ,( + (progn + (princ curr-string) + (setf (fill-pointer curr-string) 0) + (setq got-comma nil) + (vector-push #\( curr-string) + (do ((ch (read-char stream t nil t) (Read-char stream t nil t))) + ((eql ch #\))) + (when (eql ch #\]) + (format *trace-output* "Syntax error reading #\]") + (return nil)) + (vector-push-extend ch curr-string)) + (vector-push-extend #\) curr-string) + (let ((result (eval (read-from-string curr-string)))) + (when result + (princ result))) + (setf (fill-pointer curr-string) 0)) + ;; read comma, then non #\( char + (progn + (unless (eql ch #\,) + (setq got-comma nil)) + (vector-push-extend #\, curr-string) ;; push previous command + (vector-push-extend ch curr-string))) + ;; previous character is not a comma + (if (eql ch #\,) + (setq got-comma t) + (progn + (setq got-comma nil) + (vector-push-extend ch curr-string))))) + (princ curr-string)) + t)) + +