|
|
MaachLang is implemented as a simple interpreter. Source code is read as text, tokenized, parsed into an abstract syntax tree, and then executed by the runtime.
The language currently supports variables, numbers, strings, lists, functions, conditionals, loops, and a small built-in standard library.
The public runtime entrypoint is maach.run(fn, text), exposed through the maach package.
- The lexer converts raw source text into tokens.
- The parser turns those tokens into an abstract syntax tree.
- The interpreter walks the tree and evaluates the program.
- Built-in values and functions are loaded into the global symbol table before execution starts.
This is why the shell runners are thin wrappers around the shared interpreter logic.
For a deeper engineering-level walkthrough of the runtime, see TECHNICAL_GUIDE.md.
Use the file runner to execute a MaachLang source file:
python3 FileRunnerShell.py examples/helloworld.maachYou can also use the convenience script:
bash maach.sh examples/helloworld.maachRun the REPL when you want to type code line by line:
python3 shell.pyType tham or exit to leave the shell.
If you want to embed MaachLang in another Python script:
from maach import run
result, error = run("<stdin>", 'bol("Hello World")')The full list of keywords and built-in functions lives in guide.md.
Some of the currently available built-ins are:
bolfor printingjigesh_korfor inputsonkha_jigesh_korfor integer inputlaga/byass_ber_kor/atkafor list operationsfloor,ceil,round,abs,sqroot,sin,cos,tan,powfor math helpers
# Hello world
bol("Hello World")# A basic for loop
ghorao i = 0 theke 5 tarpor
bol("loop!")
byass# A simple function
kaaj naam(name);
bol("Hello " + name);
byass;
bol("Name: ")
chol n = jigesh_kor()
naam(n)# Recursive factorial
kaaj fact(n);
jodi n<=1 tarpor de(1) nahole de(n * fact(n-1))
byass;
bol(fact(5))More runnable examples are available in the examples/ directory:
examples/conditionals.maach(if/else and boolean logic)examples/while_countdown.maach(while loop)examples/list_ops.maach(list values and list helpers)examples/math_showcase.maach(math built-ins)examples/script_runner.maach(running one script from another)
A formal installation flow is not published yet. For now, clone the repository and run the scripts with Python 3.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.