From 6eff29f62d812d11a74cd17c671979c20bb73fd2 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Mon, 16 Sep 2024 10:50:12 +0200 Subject: [PATCH] forge/sf: exec-string, using iter:string-iterator --- forge/sf.lisp | 8 ++++++-- test/test-core.lisp | 3 +-- test/test-sf.lisp | 9 +++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/forge/sf.lisp b/forge/sf.lisp index 8fd11cb..0e41101 100644 --- a/forge/sf.lisp +++ b/forge/sf.lisp @@ -9,7 +9,7 @@ (:export #:forge-env #:vocabulary #:stack #:current-package #:*forge-env* #:*input* #:*code* #:word #:comp-word - #:exec-list #:exec-input #:comp-input #:call + #:exec-list #:exec-string #:exec-input #:comp-input #:call #:comp-item #:next #:reg #:reg1 #:reg2 #:reg-code #:pushd #:popd #:peekd)) @@ -55,7 +55,7 @@ (comp-item v))))) (defun find-word (sym) - (let ((sym (find-symbol (symbol-name sym) (current-package *forge-env*)))) + (let ((sym (intern (symbol-name sym) (current-package *forge-env*)))) (multiple-value-bind (val found) (gethash sym (vocabulary *forge-env*)) (when (not found) (util:lgw "not found" sym)) @@ -85,6 +85,10 @@ (let ((*input* (iter:list-iterator lst))) (exec-input))) +(defun exec-string (s) + (let ((*input* (iter:string-iterator s))) + (exec-input))) + (defun exec-input () (iter:process *input* #'exec-item)) diff --git a/test/test-core.lisp b/test/test-core.lisp index b6ea8df..a1e1d08 100644 --- a/test/test-core.lisp +++ b/test/test-core.lisp @@ -94,8 +94,7 @@ (let ((it (iter:string-iterator "a b c"))) (== (iter:value it) nil) (== (iter:next it) nil) - (== (iter:value it) (intern "A"))) - ;(== (iter:value it) (read-from-string "a"))) + (== (string (iter:value it)) "A")) ) (deftest test-shape() diff --git a/test/test-sf.lisp b/test/test-sf.lisp index 5ee3ff6..ec0ce5b 100644 --- a/test/test-sf.lisp +++ b/test/test-sf.lisp @@ -3,8 +3,7 @@ ;;;; testing facility for scopes/forge (defpackage :scopes/test-sf - (:use :common-lisp - :sf-builtin) + (:use :common-lisp) (:local-nicknames (:forge :scopes/forge/sf) (:util :scopes/util) (:t :scopes/testing)) @@ -29,10 +28,12 @@ (== (forge:popd) 6) (forge:exec-list '( in square reg)) (forge:exec-list '(7 square)) - (== (forge:popd) 49)) + (== (forge:popd) 49) + (forge:exec-string "8 square") + (== (forge:popd) 64)) (deftest test-def () (forge:exec-list '( in )) + (forge:exec-string "") (forge:exec-list '(3 cube)) (== (forge:popd) 27))