Fox is a imperative language designed to be both interpreted and compiled.
The src/Parser.hs is based on combinator parser. It does not rely on famous library like parsec or so.
The src/Backend.hs is a monadic one. It is based on a State monad and supports partial Runtime Error such as undefined variables.
The src/Codegen.hs compiles to the LLVM 15 IR. It is based on top of the llvm-hs
package, which is a submodule of this project.
This allows one to compile to any target or to apply smart optimizations.
The project is based on llvm-hs, which we will build from source. To do so, clone the submodules :
git submodule init
Once done, make sure you have LLVM installed on your machine. A 15.x version is required. On MacOS, just run brew install llvm@15
Just run :
make
You have sample files in the sample
directory. To parse the file hello.fox
, just run :
./fox parse samples/fibo.fox
You have sample files in the sample
directory. To run the file hello.fox
, just run :
./fox run samples/hello.fox
You have sample files in the sample
directory. To compile the file hello.fox
, just run :
./fox compile samples/hello.fox
This will generate a fox.lc
file inside the samples
folder.
To build the object files, run :
llc -filetype=obj samples/fox.lc -o samples/fox.o -opaque-pointers
To compile the final binary (using clang):
clang samples/fox.o -o foxy