Adding vocabularies.
This commit is contained in:
@ -113,7 +113,7 @@ unit_tests: $(POSIX)/ueforth common/all_tests.fs
|
|||||||
$(GEN):
|
$(GEN):
|
||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
|
|
||||||
POSIX_BOOT = common/boot.fs common/ansi.fs \
|
POSIX_BOOT = common/boot.fs common/vocabulary.fs common/ansi.fs \
|
||||||
posix/posix.fs posix/posix_highlevel.fs \
|
posix/posix.fs posix/posix_highlevel.fs \
|
||||||
common/highlevel.fs common/filetools.fs posix/posix_desktop.fs \
|
common/highlevel.fs common/filetools.fs posix/posix_desktop.fs \
|
||||||
common/tasks.fs common/streams.fs common/blocks.fs posix/args.fs \
|
common/tasks.fs common/streams.fs common/blocks.fs posix/args.fs \
|
||||||
@ -121,14 +121,14 @@ POSIX_BOOT = common/boot.fs common/ansi.fs \
|
|||||||
$(GEN)/posix_boot.h: common/source_to_string.js $(POSIX_BOOT) | $(GEN)
|
$(GEN)/posix_boot.h: common/source_to_string.js $(POSIX_BOOT) | $(GEN)
|
||||||
echo "ok" | cat $(POSIX_BOOT) - | $< boot >$@
|
echo "ok" | cat $(POSIX_BOOT) - | $< boot >$@
|
||||||
|
|
||||||
WINDOWS_BOOT = common/boot.fs common/ansi.fs \
|
WINDOWS_BOOT = common/boot.fs common/vocabulary.fs common/ansi.fs \
|
||||||
windows/windows.fs windows/windows_highlevel.fs common/highlevel.fs \
|
windows/windows.fs windows/windows_highlevel.fs common/highlevel.fs \
|
||||||
common/tasks.fs common/streams.fs common/blocks.fs \
|
common/tasks.fs common/streams.fs common/blocks.fs \
|
||||||
common/utils.fs
|
common/utils.fs
|
||||||
$(GEN)/windows_boot.h: common/source_to_string.js $(WINDOWS_BOOT) | $(GEN)
|
$(GEN)/windows_boot.h: common/source_to_string.js $(WINDOWS_BOOT) | $(GEN)
|
||||||
echo "ok" | cat $(WINDOWS_BOOT) - | $< boot >$@
|
echo "ok" | cat $(WINDOWS_BOOT) - | $< boot >$@
|
||||||
|
|
||||||
ARDUINO_BOOT = common/boot.fs arduino/arduino.fs \
|
ARDUINO_BOOT = common/boot.fs common/vocabulary.fs arduino/arduino.fs \
|
||||||
posix/posix_highlevel.fs common/highlevel.fs common/filetools.fs \
|
posix/posix_highlevel.fs common/highlevel.fs common/filetools.fs \
|
||||||
common/tasks.fs common/streams.fs arduino/arduino_server.fs \
|
common/tasks.fs common/streams.fs arduino/arduino_server.fs \
|
||||||
arduino/esp_camera.fs common/blocks.fs common/utils.fs \
|
arduino/esp_camera.fs common/blocks.fs common/utils.fs \
|
||||||
|
|||||||
@ -2,4 +2,5 @@ include common/testing.fs
|
|||||||
include common/utils.fs
|
include common/utils.fs
|
||||||
include common/base_tests.fs
|
include common/base_tests.fs
|
||||||
include common/utils_tests.fs
|
include common/utils_tests.fs
|
||||||
|
include common/vocabulary_tests.fs
|
||||||
run-tests
|
run-tests
|
||||||
|
|||||||
@ -127,8 +127,13 @@ static void ueforth_init(int argc, char *argv[], void *heap,
|
|||||||
g_sys.heap = (cell_t *) heap + 4; // Leave a little room.
|
g_sys.heap = (cell_t *) heap + 4; // Leave a little room.
|
||||||
cell_t *sp = g_sys.heap + 1; g_sys.heap += STACK_SIZE;
|
cell_t *sp = g_sys.heap + 1; g_sys.heap += STACK_SIZE;
|
||||||
cell_t *rp = g_sys.heap + 1; g_sys.heap += STACK_SIZE;
|
cell_t *rp = g_sys.heap + 1; g_sys.heap += STACK_SIZE;
|
||||||
|
|
||||||
|
// FORTH vocabulary
|
||||||
|
*g_sys.heap++ = 0;
|
||||||
g_sys.current = (cell_t **) g_sys.heap;
|
g_sys.current = (cell_t **) g_sys.heap;
|
||||||
g_sys.context = (cell_t **) g_sys.heap; ++g_sys.heap;
|
g_sys.context = (cell_t **) g_sys.heap; ++g_sys.heap;
|
||||||
|
*g_sys.heap++ = 0; *g_sys.heap++ = 0; *g_sys.heap++ = 0;
|
||||||
|
|
||||||
ueforth_run(0);
|
ueforth_run(0);
|
||||||
(*g_sys.current)[-1] = 1; // Make last word ; IMMEDIATE
|
(*g_sys.current)[-1] = 1; // Make last word ; IMMEDIATE
|
||||||
g_sys.DOLIT_XT = FIND("DOLIT");
|
g_sys.DOLIT_XT = FIND("DOLIT");
|
||||||
|
|||||||
4
ueforth/common/vocabulary.fs
Normal file
4
ueforth/common/vocabulary.fs
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
( Implement Vocabularies )
|
||||||
|
: forth [ current @ ] literal context ! ;
|
||||||
|
: vocabulary ( "name" ) create 0 , current @ 2 cells + , does> cell+ context ! ;
|
||||||
|
: definitions context @ current ! ;
|
||||||
13
ueforth/common/vocabulary_tests.fs
Normal file
13
ueforth/common/vocabulary_tests.fs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
e: test-vocabularies
|
||||||
|
vocabulary foo
|
||||||
|
vocabulary bar
|
||||||
|
foo definitions : test ." AAAA" cr ;
|
||||||
|
bar definitions : test ." BBBB" cr ;
|
||||||
|
forth definitions
|
||||||
|
foo test
|
||||||
|
bar test
|
||||||
|
foo test
|
||||||
|
out: AAAA
|
||||||
|
out: BBBB
|
||||||
|
out: AAAA
|
||||||
|
;e
|
||||||
Reference in New Issue
Block a user