Compiler for C+ toy imperative language, based on LLVM.
- For language syntax, semantics, and examples check documentation.md
- For formal language grammar, check grammar.md
- 
Code sample.cproutine main() is println "Hello C+"; return; end 
- 
Compile $ ./cplus sample.cp Compilation successful. Run ./a.out to execute 
- 
Run $ ./a.out Hello C+ 
- 
Generated ir.ll; ModuleID = 'ir.ll' source_filename = "ir.ll" target triple = "x86_64-pc-linux-gnu" @fmt_s_ln = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 @str = private unnamed_addr constant [9 x i8] c"Hello C+\00", align 1 define i64 @main() { entry: %printfCall = call i64 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @fmt_s_ln, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str, i32 0, i32 0)) ret i64 0 } declare i64 @printf(i8*, ...) 
- 
Debug output from cplus -d sample.cp
- 
Install prerequisites: cmake flex bison clang llvm-10using the package manager for your distro.- Example (Ubuntu 20.04 LTS): sudo apt install cmake flex bison clang llvm
 
- Example (Ubuntu 20.04 LTS): 
- 
Clone repo git clone https://github.com/Sh3B0/cplus/ cd cplus
- 
Build cplusbinary using CMakemkdir build cmake -S . -B build cmake --build build
- 
Compile a source file *.cp(check tests)cd build ./cplus -d ../tests/1.cp
- 
Help $ ./cplus --help usage: cplus [options] infile infile path to the source code file (*.cp) to compile. options: -h, --help show this help message and exit. -d, --debug show debug messages. -o, --outfile outfile specify executable file name. 
Feel free to report a bug or suggest a feature by creating an issue.
The source code is licensed under the MIT license, which you can find in the LICENSE file.
