STAKAN interprets a Forth-like language. Uses a somewhat heavy long double
stack.
I am writing STAKAN to:
- learn principles of concatenative languages
- implement something real in C (previously I tried to make a Lisp in C and that didn't go quite well)
- understand how compilers work
- have some fun during the summer
- Read words
- Parse words into tokens
- Evaluate words
- Implement some primeops
- Implement
:
and;
- Implement
branch
andbranch?
- Implement
if
,then
,else
- Implement the
until
loop - Implement all Forth primitives
- Write a useful standard library (maybe, some web server - stuff)
- Get the code reviewed by someone who is proficient in C
- ...
You can define your own words both in run-time or at compile-time.
Run-time words are defined in STAKAN itself by using : (...) ;
construction:
: double 2 * ;
: quad double double ;
Compile-time native words are defined in C language using convenience macros defined in nwords.h
:
NWORD(double) {
PUSH(2);
MUL();
}
NWORD(quad) {
DOUBLE();
DOUBLE();
}
To compile and run:
git clone https://github.com/ksixty/stakan && cd stakan && make run