This C++ Compiler is a modular compiler pipeline written primarily in C++. It simulates the internal architecture of modern compilers such as Clang by implementing:
- 🔎 Tokenization (Lexer)
- 🌳 Abstract Syntax Tree (AST)
- 🧠 Recursive Descent Parsing
- ⚡ Bytecode Instruction Generation
- 🖥️ Stack-Based Virtual Machine
Source Code
↓
Lexer (Token Stream)
↓
Parser (AST)
↓
Code Generator (Bytecode)
↓
Virtual Machine (Execution)
CppCompiler/ │ ├── src/ │ ├── main.cpp │ │ │ ├── lexer/ │ ├── parser/ │ ├── ast/ │ ├── codegen/ │ ├── vm/ │ └── CMakeLists.txt
- Modular architecture
- Clean separation of compiler phases
- Stack-based bytecode VM
- Recursive Descent Parser
- Extendable grammar
- Modern C++17 support
10 + 20 * 2
Planned extensions:
- 🔜 Variable declarations
- 🔜 Assignment statements
- 🔜 if / while
- 🔜 Functions
- 🔜 Symbol Table
- C++17 compatible compiler
- CMake 3.16+
mkdir build
cd build
cmake ..
cmake --build .
./CppCompiler
(Windows users: MiniCppCompiler.exe)
- 🔹 Symbol Table Implementation
- 🔹 Full Statement Parsing
- 🔹 LLVM IR Backend
- 🔹 Optimization Passes
- 🔹 Error Reporting System
- 🔹 Debug Mode with AST Visualization
Create with ❤️!