This repository is a C compiler for x86 implemented at INSA Lyon.
- Rivaldo De Souza
- Emmanuel Garreau
- Mathis Goichon
- Bérenger Mayoud--Dupin
- Paul Souteyrat
To build the project, go to CompilerC directory and use:
cmake -B build
cmake --build build --target compiler
Prefer use WSL Ubuntu and run the two commands given above.
To run the test framework, you have to:
cd tests
python3 ifcc-test.py .
If you make any change in the grammar, you can generate Cpp code with the following commands:
cd compiler
java -cp ../antlr-4.10.1-complete.jar org.antlr.v4.Tool -lib ./ -visitor -listener -Dlanguage=Cpp -o ./generated ./ifcc.g4
We have implemented a CI/CD which build and execute the tests.
You can access our workflows through the Actions tab and then by selecting one of the jobs.
You will find a full report in the unit test result : https://github.com/PeredurOmega/CompilerC/actions/runs/2503655455
You can also download the artifact of the test output.
Features to implement (x86):
- Variable declaration
- Multiple declaration (int a, b, c)
- Anywhere variable declaration
- Variable assignment
- Multiple assignment (int a = b = c)
- Variable initialisation (a = 0)
- Function declaration with int and void type (call not implemented)
- Multiple functions declaration (call not implemented)
- Ignore comments
- Supporting int type (32 bits)
- Constant support
- Arithmetics operations (+, -, *, /, %)
- Bitwise logical operations (&, |, ^)
- Comparison operator (==, !=, <, <=, >, >=)
- Logical operator (&&, ||)
- Unary operators (+, -, !, ~)
- Shift bit operator (>>, <<)
- Block structure
- Conditional structure (if else)
- Return support
- Empty function support
- Empty return support
- IR migration
- Conditional return support
- While
- Always return optimization
- Do not compile on assignment in single line if-else-else if-while statements
- Break and Continue keyword
- Char support
- Statical analysis (variable scope, shadowing)
- Function call
- For
- Switch case
- Arrays
- Pointers
- Various optimisation