From add154df51a5a31464ae3ba8cc1cc970981659f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Wed, 17 Nov 2021 18:34:35 +0100 Subject: [PATCH] move junk to subfolder, add readme --- README.md | 77 ++++++++++++++++++++ a.forth => testfiles/a.forth | 0 defined.f => testfiles/defined.f | 0 doloop.forth => testfiles/doloop.forth | 0 exit.forth => testfiles/exit.forth | 0 hello.forth => testfiles/hello.forth | 0 if.forth => testfiles/if.forth | 0 loops.forth => testfiles/loops.forth | 0 overwrite.forth => testfiles/overwrite.forth | 0 postpone.forth => testfiles/postpone.forth | 0 str.forth => testfiles/str.forth | 0 11 files changed, 77 insertions(+) create mode 100644 README.md rename a.forth => testfiles/a.forth (100%) rename defined.f => testfiles/defined.f (100%) rename doloop.forth => testfiles/doloop.forth (100%) rename exit.forth => testfiles/exit.forth (100%) rename hello.forth => testfiles/hello.forth (100%) rename if.forth => testfiles/if.forth (100%) rename loops.forth => testfiles/loops.forth (100%) rename overwrite.forth => testfiles/overwrite.forth (100%) rename postpone.forth => testfiles/postpone.forth (100%) rename str.forth => testfiles/str.forth (100%) diff --git a/README.md b/README.md new file mode 100644 index 0000000..28bc83a --- /dev/null +++ b/README.md @@ -0,0 +1,77 @@ +Forth +===== + +This is a new implementation of Forth 2012 in C. + +Building & use +-------------- + +Use cmake or `build.sh`. It probably needs GCC with `--std=gnu99`. + +You get a binary with the forth runtime. Run it to get a prompt. Use `-h` for help. + +Goals +----- + +- Comfy to use and extend +- No dynamic allocation where possible +- Compact and embeddable so it can be ported to ARM-CortexM or similar later +- Implement the CORE and CORE-EXT word sets, for a start +- Pass the [Forth2012 test suite](https://github.com/gerryjackson/forth2012-test-suite), at least for the word sets that are implemented +- Maybe eventually have some terminal-based implementation of a subset of the Facility word set, like AT-XY and keyboard input +- Try to keep added custom words and quirks at a minimum +- Comment stuff, maybe + +Non-Goals +--------- + +- I don't really care about implementing some of the word sets +- Performance is not so critical for a hobby Forth like this +- Probably won't accept merge requests, this is my Forth +- I also don't care about someone telling me to add a license file + +Custom words +------------ +- `.\"` - like `."` but allows escaping, this is essentially `S\" blah" TYPE`, but without allocation (unless compiled) +- `??` - debug dump of the stacks +- `reset` - everything should become like if you restarted the program +- `debug ( flag -- )` - enable or disable verbose logging + +For debug, there is `see ( "word" -- )` that lets you inspect and disassemble dictionary entries. + +Implementation status +--------------------- + +*(this section may be outdated)* + +Implemented: + +``` +CORE: +! ' ( * */ */MOD + +! +LOOP , - . ." / /mod 0< 0= 1+ 1- 2! 2* 2/ 2@ 2DROP 2DUP 2OVER 2SWAP +: ; < = > >IN >R ?DUP @ ABORT ABS ALIGN ALIGNED ALLOT AND BASE BEGIN BL CELL CELL+ CELLS CHAR CHAR+ +CHARS CONSTANT COUNT CR CREATE DECIMAL DEPTH DO DROP DUP ELSE EMIT ENVIRONMENT? EXECUTE EXIT FIND +HERE I IF IMMEDIATE INVERT J LEAVE LITERAL LOOP MOD NEGATE OR OVER POSTPONE QUIT R> R@ RECURSE +REPEAT ROT S" SOURCE SPACE SWAP THEN TYPE U< UNTIL VARIABLE WHILE WORD XOR [ ['] [CHAR] ] + +CORE-EXT: +.( 0<> 0> 2>R 2R> 2R@ <> ?DO AGAIN FALSE HEX NIP PAD PICK ROLL S\" TO TRUE TUCK U.R U> UNUSED VALUE +\ + +Other sets: +FORGET SEE BYE +``` + +Missing: + +``` +CORE: +# #> #S <# >BODY >NUMBER ABORT" ACCEPT C! C, C@ DOES> EVALUATE FILL FM/MOD HOLD KEY LSHIFY M* MAX +MIN MOVE RSHIFT S>D SIGN SM/REM SPACES STATE U. UM* UM/MOD UNLOOP + +CORE-EXT: +.R :NONAME ACTION-OF BUFFER: C" CASE COMPILE, DEFER DEFER! DEFER@ ENDCASE ENDOF ERASE HOLDS IS +MARKER OFPARSE PARSE-NAME REFILL RESTORE-INPUT SAVE-INPUT SOURCE-IDWITHIN [COMPILE] +``` + +. diff --git a/a.forth b/testfiles/a.forth similarity index 100% rename from a.forth rename to testfiles/a.forth diff --git a/defined.f b/testfiles/defined.f similarity index 100% rename from defined.f rename to testfiles/defined.f diff --git a/doloop.forth b/testfiles/doloop.forth similarity index 100% rename from doloop.forth rename to testfiles/doloop.forth diff --git a/exit.forth b/testfiles/exit.forth similarity index 100% rename from exit.forth rename to testfiles/exit.forth diff --git a/hello.forth b/testfiles/hello.forth similarity index 100% rename from hello.forth rename to testfiles/hello.forth diff --git a/if.forth b/testfiles/if.forth similarity index 100% rename from if.forth rename to testfiles/if.forth diff --git a/loops.forth b/testfiles/loops.forth similarity index 100% rename from loops.forth rename to testfiles/loops.forth diff --git a/overwrite.forth b/testfiles/overwrite.forth similarity index 100% rename from overwrite.forth rename to testfiles/overwrite.forth diff --git a/postpone.forth b/testfiles/postpone.forth similarity index 100% rename from postpone.forth rename to testfiles/postpone.forth diff --git a/str.forth b/testfiles/str.forth similarity index 100% rename from str.forth rename to testfiles/str.forth