Contents    Page-10    Prev    Next    Page+10    Index   

Looping Statements

Looping statements generate multiple statements in intermediate code, as shown in the following patterns. (Generate label numbers by j = labelnumber++;.)


for i := start to end do s

(PROGN (:= i start)
       (LABEL j)
       (IF (<= i end)
           (PROGN s
                  (:= i (+ 1 i))
                  (GOTO j) )))
while c do s

(PROGN (LABEL j)
       (IF c (PROGN s (GOTO j))))


repeat statements until c

(PROGN (LABEL j)
       (PROGN statements)
       (IF c (PROGN) (GOTO j)))
The empty (PROGN) acts as a no-op.