Giter Site home page Giter Site logo

gurbaj5124871 / bhai-lang Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dullabs/bhai-lang

0.0 0.0 0.0 2.84 MB

A toy programming language written in Typescript

Home Page: https://bhailang.js.org/

License: MIT License

JavaScript 1.83% TypeScript 97.43% CSS 0.71% HTML 0.03%

bhai-lang's Introduction

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

hi bhai
  bol bhai "Hello bhai";
bye bhai

Run

bhailang test.bhai

Output

hello bhai

Documentation

General

hi bhai is the entrypoint for the program and all program must end with bye bhai. Anything outside of it will be ignored.


This will be ignored

hi bhai
// Write code here
bye bhai

This too

Variables

Variables can be declared using bhai ye hai.


hi bhai
  bhai ye hai a = 10;
  bhai ye hai b = "two";
  bhai ye hai c = 15;
  a = a + 1;
  b = 21;
  c *= 2;
bye bhai

Types

Numbers and strings are like other languages. Null values can be denoted using nalla. sahi and galat are the boolean values.


hi bhai
  bhai ye hai a = 10;
  bhai ye hai b = 10 + (15*20);
  bhai ye hai c = "two";
  bhai ye hai d = 'ok';
  bhai ye hai e = nalla;
  bhai ye hai f = sahi;
  bhai ye hai g = galat;
bye bhai

Built-ins

Use bol bhai to print anything to console.


hi bhai
  bol bhai "Hello World";
  bhai ye hai a = 10;
  {
    bhai ye hai b = 20;
    bol bhai a + b;
  }
  bol bhai 5, 'ok', nalla , sahi , galat;
bye bhai

Conditionals

Bhailang supports simple if else construct , agar bhai block will execute if condition is sahi and warna bhai block will execute if condition is galat.


hi bhai
  bhai ye hai a = 10;
  agar bhai (a < 25) {
   bol bhai "a is less than 25";
  } warna bhai {
   bol bhai "a is greater than or equal to 25";
  }
bye bhai

Loops

Statements inside jab tak bhai blocks are executed as long as a specified condition evaluates to sahi. If the condition becomes galat, statement within the loop stops executing and control passes to the statement following the loop. Use bas kar bhai to break the loop and agla dekh bhai to continue within loop.


hi bhai
  bhai ye hai a = 0;
  jab tak bhai (a < 10) {
   a += 1;
   agar bhai (a == 5) {
    bol bhai "andar se bol bhai ", a;
    agla dekh bhai;
   }
   agar bhai (a == 6) {
    bas kar bhai;
   }
   bol bhai a;
  }
  bol bhai "done";
bye bhai

bhai-lang's People

Contributors

aniketsingh0104 avatar ristri avatar ankitchouhan1020 avatar dependabot[bot] avatar deep-codes avatar lakhankumawat avatar shubh0107 avatar susmita-dey avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.