Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MiniLang Transpiler

Educational MiniLang compiler that transpiles to JavaScript or Python, with a fully responsive web playground (HTML/CSS/JS) and a Python backend.

Features

  • Lexer → Parser → Type checker → Transpiler
  • Targets: JavaScript and Python
  • Responsive playground (desktop / tablet / mobile)
  • CLI (cli.py) and REST API (app.py)
  • Example programs and tests

MiniLang syntax

fn name(params) -> type { ... }

let x: int = 10;
x = x + 1;
if (cond) { ... } else { ... }
while (cond) { ... }
print(value);
return value;

Types: int, bool, void
Operators: + - * / %, == != < <= > >=, and or not

Quick start

pip install -r requirements.txt
python app.py

Open http://127.0.0.1:5000.

CLI

python cli.py examples/hello.ml -t javascript
python cli.py examples/recursion.ml -t python -o out.py
python cli.py examples/loops.ml --dump-ast

Tests

pip install pytest
pytest -q

Project layout

minilang/          # compiler core
  lexer.py
  parser.py
  ast.py
  sema.py
  transpile.py
  compiler.py
templates/         # HTML UI
static/css|js      # responsive frontend
examples/          # .ml sample programs
app.py             # Flask playground + API
cli.py             # command-line transpiler

API

Endpoint Method Body Purpose
/api/compile POST { "source", "target" } Transpile
/api/run POST { "source" } Compile to Python & execute
/api/examples GET List examples

What you got Compiler pipeline: lexer → parser → type checker → transpile Targets: JavaScript and Python Responsive UI: HTML/CSS/JS playground (desktop / tablet / mobile) CLI + Flask API + 8 examples + 8 passing tests Run it

pip install -r requirements.txt python app.py

Then open http://127.0.0.1:5000

python cli.py examples/hello.ml -t javascript python cli.py examples/recursion.ml -t python -o out.py pytest -q

Try in the UI Pick an example (or write MiniLang) Choose JavaScript or Python Transpile / inspect Tokens & AST Run to execute via the Python sandbox

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages