Another Page

Tutorial

Surti

A Language For Surti JS

Surti is a programming language written in Typescript.

Installation

npm i surti

Usage

Create a new file (test.surti)

Edit the file with a text editor.

hi loda
  bol loda "Hello chodu";
bye loda

Run

surti test.surti

Output

hello chodu

Documentation

General

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

This will be ignored
 
hi loda
// Write code here
bye loda
 
This too

Variables

Variables can be declared using loda aa che.

hi loda
  loda aa che a = 10;
  loda aa che b = "two";
  loda aa che c = 15;
  a = a + 1;
  b = 21;
  c *= 2;
bye loda

Types

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

hi loda
  loda aa che a = 1;
  loda aa che b = 15 + (66*22);
  loda aa che c = "two";
  loda aa che d = 'ok';
  loda aa che e = nalla;
  bhai ye hai f = sachu;
  loda aa che g = maachodi;
bye loda

Built-ins

Use bol loda to print anything to console.

hi loda
  bol loda "Hello World";
  loda aa che a = 10;
  {
    loda aa che b = 20;
    bol loda a + b;
  }
  bol loda 5, 'ok', nalla , sachu , maachodi;
bye loda

Conditionals

Surti supports if-else-if ladder construct , jo loda block will execute if condition is sachu, otherwise one of the subsequently added nai to loda blocks will execute if their respective condition is sachu, and the nakar loda block will eventually execute if all of the above conditions are maachodi

hi loda
  loda aa che a = 10;
  jo loda (a < 20) {
    bol loda "a is less than 20";
  } nai to loda ( a < 25 ) {
    bol loda "a is less than 25";
  } nakar loda {
    bol loda "a is greater than or equal to 25";
  }
bye loda

Loops

Statements inside jya sudhi loda blocks are executed as long as a specified condition evaluates to sachu. If the condition becomes maachodi, statement within the loop stops executing and control passes to the statement following the loop. Use bas kar loda to break the loop and agal jo loda to continue within loop.

hi loda
  loda aa che a = 0;
  jya sudhi loda (a < 10) {
   a += 1;
   jo loda (a == 5) {
    bol loda "andar thi bol loda ", a;
    agal jo loda;
   }
   jo loda (a == 6) {
    bas kar loda;
   }
   bol loda a;
  }
  bol loda "done";
bye loda