Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

⚙️ C++ Compiler

📌 Description

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

🧠 Compiler Pipeline

Source Code
    ↓
Lexer (Token Stream)
    ↓
Parser (AST)
    ↓
Code Generator (Bytecode)
    ↓
Virtual Machine (Execution)

📂 Project Structure

CppCompiler/
│
├── src/
│   ├── main.cpp
│   │
│   ├── lexer/
│   ├── parser/
│   ├── ast/
│   ├── codegen/
│   ├── vm/
│
└── CMakeLists.txt

✨ Features

  • Modular architecture
  • Clean separation of compiler phases
  • Stack-based bytecode VM
  • Recursive Descent Parser
  • Extendable grammar
  • Modern C++17 support

🧾 Supported Syntax (Current Version)


10 + 20 * 2

Planned extensions:

  • 🔜 Variable declarations
  • 🔜 Assignment statements
  • 🔜 if / while
  • 🔜 Functions
  • 🔜 Symbol Table

⚙️ Build Instructions

📦 Requirements

  • C++17 compatible compiler
  • CMake 3.16+

🔨 Build Steps


mkdir build
cd build
cmake ..
cmake --build .

▶ Run


./CppCompiler

(Windows users: MiniCppCompiler.exe)


🚀 Future Improvements

  • 🔹 Symbol Table Implementation
  • 🔹 Full Statement Parsing
  • 🔹 LLVM IR Backend
  • 🔹 Optimization Passes
  • 🔹 Error Reporting System
  • 🔹 Debug Mode with AST Visualization


Create with ❤️!

About

A C++ compiler that performs lexical analysis, parsing, AST generation, and bytecode execution.

Topics

Resources

Code of conduct

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages