Skip to content

A toy programming language written in Typescript

License

Notifications You must be signed in to change notification settings

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%