This is the master branch. The latest (development) branch is the types branch which features a rewrite of the compiler and runtime to support types and a codebase that has been refactored to be much cleaner and more modular
The process of compilation is:
- Parse the functional program
- Transform the functional program to a high level intermediate representation
- Compile the HIR to the intensional program
- Compile the intensional program to C
- Compile the C program to an executable and link it with the runtime library
- Parse functional programs as shown in
prog.fl - Peform error checking on the functional program (undefined variables, wrong argument arities, definition of nullary variable
result, etc.) - Handle function local arguments in the functional source program
- Transform the functional program to a high level intermediate representation
- Transform the HIR to the equivalent intensional program
- Compile the intensional program to C
- Don't require the user to compile and link the generated code; do it automatically
- Compiler code is 💩 needs cleanup/simplification
- LARs (Only heap allocated, will change if types are added to the language)
- Garbage Collection (Currently mark and sweep - pretty slow should be improved)
-
The Rust toolchain (https://www.rust-lang.org/tools/install)
-
CMake (https://cmake.org/install/)
git clone https://github.com/nikos-alexandris/icThis is needed for the compiler to know where the runtime library is located. This should be set to the root of the repository you just cloned.
cd ic
export IC_HOME=$(pwd)cd $IC_HOME/compiler
cargo build --releaseLeaves the executable ic in $IC_HOME/compiler/target/release/ic
cd $IC_HOME/runtime
mkdir lib
cd lib
cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..
make -j $(nproc)Leaves the static library libic.a in $IC_HOME/runtime/lib/libic.a
If the program is called prog.fl:
cd /path/to/program
$IC_HOME/compiler/target/release/ic prog.flCreates a _build subdirectory in the current directory with the generated executable out (and the generated C source code out.c)
_build/outThere are program examples in the examples/fl directory.