Skip to content

jeet-dhandha/EmojiScript

 
 

Repository files navigation

Bhai Lang

Total alerts Language grade: JavaScript Build Build Build

This is official repository for bhai-lang.

Bhai lang is a toy programming language written in Typescript.


Installation

npm i -g bhailang

Usage

Create a new file (test.bhai)

Edit the file with a text editor. You can also try out your code on Bhai Lang PlayGround

🤚
  ✏️ "Hello bhai";
🤚

Run

bhailang test.bhai

Output

hello bhai

Documentation

General

🤚 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

Variables can be declared using 👉.


🤚
  👉 a = 10;
  👉 b = "two";
  👉 c = 15;
  a = a + 1;
  b = 21;
  c *= 2;
🤚

Types

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;
🤚

Built-ins

Use ✏️ to print anything to console.


🤚
  ✏️ "Hello World";
  👉 a = 10;
  {
    👉 b = 20;
    ✏️ a + b;
  }
  ✏️ 5, 'ok', 🫢 , true , false;
🤚

Conditionals

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";
  }
🤚

Loops

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";
🤚

Development

You can explore abstract syntax tree(AST) of bhailang here.

About

A toy programming language written in Typescript

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 95.9%
  • JavaScript 3.4%
  • Other 0.7%