brolang-cli
TypeScript icon, indicating that this package has built-in type declarations

0.4.0 • Public • Published

Bro Lang

Total alerts Language grade: JavaScript Build Build Build

Brolang is a toy programming language created for tech bros.


Installation

npm i -g brolang-cli

Usage

Create a new file


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

bro listen
  bro say "Hello Bro";
bro done

Run

brolang test.bro

Output

hello 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 = nothing;
  bro remember f = correct;
  bro remember g = wrong;
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 simple if else construct , bro if block will execute if condition is correct and bro otherwise block will execute if condition is wrong.


bro listen
  bro remember a = 10;
  bro 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

Package Sidebar

Install

npm i brolang-cli

Weekly Downloads

3

Version

0.4.0

License

MIT

Unpacked Size

282 kB

Total Files

4

Last publish

Collaborators

  • jonyal