2024 Compilation Project Report - COREC Compiler
The project
The main goal of this project is to build a COREC compiler, from high-level syntax to low-level syntax (assembly language). See the project subject here.
You may also be interested in the architecture of the project and the test report.
Parameters
-
-o output.asm
-> write the result in the output.asm. -
-version
-> show the credits. -
-tos
-> show the symbole table.
Prerequisites
- Install flex :
sudo apt install flex
- Install bison :
sudo apt install bison
-
To run mips code, you need:
-
Java :
sudo apt install default-jdk
-
MIPS simulator :
Download MARS : MIPS java simulator on moodle unistra and deplace it in the root of the project.
-
Implemented Features
1. branch test1
- Definition of local variable in the loc section of functions. *
- Affectation of integer value.
- Print and printstr functions.
2. branch test2
- Operation on variable (except arrays) -> (+,-,*,/).
- Assignement operation on variable (except arrays) -> (+=,-=,*=,/=).
3. branch test3
- Affectation and definition of local 1D array.
4. branch test4
- Operation with and on local 1D array.
- print function works on array.
5. branch test5
- float value as singleton array.
- Cast integer in float if integer affectation to arrays or multiplication of a float and an integer. (Implicit)
6. branch test6
- Affectation multi dimensional array.
7. branch test7
- Operations on multi dimensional array.
8. branch test8
- conditional code execution
9.branch test9
- Read an int into an int variable
- Read a float into a float variable
10.branch test10
- implemented DOM for main and functions
See in the test report file the report on COREC tests features and error detection.
To Do
- Translate intermediate code of the testN branch in mips.
- Add to the symtable in the beginning of the programm COREC key words (def, prog, Loc, Rec, ...) to recognize without the lex. Not sure
- Possibility to add an attribut of type variable (INT, FLOAT, ARRAY) to the symbol structure for temporary variable and variable, to know what, the affectation value type is (Maybe with an enum). And when declare, the variable are set to none. This would provide a better error detection of implicit cast.
- Call of functions (verify arguments, etc)
Makefile commands
-
make
-> compile the source files -
compil
-> run project executable on the input.txt file, create and write the result onoutput/output.asm
file. -
run
-> test with Mars (Mars4_5.jar
) theoutput/output.asm
file. -
version
-> same asrun
but shows credits. -
tos
-> same asrun
but shows the table of symbole. -
clean
-> clean the directory.
For developpment (add tokens display in the lex file):
-
test num=N
-> run project executable and test it onCodes_en_COREC/tests/testN.corec
file. By default,num
is equal to 1. -
testTo num=N
-> run project executable and test it on everyCodes_en_COREC/tests/testX.corec
files where X <= N. By default,num
is equal to 1. -
testErr num=N
-> run project executable and test it onCodes_en_COREC/testsErrors/testNErr.corec
file. By default,num
is equal to 1. The test should return an error by the compiler. -
check num=N
-> run project executable and check valgrind error onCodes_en_COREC/tests/testN.corec
file. By default,num
is equal to 1. -
checkErr num=N
-> run project executable and check valgrind error onCodes_en_COREC/testsErrors/testNErr.corec
file. By default,num
is equal to 1. The test should return an error by the compiler. -
test_corec
-> run project executable and test it on 7 COREC files examples inCodes_en_COREC/
directory.
Need more on commands for the project ? Go here.
Members
The four members are :
- Julien CLAVEL (CMI SIRIS).
- Jaenai RUGENGANDE IHIMBAZWE (CMI SIRIS).
- Constantin ANDERSSEN (CMI SIRIS).
- Audric BONNEAU (CMI IIRVIJ).