This code was written as a university project. The task description, written in Polish, can be found here. The specification of the Latte language for this task is available here. I chose Haskell for this project because I enjoy working with it, and it was recommended by the lecturer. This version (uploaded to GitHub) does not meet the technical requirements for code structure.
Compiler compiles Latte language program to x86_64.
gcc- for compiling C codeghc- for compiling Haskell codebnfc,alex,happy- for creating Latte parser
This code scored 30.5/34 points, the highest score among students in my year.
make
Makefilesrc/- source filesbuild/latc_x86_64- compiled BNFC files for the grammar described insrc/Grammar.cfbuild/Grammar/- compiled BNFC files for the grammar described insrc/Grammar.cflib/runtime.o- compiled built-in functions fromsrc/runtime.ctests/- test cases for the compiler
The current conflict is a well-known issue with if (...) if (...) ... else ....
The parser resolves this conflict by applying the shift operation, ensuring that else is associated with the nearest preceding if, which aligns with our intuition.
- Arrays
- Structures
- Objects
- Virtual methods
- Garbage collection (instead of a la Rust's memory management)
- LCSE/GCSE (Local/Common Subexpression Elimination)
- Constant propagation (enabled under the
-O2compilation flag)
Library and helper functions are included in lib/runtime.o (source code in src/runtime.c).