Added :REPEAT clauses to PS's LOOP.
authorDaniel Gackle <danielgackle@gmail.com>
Fri, 31 Jul 2009 20:20:15 +0000 (14:20 -0600)
committerVladimir Sedach <vsedach@gmail.com>
Sat, 1 Aug 2009 19:42:22 +0000 (13:42 -0600)
src/lib/ps-loop.lisp

index c7334fa..38ea78c 100644 (file)
@@ -9,7 +9,7 @@
 (defvar *loop-keywords*
   '(:for :do :when :unless :initially :finally :first-time :last-time :while :until
     :from :to :below :downto :above :by :in :across :on :index := :then :sum :collect
-    :count :minimize :maximize :into))
+    :count :minimize :maximize :into :repeat))
 
 (defun normalize-loop-keywords (args)
   (mapcar
                      ((:in :across) (for-in var))
                      (:on (for-on var))
                      (otherwise (error "FOR ~s ~s is not valid in PS-LOOP." var term)))))
+               (repeat-clause ()
+                 (let ((index (ps-gensym)))
+                   (setf terms (append `(:for ,index :from 0 :below ,(consume)) terms))
+                   (clause)))
                (clause ()
                  (let ((term (consume-atom)))
                    (case term
                      (:for (for-clause))
+                     (:repeat (repeat-clause))
                      (:while (push `(unless ,(consume) break) body))
                      (:until (push `(when ,(consume) break) body))
                      (:initially (push (consume-progn) initially))