Skip to content

The ic compiler for pure lazy functional programming languages using intensional logic

Notifications You must be signed in to change notification settings

nikos-alexandris/ic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The ic compiler for pure lazy functional programming languages using intensional logic

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

Process

The process of compilation is:

  1. Parse the functional program
  2. Transform the functional program to a high level intermediate representation
  3. Compile the HIR to the intensional program
  4. Compile the intensional program to C
  5. Compile the C program to an executable and link it with the runtime library

Roadmap

Compiler

  • 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

Runtime

  • LARs (Only heap allocated, will change if types are added to the language)
  • Garbage Collection (Currently mark and sweep - pretty slow should be improved)

Dependencies

Running a program

Step 1: Cloning the repository

git clone https://github.com/nikos-alexandris/ic

Step 2: Setting up the environment variable

This 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)

Step 3: Building the compiler

cd $IC_HOME/compiler
cargo build --release

Leaves the executable ic in $IC_HOME/compiler/target/release/ic

Step 4: Building the runtime library

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

Step 5: Compiling the program

If the program is called prog.fl:

cd /path/to/program
$IC_HOME/compiler/target/release/ic prog.fl

Creates a _build subdirectory in the current directory with the generated executable out (and the generated C source code out.c)

Step 6: Running the program

_build/out

There are program examples in the examples/fl directory.

About

The ic compiler for pure lazy functional programming languages using intensional logic

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published