A Pushdown Automata simulator built with Flask.
This project lets you test strings against predefined context-free language patterns and view each computation step, including state, remaining input, and stack contents.
- Web interface for interactive simulation
- Step-by-step trace output
- Accept/Reject result with dead-state visibility
- CLI mode for terminal-based runs
- 11 built-in PDA language definitions
- Ready-to-deploy Vercel configuration
Choose one of the following language sets in the UI or CLI:
- L = { a^n b^n : n >= 0 }
- L = { a^n b^(2n) : n >= 0 }
- L = { a^m b^n c^(m+n) : m,n >= 0 }
- L = { a^n b^m c^m d^n : m,n >= 0 }
- L = { w c w^R : w in {a,b}* }
- L = { w w^R : w in {a,b}* }
- L = { a^m b^n : m >= n >= 0 }
- Balanced parentheses
- L = { a^n b^n c^m : n,m >= 0 }
- L = { w in {a,b}* : #a = #b }
- L = { a^n b^n } U { a^n b^(2n) }
- Python 3.11
- Flask
- HTML + Tailwind CSS + JavaScript
- app.py: Flask routes and API endpoint
- pda.py: PDA engine and transition execution logic
- lang.py: predefined PDA language configurations
- runner.py: command-line simulator
- templates/index.html: web interface
- api/index.py: Vercel serverless entry point
- vercel.json: Vercel routing/build configuration
- requirements.txt: dependencies
-
Create and activate a virtual environment.
Windows PowerShell:
python -m venv .venv .\.venv\Scripts\Activate.ps1macOS/Linux:
python -m venv .venv source .venv/bin/activate -
Install dependencies:
pip install -r requirements.txt
-
Start the app:
python app.py
-
Open in browser:
Run the simulator from terminal:
python runner.py -i <language_id>Example:
python runner.py -i 1Then type the input string when prompted.
- This simulator is designed for learning, experimentation, and classroom demos.
- You can extend it by adding new PDA definitions in lang.py.
- For deployments, keep vercel.json, api/index.py, and requirements.txt in sync.
Contributions are welcome.
- Fork the repository.
- Create a feature branch.
- Commit your changes.
- Open a pull request with a clear description.
View the full contributors graph (including commit counts): Contributors Graph
If this project helps your automata theory practice, consider starring the repository and sharing it with classmates.
