A Forth Interpreter written in C.
The AFI interpreter is designed to be cross platform, with system-specific frontends.
The AFI interpreter requires a C11 compiler with malloc.
The AFI standard frontend and test suite also requires the readline library.
To build the AFI static library and frontend, simply use make
.
By default, debugging symbols are included, if a smaller binary is preferred, use make RELEASE=y
.
To build a different frontend, use make TARGET=<somefrontend>
. Currently only test
and linux
are valid by default.
To build only the static library, use make afi.a
.
After building, the frontend binaries and static library should be in the bin/
subdirectory. Simply run one of the programs from the shell of your choice.
AFI is a stack based language, heavily based on FORTH. AFI currently works a lot like a Reverse Polish Notation calculator.
Currently, AFI has a very small standard library. This consists of arithmetic operations, branching, and basic stack operations.
These include:
+
,-
,*
,/
- Example:
2 4 + 3 - 4 *
will push 12 onto the stack.
- Example:
.
,.D
,PEEK
- Prints the top element of the stack to stdio, without changing the stack.
POP
- Prints the top element of the stack to stdio, and removes the element from the stack.
DROP
- Discards the top element of the stack without printing.
IF
,ELSE
,END
- If the top of the stack is non-zero, any code between
IF
andELSE
is executed. Otherwise, the code betweenELSE
andEND
is executed.
- If the top of the stack is non-zero, any code between