This is official repository for bhai-lang.
Bhai lang is a toy programming language written in Typescript.
npm i -g bhailang
Edit the file with a text editor. You can also try out your code on Bhai Lang PlayGround
🤚
✏️ "Hello bhai";
🤚
bhailang test.bhai
hello bhai
🤚
is the entrypoint for the program and all program must end with 🤚
. Anything outside of it will be ignored.
This will be ignored
🤚
// Write code here
🤚
This too
Variables can be declared using 👉
.
🤚
👉 a = 10;
👉 b = "two";
👉 c = 15;
a = a + 1;
b = 21;
c *= 2;
🤚
Numbers and strings are like other languages. Null values can be denoted using 🫢
. true
and false
are the boolean values.
🤚
👉 a = 10;
👉 b = 10 + (15*20);
👉 c = "two";
👉 d = 'ok';
👉 e = 🫢;
👉 f = true;
👉 g = false;
🤚
Use ✏️
to print anything to console.
🤚
✏️ "Hello World";
👉 a = 10;
{
👉 b = 20;
✏️ a + b;
}
✏️ 5, 'ok', 🫢 , true , false;
🤚
Bhailang supports if-else-if ladder construct , 👀
block will execute if condition is true
, otherwise one of the subsequently added 🧿
blocks will execute if their respective condition is true
, and the 👁️
block will eventually execute if all of the above conditions are false
🤚
👉 a = 10;
👀 (a < 20) {
✏️ "a is less than 20";
} 🧿 ( a < 25 ) {
✏️ "a is less than 25";
} 👁️ {
✏️ "a is greater than or equal to 25";
}
🤚
Statements inside 🔁
blocks are executed as long as a specified condition evaluates to true. If the condition becomes false
, statement within the loop stops executing and control passes to the statement following the loop. Use 🙏🏻
to break the loop and 💔
to continue within loop.
🤚
👉 a = 0;
🔁 (a < 10) {
a += 1;
👀 (a == 5) {
✏️ "andar se ✏️ ", a;
💔;
}
👀 (a == 6) {
🙏🏻;
}
✏️ a;
}
✏️ "done";
🤚
You can explore abstract syntax tree(AST) of bhailang here.