Giter Site home page Giter Site logo

jonathanalvares9009 / bro-lang Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dullabs/bhai-lang

0.0 0.0 0.0 1.86 MB

A toy programming language written in Typescript

Home Page: https://brolang.vercel.app/

License: MIT License

JavaScript 3.81% TypeScript 95.43% CSS 0.71% HTML 0.02% Zeek 0.02%

bro-lang's Introduction

Bro Lang

This is official repository for brolang.

Brolang is a toy programming language written in Typescript.


Installation

npm i -g brolang-cli

Usage

Create a new file (test.bro)

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

bro listen
  bro say "Tech bro";
bro done

Run

brolang test.bro

Output

Tech bro

Documentation

General

bro listen is the entrypoint for the program and all program must end with bro done. Anything outside of it will be ignored.


This will be ignored

bro listen
// Write code here
bro done

This too

Variables

Variables can be declared using bro remember.


bro listen
  bro remember a = 10;
  bro remember b = "two";
  bro remember c = 15;
  a = a + 1;
  b = 21;
  c *= 2;
bro done

Types

Numbers and strings are like other languages. Null values can be denoted using nothing. correct and wrong are the boolean values.


bro listen
  bro remember a = 10;
  bro remember b = 10 + (15*20);
  bro remember c = "two";
  bro remember d = 'ok';
  bro remember e = nalla;
  bro remember f = sahi;
  bro remember g = galat;
bro done

Built-ins

Use bro say to print anything to console.


bro listen
  bro say "Hello World";
  bro remember a = 10;
  {
    bro remember b = 20;
    bro say a + b;
  }
  bro say 5, 'ok', nothing , correct , wrong;
bro done

Conditionals

Brolang supports if-else-if ladder construct , bro if block will execute if condition is correct, otherwise one of the subsequently added bro otherwise if blocks will execute if their respective condition is correct, and the bro otherwise block will eventually execute if all of the above conditions are wrong


bro listen
  bro remember a = 10;
  bro if (a < 20) {
    bro say "a is less than 20";
  } bro otherwise if ( a < 25 ) {
    bro say "a is less than 25";
  } bro otherwise {
    bro say "a is greater than or equal to 25";
  }
bro done

Loops

Statements inside bro when blocks are executed as long as a specified condition evaluates to correct. If the condition becomes wrong, statement within the loop stops executing and control passes to the statement following the loop. Use bro stop to break the loop and bro skip to continue within loop.


bro listen
  bro remember a = 0;
  bro when (a < 10) {
    a += 1;
    bro if (a == 5) {
      bro say "tech bro", a;
      bro skip;
    }
    bro if (a == 6) {
      bro stop;
    }
    bro say a;
  }
  bro say "done";
bro done

bro-lang's People

Contributors

aniketsingh0104 avatar ristri avatar jonathanalvares9009 avatar ankitchouhan1020 avatar dependabot[bot] avatar lakhankumawat avatar shubh0107 avatar deep-codes avatar ayush7614 avatar harshkanjariya avatar nikhil216 avatar susmita-dey avatar vipul0092 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.