A browser-based IDE for a custom programming language - featuring a full compiler pipeline (Lexer → Parser → AST → Evaluator) with an AI-powered error correction and auto-fix engine.
Most compilers just throw a cryptic error and leave you alone. This one doesn't.
AI Compiler Assistant is a fully functional browser-based IDE where you write code in a custom programming language. When your code compiles successfully, you see the output instantly. When it fails, an AI assistant takes over - analyzing the error, explaining what went wrong in plain language, suggesting a fix, and giving you corrected code you can apply with a single click.
Built as a team project. Entire compiler pipeline written from scratch in Python.
Write code → Run → See output or get AI-corrected code instantly
integer a = 10;
integer b = 20;
a = a + b;
print(a);
Output:
30
If you write broken code:
integer a = 10
print(a) ← missing semicolons
The AI assistant returns:
- Errors - exactly which lines failed and why
- Explanation - plain language description of the issue
- Fix - what you need to change
- Optimization - any improvements beyond the fix
- Corrected Code - ready to use, one click to apply
User Code (CodeMirror Editor)
│
▼
┌───────────────┐
│ Lexer │ Tokenizes raw source code into typed tokens
└───────┬───────┘
│
▼
┌───────────────┐
│ Parser │ Recursive descent parser — builds an Abstract Syntax Tree (AST)
└───────┬───────┘
│
▼
┌───────────────┐
│ Evaluator │ Walks the AST, executes statements, maintains symbol table
└───────┬───────┘
│
┌────┴────┐
│ │
SUCCESS FAILURE
│ │
▼ ▼
Output AI Assistant
console (Online LLM → Offline fallback)
Returns: Errors, Explanation,
Fix, Optimization, Corrected Code
The compiler supports a custom DSL with the following formal grammar:
PROGRAM → STMT_LIST EOF
STMT_LIST → (STMT)*
STMT → DECL | ASSIGN | PRINT_STMT
DECL → "integer" ID "=" EXPR ";"
ASSIGN → ID "=" EXPR ";"
PRINT_STMT → "print" "(" EXPR ")" ";"
EXPR → TERM { ("+" | "-") TERM }
TERM → FACTOR { ("*" | "/") FACTOR }
FACTOR → NUMBER | STRING | ID | "(" EXPR ")"
NUMBER → DIGIT+
STRING → '"' CHAR* '"'
ID → LETTER (LETTER | DIGIT | "_")*
Supported operations:
- Variable declaration with
integer - Arithmetic:
+,-,*,/ - Grouped expressions with parentheses
- String literals
print()statements
| Feature | Description |
|---|---|
| Full compiler pipeline | Lexer → Parser → AST → Evaluator, built from scratch |
| AI error correction | On compile failure, LLM returns structured fix + corrected code |
| Online + offline fallback | Uses online LLM when available, falls back to offline assistant automatically |
| One-click auto-replace | Apply corrected code directly into the editor with a single button |
| CodeMirror editor | Syntax-highlighted editor with Dracula theme |
| Live output console | See program output in real time |
| Copy to clipboard | Copy corrected code instantly |
| Symbol table inspection | Final variable state displayed after successful execution |
| Layer | Technology |
|---|---|
| Backend | Python |
| Compiler modules | Custom Lexer, Parser, Evaluator (pure Python, no compiler libraries) |
| AI integration | Online LLM API + Offline fallback assistant |
| Frontend | HTML, CSS, JavaScript |
| Code editor | CodeMirror (Dracula theme) |
| Server | Python HTTP server (compiler_server.py) |
AI-Compiler-Assisstant/
├── Compiler/
│ ├── Lexer.py # Tokenizer — converts source to token stream
│ ├── Parser.py # Recursive descent parser — builds AST
│ ├── Evaluator.py # AST walker — executes the program
│ ├── OnlineAssistant.py # LLM-powered error correction (online)
│ └── OfflineAssistant.py # Fallback error assistant (offline)
├── WebPage/
│ ├── compiler_server.py # Python HTTP server — run this to start
│ ├── index.html # Browser IDE frontend
│ ├── style.css # Styling
│ └── script.js # Editor logic + API calls
├── main.py # Core orchestration: run() + fallback logic
├── requirements.txt # Python dependencies
└── README.md
1. Clone the repository
git clone https://github.com/manishkrmahato/AI-Compiler-Assisstant.git
cd AI-Compiler-Assisstant2. Install dependencies
pip install -r requirements.txt3. Start the server
cd WebPage
python compiler_server.py4. Open in browser
http://localhost:8000
Write code in the editor, click Run. That's it.
Arithmetic
integer x = 5;
integer y = 3;
integer z = x * y + 2;
print(z);
Output: 17
String print
print("Hello, World!");
Output: Hello, World!
Variable reassignment
integer a = 100;
a = a / 4;
print(a);
Output: 25
When the compiler's Evaluator raises an exception, main.py catches it and calls run_compiler_from_code(). This sends the broken code to the AI assistant with a structured system prompt that includes the full language grammar.
The AI returns a response in five structured sections:
- Errors - exact lines and what failed
- Explanation - plain language description
- Fix - minimal change needed
- Optimization - suggestions beyond correctness
- Corrected Code - clean, runnable version
If the online LLM is unavailable, the system automatically falls back to the offline assistant - ensuring the IDE never leaves the user without feedback.
Built as a collaborative team project at NIT Warangal.
| Contributor | GitHub |
|---|---|
| Manish Kumar Mahato | @manishkrmahato |
| Pranav Umbarkar | @PranavUmbarkar06 |
| Mistry Ritik | @kai11017 |