1 ;; the if* macro used in Allegro:
3 ;; This is in the public domain... please feel free to put this definition
4 ;; in your code or distribute it with your version of lisp.
8 (eval-when (:compile-toplevel :load-toplevel :execute)
9 (defvar if*-keyword-list '("then" "thenret" "else" "elseif")))
11 (defmacro if* (&rest args)
12 (do ((xx (reverse args) (cdr xx))
19 (cond ((eq state :compl)
21 (t (error "if*: illegal form ~s" args))))
22 (cond ((and (symbolp (car xx))
23 (member (symbol-name (car xx))
25 :test #'string-equal))
26 (setq lookat (symbol-name (car xx)))))
28 (cond ((eq state :init)
29 (cond (lookat (cond ((string-equal lookat "thenret")
33 "if*: bad keyword ~a" lookat))))
36 (push (car xx) col))))
39 (cond ((string-equal lookat "else")
42 "if*: multiples elses")))
45 (push `(t ,@col) totalcol))
46 ((string-equal lookat "then")
48 (t (error "if*: bad keyword ~s"
50 (t (push (car xx) col))))
54 "if*: keyword ~s at the wrong place " (car xx)))
55 (t (setq state :compl)
56 (push `(,(car xx) ,@col) totalcol))))
58 (cond ((not (string-equal lookat "elseif"))
59 (error "if*: missing elseif clause ")))
60 (setq state :init)))))