From f5787bcc7c556f847387038fa50536bbd9d2ca29 Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Fri, 12 Feb 2021 21:05:36 -0800 Subject: [PATCH] Moved words and vlist to utils. --- ueforth/common/boot.fs | 4 ---- ueforth/common/utils.fs | 16 ++++++++++++++-- ueforth/common/vocabulary.fs | 6 +----- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/ueforth/common/boot.fs b/ueforth/common/boot.fs index 8ef1f3e..6dcd657 100644 --- a/ueforth/common/boot.fs +++ b/ueforth/common/boot.fs @@ -206,10 +206,6 @@ variable hld if ." Unsupported word type: " see. cr exit then ['] : see. dup see. space see-loop ['] ; see. cr ; : see ' see-xt ; -75 value line-width -: onlines ( n xt -- n xt ) - swap dup line-width > if drop 0 cr then over >name nip + 1+ swap ; -: words 0 context @ @ begin dup while onlines dup see. >link repeat 2drop cr ; ( Input ) : raw.s depth 0 max for aft sp@ r@ cells - @ . then next ; diff --git a/ueforth/common/utils.fs b/ueforth/common/utils.fs index 8b842c0..0dc7d12 100644 --- a/ueforth/common/utils.fs +++ b/ueforth/common/utils.fs @@ -7,6 +7,9 @@ : dump ( a n -- ) cr 0 do i 16 mod 0= if cr then dup i + c@ . loop drop cr ; +( Remove from Dictionary ) +: forget ( "name" ) ' dup >link current @ ! >name drop here - allot ; + internals definitions : mem= ( a a n -- f) for aft 2dup c@ swap c@ <> if 2drop rdrop 0 exit then 1+ swap 1+ then next 2drop -1 ; @@ -14,7 +17,16 @@ forth definitions also internals : str= ( a n a n -- f) >r swap r@ <> if rdrop 2drop 0 exit then r> mem= ; : startswith? ( a n a n -- f ) >r swap r@ < if rdrop 2drop 0 exit then r> mem= ; : .s ." <" depth n. ." > " raw.s cr ; -: see-all 0 context @ @ begin dup while onlines dup see-xt >link repeat 2drop cr ; only forth definitions -: forget ( "name" ) ' dup >link current @ ! >name drop here - allot ; +( List words in Dictionary / Vocabulary ) +internals definitions +75 value line-width +: onlines ( n xt -- n xt ) + swap dup line-width > if drop 0 cr then over >name nip + 1+ swap ; +: >name-length ( xt -- n ) dup 0= if exit then >name nip ; +forth definitions also internals +: vlist 0 context @ @ begin dup >name-length while onlines dup see. >link repeat 2drop cr ; +: words 0 context @ @ begin dup while onlines dup see. >link repeat 2drop cr ; +: see-all 0 context @ @ begin dup while onlines dup see-xt >link repeat 2drop cr ; +only forth definitions diff --git a/ueforth/common/vocabulary.fs b/ueforth/common/vocabulary.fs index bde8db9..0f19455 100644 --- a/ueforth/common/vocabulary.fs +++ b/ueforth/common/vocabulary.fs @@ -5,8 +5,6 @@ current @ constant forth-wordlist : vocabulary ( "name" ) create 0 , current @ 2 cells + , current @ @ last-vocabulary ! does> cell+ context ! ; : definitions context @ current ! ; -: >name-length ( xt -- n ) dup 0= if exit then >name nip ; -: vlist 0 context @ @ begin dup >name-length while onlines dup see. >link repeat 2drop cr ; ( Make it easy to transfer words between vocabularies ) : transfer-xt ( xt -- ) context @ begin 2dup @ <> while @ >link& repeat nip @@ -36,9 +34,7 @@ transfer{ 'sys 'heap aliteral leaving( )leaving leaving leaving, (do) (?do) (+loop) - parse-quote digit $@ - see. see-loop >name-length exit= - see-one raw.s + parse-quote digit $@ raw.s tib-setup input-limit }transfer forth definitions