A smart, interactive compiler for a custom programming language — complete with lexing, parsing, evaluation, and AI-powered auto-correction.
The AI Compiler Assistant is a browser-based development environment that:
- Lexes, parses and evaluates a custom programming language
- Provides AI-generated corrections, explanations, and optimizations
- Shows a beautifully styled Corrected Code Box
- Lets users auto-replace their code with a single button
- Includes a full Python backend + CodeMirror editor frontend
Example:
integer a = 10;
a = a + 5;
print(a);- 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 ")"
Backend Architecture (Python)
✔ Lexer – Tokenizes input ✔ Parser – Builds an AST ✔ Evaluator – Executes AST + symbol table ✔ AI Assistant Fallback – On failure, returns:
- Errors
- Explanation
- Fix
- Optimization
- Corrected Code
- CodeMirror editor (Dracula theme)
- Live output console
- AI assistant panel
- Clean corrected-code UI
- Buttons:
- Use corrected code → replaces editor
- Copy code → clipboard support
Extract this repository into your working directory and simply run the compiler_server.py in webpage directory.