-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Strange Forth is an implementation of Forth, as a scripting language. So, unlike a lot of Forths we don't compile to assembly language but an interpreted byte-code. One side goal is to add a JIT engine at some point, but for now at least, everything is interpreted.
This implementation was inspired by the article Forth: The programming language that writes itself. In particular the simplicity of the Forth language and it's powerful extensibility.
To illustrate this point, large portions of the language implementation are implemented in the standard library, std.f. Typically built in constructs like if, case, or loops are all implemented as forth words.
So, one of the goals of the project was to take Forth and make it interoperable with modern systems. To help towards this goal, the language server for this project itself is written in Strange Forth.
This project is still in it's early stages, there is a roadmap on the main page that will outline further goals for this project.
Start off by cloning the main repo.
git clone git@github.com:cstrainge/sorth.git
You can use the Makefile
to build the interpreter by running:
make default
In the project's root directory. This will generate the interpreter and copy the standard library into the ./build
directory.
To jump into the sorth repl either add the build
directory into the path or run:
./build/sorth
Once running in the repl you should get the standard welcome text:
Strange Forth REPL.
Enter quit, q, or exit to quit the REPL.
>>
You can also run the interpreter with a pre-written script by passing the path to the script on the command line:
sorth path\to\my\script.f
If you are on a Unix system you can make the script itself executable like other scripting languages. First make sure the executable sorth
is in your path.
Then add the following to the top of your script:
#!/usr/bin/env sorth
Now, normally # is not a comment character in the language. Right now, only brackets separated by spaces are proper comments, ( )
. However #!/usr/bin/env
and sorth
are defined as words in the standard library that do not do anything. This approach allows the language to have it's won comments without having to special case this in the interpreter.
If you are on Windows you can add *.f
to the Windows PATHEXT
environment variable. (This allows you to run the script without typing the .f at the command line. Just like with .exe
files.) Then you need to register the interpreter in the Windows registry under: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\
Please visit the following pages for more details about the language.