A complete, web-based educational IDE for the simple, English-like programming language, EasyLang. This project provides a hands-on environment to understand and visualize the core principles of compilers and interpreters.
- Dual Execution Modes: Instantly switch between an Interpreter (executes code directly) and a Compiler (translates to Python first).
- Live Code Editor: A professional-grade editor powered by CodeMirror with custom EasyLang syntax highlighting, line numbers, and active line styling.
- Transparent Process: The "Process Log" gives a step-by-step view of the compiler's work, showing timings for lexing, parsing, and execution.
- Beginner-Friendly Language: EasyLang is designed to be readable and intuitive, allowing students to focus on programming logic rather than complex syntax.
- Rich UI Experience: Features a modern design, a vibrant logo, dark/light themes, and font size controls for a polished and accessible user experience.
- Well-Structured Codebase: The project is organized professionally with separate modules for the lexer, parser, AST, interpreter, and compiler, making it easy to study and extend.
- Zero-Installation: As a web application, it requires no setup for the end-user. Anyone with a web browser can start learning immediately.
Follow these steps to run the EasyLang Compiler Lab on your local machine.
- Python 3.8 or newer
pip(Python's package installer)
-
Clone or Download the Project
Download the project files and unzip them into a directory of your choice.
-
Navigate to the Project Directory
Open your terminal or command prompt and change to the project's root directory.
cd path/to/your/EasyLang -
Create a Virtual Environment (Recommended)
This creates an isolated environment for the project's dependencies.
# For Windows python -m venv venv venv\Scripts\activate # For macOS/Linux python3 -m venv venv source venv/bin/activate
-
Install Dependencies
Install the required packages using the
requirements.txtfile.pip install -r requirements.txt
-
Run the Application
Start the Flask development server.
python compiler_app.py
-
Open in Browser
Once the server is running, open your web browser and go to the following address:
You should now see the EasyLang Compiler Lab interface and can start coding!
The application follows a classic compiler architecture. When you click "Compile" or "Interpret", your EasyLang code goes through the following stages:
-
Lexical Analysis (Lexing)
- Component:
compiler/lexer.py - Job: The raw code string is scanned and broken down into a sequence of tokens (e.g.,
KEYWORD,IDENTIFIER,NUMBER). Comments and whitespace are discarded.
- Component:
-
Syntax Analysis (Parsing)
- Component:
compiler/parser.py - Job: The stream of tokens is organized into a hierarchical structure called an Abstract Syntax Tree (AST) based on the rules of the EasyLang grammar. This tree represents the logical structure of the program.
- Component:
-
Execution (Interpretation or Compilation) The AST is then passed to one of two backends:
-
The Interpreter (
compiler/interpreter.py)- Method: Tree Walking.
- Process: It recursively "walks" the AST, evaluating each node directly. For example, when it sees a
BinaryOpnode for addition, it evaluates the children, performs the addition, and holds the result.
-
The Compiler (
compiler/compiler.py)- Method: Source-to-Source Translation.
- Process: It walks the AST and generates equivalent source code in a target language (in this case, Python). For example, an EasyLang
if-then-elseblock is translated into a Pythonif-elseblock. The resulting Python script is then executed in a safe, separate process.
-
The project is organized into a clean, modular structure:
/
|-- compiler_app.py # Main Flask application (routes and server logic)
|-- requirements.txt # Python package dependencies
|-- README.md # This documentation file
|
|-- compiler/ # Core compiler components
| |-- lexer.py
| |-- parser.py
| |-- ast.py
| |-- interpreter.py
| |-- compiler.py
|
|-- templates/
| |-- index.html # The single-page HTML user interface
|
|-- samples/ # Directory for all .ey sample programs
|-- 01_basics.ey
|-- ... (and 9 other sample files)