Compiler(s)
Update: Last year I add the opportunity to work on a new cleaner and more interesting compiler project. This last project was done there again with ANTLR4 and Java, using visitor pattern so that the code was organized better, and it allowed us to make more interesting Intermediate Representations optimizations ! The featured optimization are the following:
- Control Flow Graph (CFG) construction alongside the SSA form as well
- Constant propagation
- Dead code elimination
- Conditional constant propagation
- CFG and SSA simplifications
In addition, we added an error and warning management system. This project is not yet on any cleaned git repository, but when time permits, I will make it accessible.
Compiler MVAP (previous compiler project)
Compilation project from a Simple C-like language to a assembly-like language (MVaP). Using Java and Antlr 4. I have worked on a better compiler this year with a friend where we managed to do some real optimisation using CFG and SSA representation. So this project seems a little bit less interesting right now, and is a lot messier than what we did this year (will update on that someday).
Note on future compiler project: I would probably use something like Scala instead of Java.
This project features:
- global and local variable
- arithmetic operations (with or without variable)
- float support
- logic operations
- boolean support
- branchements (if else)
- loops (for/while) (with break and continue instructions supported)
- functions (with return and arguments)
- cast (and some implicit cast)
- array (with reference when passed to functions)
- warning and error notifications
- nested functions
- constant variable (checked only by the compiler)
Files informations: - Calculette.g4: contains the lexer and parser. - TablesSymboles.java: contains the needed tables of symbols for the global or local variables and functions. As well as well as some tables for some specific instructions. - TableSimple.java: is the structure for a single table. - VariableInfo.java: is the structure for a variable, indicating its scope, address, type and mutability.
Scripts: - launch_tests.sh: script used to launch all the test that are in benchmark. In order to run, you would need to have the antlr and mvap jar well placed. - run_t1_mvap.sh: used to run the t1.mvap file.
This was a very pleasant project and I am thrilled to work on new project leveraging langage theory.