From 18bfcd8224271af17959c205a4beaf53abc1a776 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Mon, 9 Sep 2024 18:51:53 +0200 Subject: [PATCH] forge/sf: steps towards compiling, + minor improvements --- forge/sf.lisp | 15 +++++++++------ test/test-sf.lisp | 2 ++ util/iter.lisp | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/forge/sf.lisp b/forge/sf.lisp index a1d9a51..ecb65a9 100644 --- a/forge/sf.lisp +++ b/forge/sf.lisp @@ -21,7 +21,7 @@ (:method ((it t)) (pushd it)) (:method ((it symbol)) - (funcall (func (symbol-value it))))) + (call-item (symbol-value it)))) (defgeneric comp-item (it)) @@ -30,8 +30,8 @@ (defclass word () ((func :reader func :initarg :func))) -(defmethod call-item ((it word)) - (funcall (func it))) +(defmethod call-item ((w word)) + (funcall (func w))) (defclass comp-word (word) ()) @@ -62,12 +62,15 @@ (defpackage :sf-builtin (:use :common-lisp) - (:local-nicknames (:f :scopes/forge/sf)) - (:export #:add #:mul #:dup)) + (:local-nicknames (:f :scopes/forge/sf) + (:iter :scopes/util/iter)) + (:export #:add #:mul #:dup #:in #:?)) (in-package :sf-builtin) (f:reg2 'add #'+) (f:reg2 'mul #'*) -(f:reg 'dup #'(lambda () (pushd (peekd)))) +(f:reg 'dup #'(lambda () (f:pushd (f:peekd)))) + +(f:reg 'in #'(lambda () (f:pushd (iter:next-value f:*input*)))) diff --git a/test/test-sf.lisp b/test/test-sf.lisp index b6c7643..ad1bd8c 100644 --- a/test/test-sf.lisp +++ b/test/test-sf.lisp @@ -25,6 +25,8 @@ (forge:exec-list '(4 2 add)) (util:lgi forge:*stack*) (== (forge:popd) 6) + (forge:exec-list '(in name)) + (util:lgi (forge:popd)) (t:show-result)) diff --git a/util/iter.lisp b/util/iter.lisp index b0f4bf3..a3dd6f1 100644 --- a/util/iter.lisp +++ b/util/iter.lisp @@ -5,7 +5,7 @@ (defpackage :scopes/util/iter (:use :common-lisp) - (:export #:next #:value #:process + (:export #:next #:value #:next-value #:process #:list-iterator)) (in-package :scopes/util/iter)