From 578e856583a471b35bb4e2404a6618f04c380022 Mon Sep 17 00:00:00 2001 From: Daniel Gackle Date: Fri, 31 Jul 2009 14:20:15 -0600 Subject: [PATCH] Added :REPEAT clauses to PS's LOOP. --- src/lib/ps-loop.lisp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/ps-loop.lisp b/src/lib/ps-loop.lisp index c7334fa..38ea78c 100644 --- a/src/lib/ps-loop.lisp +++ b/src/lib/ps-loop.lisp @@ -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 @@ -146,10 +146,15 @@ ((: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)) -- 2.20.1