From 9ca16d123d7e22e25ca35f4f54b4408b834e5fd2 Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Sat, 10 Jul 2021 13:00:19 -0700 Subject: [PATCH] Add -- support to locals. --- ueforth/Makefile | 4 ++-- ueforth/common/locals.fs | 7 ++++++- ueforth/common/locals_tests.fs | 5 +++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ueforth/Makefile b/ueforth/Makefile index 53d9594..cef4103 100644 --- a/ueforth/Makefile +++ b/ueforth/Makefile @@ -150,9 +150,9 @@ $(GEN): POSIX_BOOT = common/boot.fs common/conditionals.fs common/vocabulary.fs \ common/hide_calls.fs common/ansi.fs \ - posix/posix.fs posix/posix_highlevel.fs posix/termios.fs common/locals.fs \ + posix/posix.fs posix/posix_highlevel.fs posix/termios.fs \ common/tasks.fs common/utils.fs common/highlevel.fs common/filetools.fs \ - posix/posix_desktop.fs \ + common/locals.fs posix/posix_desktop.fs \ common/streams.fs common/blocks.fs \ posix/sockets.fs posix/telnetd.fs posix/httpd.fs posix/web_interface.fs \ posix/autoboot.fs \ diff --git a/ueforth/common/locals.fs b/ueforth/common/locals.fs index 5ffc626..45d2d40 100644 --- a/ueforth/common/locals.fs +++ b/ueforth/common/locals.fs @@ -34,10 +34,15 @@ scope-doer scope-template : (local) ( a n -- ) >r >r postpone >r postpone ahead r> r> scope-create postpone then ; : }? ( a n -- ) 1 <> if drop 0 exit then c@ [char] } = ; +: --? ( a n -- ) s" --" str= ; +: eat} begin bl parse }? until ; also forth definitions -: { begin bl parse 2dup }? if 2drop exit then (local) again ; immediate +: { begin bl parse + 2dup --? if 2drop eat} exit then + 2dup }? if 2drop exit then + (local) again ; immediate : ; scope-clear postpone ; ; immediate only forth definitions diff --git a/ueforth/common/locals_tests.fs b/ueforth/common/locals_tests.fs index 3cc035d..7fbf9e2 100644 --- a/ueforth/common/locals_tests.fs +++ b/ueforth/common/locals_tests.fs @@ -36,3 +36,8 @@ e: test-longname : setPixelColor { pixelNum } pixelNum ; 1 setPixelColor 1 = assert ;e + +e: test-dash + : test { a b c -- a a b b c c } a a b b c c ; + 1 2 3 test * + * + * 23 = assert +;e