a minimal toy Forth language
Go to file
2024-07-12 02:30:50 -04:00
3th.lua added composite word checking in compilation step when defining new words 2024-07-12 02:30:50 -04:00
input.3th clean 2024-06-13 06:27:17 -04:00
LICENSE.txt 0.0.1 baseline 2024-06-12 21:40:02 -04:00
README.md update usage 2024-07-11 14:55:15 -04:00

3th

A minimal toy forth in Lua.

2024-07-12: This is currently incomplete and in progress. Conditionals and loops are yet to be implemented. The code is not fixed and flags, primitives, help info, etc may change.

Usage

3th - Forth language in Lua [3th 0.0.1 2024-07-11]
Usage: 
3th [-r | --repl]                  Start REPL. 
    [-v | --version]              Print version info.
    [-e | --evaluate "INPUTLINE"]  Evaluate input.
    [-f | --file INPUTSCRIPT]      Execute script file.
    [-p | --pipe]                 Process piped standard input then quit.
    [-d | --debug]                Turn on debugger output.
    [-h | --help]                  Print usage info.

Running 3th without arguments launches an interactive REPL. Type bye to quit.

Documentation

Forthcoming!

For a list of words, type words.

See also

Learn a language by writing too many Forths by Serge Zaitsev

Forth, The Lego of Programming Languages by Jeff Fox

Forth: The Hackers Language by Elliot Williams, Hackaday

More About Tiny Scripting Languages by No Time To Play

Lost At C? Forth May Be the Answer by Tom Napier & Eric Krieg from Circuit Cellar

Research

Re: a tutorial on bootstrapping forth? (comp.lang.forth via archive.org)

Starting Forth by Leo Brodie

Forth: The Programming Language that writes itself by Dave Gauer

Concatenative and Forth by Devine Lu Linvega via XXIIVV

A more high-level explanation of Forth by ruvim via Stack Overflow

Stellaris Unofficial UserDoc

Forth on One Laptop Per Child

An Introduction to Forth Using StackFlow

TODO

  • minimal forth with a few instructions and premade stack
  • repl
  • minimal forth that reads program from disk
  • convert big if-ladder to a lookup table
  • minimal forth that allows user to add words to the stack, and memorizes them
  • conditionals
  • stack comments
  • string output
  • add help and put word-lookup in known_words table
  • add documentation

License

Copyright ©LT 2024. Released under the terms of the ACSL 1.4.

Notes

Notice: an IF…THEN statement must be contained within a definition. You cant just enter these words in “calculator style.” from Starting Forth, chapter 4, Lee Brodie

PICK indexing begins at 1, as it does in FIG FORTH, as described in the SoftSynth.com Forth Tutorial

Warning. The Forth-79 and FIG Forth standards differ from the ANS and Forth '83 standard in that their PICK numbering starts with one, not zero.