A portable and concise Forth implementation in modern C++
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Go to file
Clyne 4b50a9fafe
move main execution to State; bring back verify()
1 year ago
forth move main execution to State; bring back verify() 1 year ago
libalee move main execution to State; bring back verify() 1 year ago
msp430 msp430: add compressed register/flag wordset 1 year ago
tests@45b7ecc1e3 support long definitions; add tests as submodule 1 year ago
.gitignore msp430: add compressed register/flag wordset 1 year ago
.gitmodules support long definitions; add tests as submodule 1 year ago
LICENSE initial commit 2 years ago
Makefile msp430: clean up some build flags 1 year ago
README.md add SOURCE-ID 1 year ago
alee-standalone.cpp fix execute; disable verify(); bench w/ standalone 1 year ago
alee.cpp fib.fth benchmark; some minor coreword optimizations 1 year ago
alee.hpp move libalee into folder 2 years ago
memdict.hpp -Wconversion 2 years ago
splitmemdict.hpp fix execute; disable verify(); bench w/ standalone 1 year ago
splitmemdictrw.hpp forgot to push msp430 dict impl 1 year ago

README.md

Alee Forth

Alee Forth is a concise Forth implementation written in modern C++ that aims for portability, minimal memory footprint, and execution efficiency.

Cross-platform compatibility

Alee Forth relies on the C++20 standard. It does not rely on any operating system. As a result, portability extends down to microcontroller targets with < 16kB flash and < 1 kB of RAM. See the msp430 folder for an example of such a port.

System-specific functionality is achieved through a sys Forth word. This word calls a user-supplied C++ function that implements whatever functionality is needed.

Forth compatibility

Alee Forth uses the Forth 2012 test suite to ensure standards compliance. The entire "core" word-set is implemented as well as most of the "core extension" word-set. The compiled program contains a minimal set of fundamental words with libraries in the forth directory supplying these larger word-sets. The "core" word-set can be compiled into the program by building the standalone target.

Missing core extension words:

PARSE-NAME REFILL RESTORE-INPUT S\" SAVE-INPUT

Building

Alee requires make and a compiler that supports C++20. Simply running make will produce the libalee.a library and a REPL binary named alee. The core word-sets can be passed into alee via the command line: ./alee forth/core.fth forth/core-ext.fth.

Other available build targets:

  • small: Optimize for minimal binary size.
  • fast: Optimize for maximum performance on the host system.
  • standalone: Builds the core dictionary (core.fth) into the binary.
  • msp430-prep and msp430: Builds a binary for the MSP430G2553 microcontroller. See the msp430 folder for more information.

If building for a new platform, review these files: Makefile, libalee/types.hpp, and libalee/state.hpp. It is possible to modify the implementation to use 32-bit words, but this will require re-writing the core word-sets.