This is a C compiler, inspired by gcc. For now, If generates X86 assembly code. ARM assembly support is coming soon.
SSH :
git clone git@github.com:yanismnsr/C-Compiler.gitHTTPS :
git clone https://github.com/yanismnsr/C-CompilerGo to the compiler directory
cd C-Compiler/compiler./runmake_M1.sh./runmake_ubuntu.sh./runmake_fedora.shAlways in the "compiler" directory :
./ifcc <path to your program>This will show the assembly directly on the console.
If you with to put the output in a file, simply redirect the standard output in bash :
./ifcc <path to your program> > executableA list of test scenarios are already written in the directory tests/testfiles of the project. To run them, run the following commands :
arch -x86_64 zsh to open a terminal in X86 architecture.
cd tests
./ifcc-test.py testfilesThis program uses an intermediate representation to make it easily extandable to more architectures. It can compile basic programs with the following features:
- Multiple variable declaration
- Affectation of constants to variables
- Affectation of variable to variable
- If-Else blocks
- Evaluation of an arithmetic expression with respect of priorities
- Addition
- Substraction
- Multiplication
- Division
- And ('&')
- Or ('|')
- Comparison operators :
- equals ('==')
- not equal ('!=')
- Lower equal (<=)
- Lower (<)
- Greater (>)
- Greater equal(>=)
- Evaluation of an expessions with "-" and "+" unary operators
- Evaluation of an expression with parenthesis
- Scopes with blocks ("{}")
- While loops
- Return in any block
- Variable declaration anywhere in the program
- Standard functions :
- putchar
- getchar
- Define and call functions with up to 6 parameters
Moreover, the compiler is also capable of displaying warnings in the following cases :
- If a variable is declared but never used
To finish, it makes the following verifications :
- That evey used variable is declared