Interpreted strings.

This commit is contained in:
Brad Nelson
2021-01-02 12:45:26 -08:00
parent a9ec95c110
commit 20ec30514a
2 changed files with 12 additions and 7 deletions

View File

@ -40,7 +40,11 @@ out/web/ueforth.js: \
out/posix:
mkdir -p out/posix
out/posix/ueforth: posix/posix_main.c common/opcodes.h | out/posix
out/posix/ueforth: \
posix/posix_main.c \
common/opcodes.h \
common/core.h \
out/gen/boot.h | out/posix
$(CC) $(CFLAGS) $< -o $@ $(LIBS)
out/arduino:

View File

@ -118,12 +118,13 @@ variable hld
: ? ( a -- ) @ . ;
( Strings )
: $. r@ dup cell+ swap @ type r> dup @ aligned + cell+ >r ;
: ." [char] " parse postpone $. dup , 0 do dup c@ c, 1+ loop drop align ; immediate
: $@ r@ dup cell+ swap @ r> dup @ aligned + cell+ >r ;
: s" [char] " parse postpone $@ dup , 0 do dup c@ c, 1+ loop drop align ; immediate
: z$@ r@ cell+ r> dup @ aligned + cell+ >r ;
: z" [char] " parse postpone z$@ dup 1+ , 0 do dup c@ c, 1+ loop drop 0 c, align ; immediate
: parse-quote ( -- a n ) [char] " parse ;
: $place ( a n -- ) 0 do dup c@ c, 1+ loop drop 0 c, align ;
: $@ r@ dup cell+ swap @ r> dup @ 1+ aligned + cell+ >r ;
: s" parse-quote state @ if postpone $@ dup , $place
else dup here swap >r >r $place r> r> then ; immediate
: ." postpone s" state @ if postpone type else type then ; immediate
: z" postpone s" state @ if postpone drop else drop then ; immediate
( Examine Dictionary )
: >name ( xt -- a n ) 3 cells - dup @ swap over aligned - swap ;