A Python-based mini-compiler/interpreter with a Tkinter GUI that demonstrates various compiler phases including Lexical Analysis, Syntax & AST Analysis, Semantic Analysis, Intermediate Code Generation, Code Optimization, and Code Generation.
- Interactive GUI with code editor and output display
- Support for Python-like syntax including:
- Variables and assignments
- Arithmetic operations
- Control structures (if-else, while, for loops)
- Function definitions and calls
- Lists and string operations
- Error handling (try-except)
- Built-in functions (print, len, range)
.
├── ast_nodes.py # AST node definitions
├── lexer.py # Lexical analyzer
├── myparser.py # Parser implementation
├── intrepreter.py # Interpreter implementation
├── script.py # Main GUI application
├── requirements.txt # Project dependencies
└── README.md # This file
- Make sure you have Python 3.7+ installed
- Install dependencies:
pip install -r requirements.txt
- Run the application:
python script.py
- Launch the application
- Choose from the main options:
- Learn Python
- Test Your Skills
- Optimize Code
- Compiler Phases
- Write your code in the editor
- View the output and analysis in the respective panels
- Lexical Analysis: Tokenizes input code
- Syntax & AST Analysis: Builds Abstract Syntax Tree
- Semantic Analysis: Type checking and validation
- Intermediate Code Generation: Generates three-address code
- Code Optimization: Performs optimizations like constant folding
- Code Generation: Produces final output
- The interpreter supports a subset of Python features
- Error messages are displayed in the output panel
- The GUI provides real-time feedback for code analysis