Implementation of a compiler for the functional programming language Llama
most if not all of what is specified here
some worth mentioning are:
- User defined types
- Structural equality
- Type inference
- Function closures
- Garbage collection
- Floating point arithmetic
- Optimizations
- Modular execution
./llamac -help # produces a help message
./llamac [llama-source-file] # optionally can add -o [executable-file-name]
./llamac [llama-source-file] -i -o [llvm-IR-file-name] -frontend compile # produces IR source file
./llamac [llama-source-file] -S -o [assembly-file-name] -frontend compile # produces assembly source file
./llamac [llama-source-file] -ast -frontend syntax -o [ast-output-file-name]
./llamac [llama-source-file] -idtypes -frontend inf # prints inferred type information
make
to create a production version
(clang required to fully produce executable, else stops at object file)
Dependency installation tips
-
sudo apt install nasm
necessary for library compilation -
libgc build from source for garbage collection (can be disabled in makefile) Build summary:
git clone git://github.com/ivmai/bdwgc.git cd bdwgc git clone git://github.com/ivmai/libatomic_ops.git ./autogen.sh ./configure make -j make check make install
-
Bison build from source:
wget http://ftp.gnu.org/gnu/bison/bison-3.7.6.tar.gz tar -zxvf bison-3.7.6.tar.gz cd bison-3.7.6/ sudo ./configure sudo make sudo make install # sudo ln -s /usr/local/bin/bison /usr/bin/bison # (possibly necessary)
-
sudo apt install flex
should be enough -
LLVM Install precompiled binaries source
wget [proper-tarball-url] sudo tar -xf [tarbal name].tar.xz --strip-components=1 -C [install-dir] export PATH=$PATH:[install-dir]/bin cd [install-dir] sudo echo [install-dir]/lib >> /etc/ld.so.conf.d/libs.conf # make sure it's in a new line sudo ldconfig
check installation with
llvm-config --version
-
Build garbage collector from source more docs
Component | Tools |
---|---|
Lexer | Flex v2.6.4 |
Parser | Bison v3.7.6 |
Semantic analysis | C++11 |
Backend | LLVM v10.0.0 |
- Jason Chatzitheodorou (School ID: 03117089)
- Orfeas Zografos (School ID: 03117160)
- Assembly runtime library (altered and bundled in libllama directory)
- Boehm-Demers-Weiser conservative C/C++ Garbage Collector (optional)