Skip to content

Commit

Permalink
micros/walker: add termination-test clause
Browse files Browse the repository at this point in the history
  • Loading branch information
cxxxr committed Nov 19, 2023
1 parent 46504f3 commit 4441aae
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions contrib/walker/loop-form.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@
((form :initarg :form
:reader ast-form)))

(defclass termination-test-clause (ast)
((keyword :initarg :keyword
:reader ast-keyword)
(form :initarg :form
:reader ast-form)))

(defun walk-d-var-spec (walker d-var-spec env path)
(cond ((null d-var-spec)
'())
Expand Down Expand Up @@ -239,7 +245,6 @@
(next)
env
(cons pos path))))

(name-clause ()
(when (accept :named)
(let ((named (next)))
Expand Down Expand Up @@ -352,11 +357,12 @@
(or (unconditional)
(accumulation)
(conditional)))

(termination-test ()
;; TODO
)

(let ((keyword (lookahead)))
(when (accept :while :until :repeat :always :never :thereis)
(make-instance 'termination-test-clause
:keyword (intern (string keyword) :keyword)
:form (walk-and-next)))))
(for-as-clause ()
(when (accept :for :as)
(let ((part-for-as-clauses
Expand Down Expand Up @@ -419,7 +425,6 @@
:path (cons for-pos path)
:d-vars d-vars
:across across)))

(for-as-being-hash (for-pos d-vars other-var-keyword)
(let* ((hash-table-pos (current))
(hash-table (walk walker (next) env (cons hash-table-pos path))))
Expand Down Expand Up @@ -516,7 +521,6 @@
:form3 nil))))
(t
(error 'loop-conflicting-stepping-directions))))))

(type-spec ()
(cond ((and exps (member (lookahead) '(t nil fixnum float)))
(next)
Expand Down Expand Up @@ -646,5 +650,8 @@
(defmethod visit (visitor (ast return-clause))
(visit visitor (ast-form ast)))

(defmethod visit (visitor (ast termination-test-clause))
(visit visitor (ast-form ast)))

(defmethod visit (visitor (ast simple-loop-form))
(visit visitor (ast-body ast)))

0 comments on commit 4441aae

Please sign in to comment.