The Latte compiler is implemented in Haskell and translates Latte language files into LLVM intermediate representation (IR). Latte is an imperative programming language, closely resembling a subset of the imperative features of Java. For a detailed definition of Latte, refer to the MRJP course page https://www.mimuw.edu.pl/~ben/Zajecia/Mrj2021/Latte/.
README.md
(this)Makefile
- src/
- file with gramma:
Latte.cf
- files generated by BNFC:
AbsLatte.hs
,LexLatte.hs
,ParLatte.hs
,ErrM.hs
- module with helper functions for stream:
StreamHelper.hs
- type checker module:
TypeChecker.hs
- llvm compiler module:
LLVMCompiler.hs
- main modules:
TCMain.hs
,LLVMMain.hs
- file with gramma:
- lib/
- predefined functions in
runtime.(ext)
- bc, ll, c
- predefined functions in
where BNFC files were generated with commands:
> bnfc --functor -m Latte.cf
> alex --ghc LexLatte.x
> happy --ghc --coerce --array --info ParLatte.y
- create
runtime.ll
fromruntime.c
clang -emit-llvm -S runtime.c -o runtime.ll
- create
runtime.bc
fromruntime.ll
llvm-as runtime.ll
make
- Import tests (lattests directory) from MRJP labs into main directory.
Running latc
(in main directory, runs type checker):
> ./latc foo/bar/baz.lat
in return we get ERROR / OK answer in stderr,
if ERROR there is additonal line with information about its location in latte code
Running latc_llvm
(in main directory, runs compiller with type checker):
> ./latc_llvm foo/bar/baz.lat
creates files baz.ll
and baz.bc
For type checker:
make latc_tests
For compiller:
make latc_llvm_tests
- First iteration - frontend, type checker
- Second iteration - backend (base) in LLVM
- Third iteration - latte extensions:
- registers and phi (2)
- optimisations: LCSE (3)
- extensions: arrays, structures, objects (6)
- xcode-select version 2408.
- The GHCup Haskell installer, version 0.1.30.0
- The Glorious Glasgow Haskell Compilation System, version 9.10.1
- Homebrew clang version 17.0.6
- Homebrew LLVM version 17.0.6
- bnfc 2.9.4
- Alex version 3.2.7.1, (c) 2003 Chris Dornan and Simon Marlow
- Happy Version 1.20.0 Copyright (c) 1993-1996 Andy Gill, Simon Marlow (c) 1997-2005 Simon Marlow