forge: steps towards if and more...

This commit is contained in:
Helmut Merz 2024-09-18 12:55:47 +02:00
parent c857da986b
commit 90a2f4db27
2 changed files with 8 additions and 4 deletions

View file

@ -148,7 +148,7 @@
#:? #:??
#:ptr #:get #:put
#:in #:next
#:call #:call-if #:call-while #:val
#:call #:call-if #:call-while #:comp #:val
#:<comp #:reg #:regc #:/>))
(in-package :sf-builtin)
@ -185,7 +185,8 @@
(f:reg 'in #'(lambda () (f:pushd (iter:next-value f:*input*))))
(f:reg 'next #'f:next)
(f:reg 'call #'(lambda () (f:call (popd))))
(f:reg 'comp #'(lambda () (cons (f:popd) f::*buffer*)))
(f:reg 'call #'(lambda () (f:call (f:popd))))
(f:reg 'call-if #'call-if)
(f:reg 'call-while #'call-while)
(f:reg 'val #'(lambda () (f:pushd (list #'f:next (f:popd)))))

View file

@ -19,12 +19,12 @@
;(forge:setup-builtins)
(test-exec)
(test-def)
(test-val)))
(test-val)
(test-if)))
(util:lgi (forge:stack forge:*forge-env*))
(t:show-result)))
(deftest test-exec ()
;(forge:exec-str "4 2 add")
(forge:exec-list '(4 2 add))
(== (forge:popd) 6)
(forge:exec-list '(<comp dup mul /> in square reg))
@ -53,3 +53,6 @@
(== (forge:popd) 42)
)
(deftest test-if ()
(forge:exec-list '(<comp in <comp swp reg /> in <defc regc))
(forge:exec-list '(<defc <if <comp next next comp comp next call-if comp />)))