;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Aug 2002
;;;;
-;;;; $Id: lml.cl,v 1.2 2002/09/16 06:26:27 kevin Exp $
+;;;; $Id: lml.cl,v 1.9 2002/09/16 09:58:57 kevin Exp $
;;;;
;;;; This file, part of LML, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
(declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
(in-package :lml)
-(defconstant +html4-prologue-string+
- (format nil
- "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">~%"))
+(defun html4-prologue-string ()
+ "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">")
-(defconstant +xml-prologue-string+
- (format nil
- "<?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"yes\"?>~%"))
+(defun xml-prologue-string ()
+ "version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"yes\"?>")
-(defconstant +xhtml-prologue-string+
- (format nil
- "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">~%"))
+(defun xhtml-prologue-string ()
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">")
(defvar *print-spaces* nil)
(defvar *indent* 0)
(defmacro xhtml-prologue ()
`(progn
- (lml-print +xml-prologue-string+)
- (lml-print +xhtml-prologue-string+)))
+ (lml-print "~A~%" (xml-prologue-string))
+ (lml-print "~A~%" (xhtml-prologue-string))))
(defmacro link (dest &body body)
`(with a :href ,dest ,@body))
(xhtml-prologue)
(html :xmlns "http://www.w3.org/1999/xhtml"
,@body)))
+
+(set-macro-character #\[
+ #'(lambda (stream char)
+ (declare (ignore char))
+ (let ((forms '())
+ (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
+ (push `(lml-print ,curr-string) forms)
+ (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 ((eval-string (read-from-string curr-string))
+ (result (gensym)))
+ (push
+ `(let ((,res ,eval-string))
+ (when ,res
+ (lml-print ,res)))
+ forms))
+ (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)))))
+ (push `(lml-print ,curr-string) forms)
+ `(progn ,(nreverse forms)))))
+
+