r/Forth • u/PETREMANN • 8d ago
Using <EOF> to break interpretation/compilation after INCLUDE a file
Hi,
Here the definition of <EOF> for eForth Windows:
\ stop compilation before end of included file
: <EOF> ( -- )
#tib @ >in ! ;
I use this word in my FORTH files—which are loaded via `INCLUDE`—for two distinct purposes:
- when I include text-based documentation after `
<EOF>` - when I am debugging a program; I use it to store experimental code or test versions of certain definitions.
When I execute `INCLUDE <file>`, the FORTH compiler loads `<file>` and stops the loading process upon encountering `<EOF>`.
5
Upvotes
1
u/tabemann 8d ago
The equivalent in zeptoforth:
wouldn't work because in zeptoforth files are parsed line by line to avoid requiring a buffer in RAM for containing the largest possible source file and also because
utils/codeload3.shuploads source files line by line.As mentioned by u/mykesx, I recommend the use of:
to ignore blocks of text.
2
u/mykesx moderator 8d ago
There’s also [defined] [undefined] and [if] [then] [else] in some forths. It allows you to stop compilation of any sections of code.
false [if] … [then]
2
u/alberthemagician 8d ago
In my simple Forth I have
If you put EXIT outside of a definition, it terminates: