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 1960aa8773 update readme; make msp430 standalone 2 years ago
test evaluate complete 2 years ago
.gitignore build core.fth into executable 2 years ago
LICENSE initial commit 2 years ago
Makefile update readme; make msp430 standalone 2 years ago
README.md update readme; make msp430 standalone 2 years ago
alee-msp430.cpp update readme; make msp430 standalone 2 years ago
alee-standalone.cpp build core.fth into executable 2 years ago
alee.cpp add case/endcase of/endof 2 years ago
alee.hpp build as library; add small target 2 years ago
compat.txt add case/endcase of/endof 2 years ago
core.fth add case/endcase of/endof 2 years ago
corewords.cpp word, division compliance 2 years ago
corewords.hpp major compliance refactor; undo packed literals for now 2 years ago
dictionary.cpp evaluate complete 2 years ago
dictionary.hpp add case/endcase of/endof 2 years ago
memdict.hpp major compliance refactor; undo packed literals for now 2 years ago
parser.cpp evaluate complete 2 years ago
parser.hpp wip: evaluate 2 years ago
splitmemdict.hpp build core.fth into executable 2 years ago
state.cpp packed literals; faster execution 2 years ago
state.hpp packed literals; faster execution 2 years ago
types.hpp double-width mul/div; error strings 2 years ago

README.md

Alee Forth

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

Cross-platform compatibility

Alee relies on the C++17 standard. Alee does not rely on operating-system-specific functions, making portability easy.

The goal of portability extends down to microcontroller targets with kilobytes of memory. See the msp430 target for an example of a port.

System-specific functionality is obtained through a sys Forth word. This word calls a user-supplied C++ function that implements the necessary (or any additional) functionality.

Forth compatibility

Alee implements a large majority of the "core" and "core extension" glossaries. Implementation is tracked in compat.txt, with missing words listed below. Fundamental words are built into Alee (written in C++); the rest of the implementation is in core.fth.

This means Alee should be executed as alee core.fth to include these words. Alternatively, the standalone target packages the core.fth dictionary into the program.

Missing core features:

  • Pictured numeric output conversion <# #>
  • Words for unsigned integers: U. U< UM* UM/MOD
  • >NUMBER
  • FIND

Missing core extensions:

.R HOLDS PAD PARSE PARSE-NAME REFILL RESTORE-INPUT S\" SAVE-INPUT SOURCE-ID U.R U> UNUSED WITHIN [COMPILE]

Alee aims for compliance with common Forth standards like Forth 2012 and ANS Forth. Compliance is tested using a Forth 2012 test suite. Supported test files are in the test directory, with tests for unimplemented words commented out.

Building

Alee requires make and a C++17-compatible compiler.

To compile, simply run the make command. This will produce a library, libalee.a, as well as a REPL binary named alee.
A small target exists that optimizes the build for size.
A fast target exists that optimizes for maximum performance on the host system. The standalone target will produce a alee-standalone binary that contains and pre-loads the core dictionary. The msp430 target builds Alee for the MSP430G2553 microcontroller. Like standalone, the core dictionary is built into the binary.

Configurable constants and types are defined either in the Makefile or in types.hpp.