Skip to content

A toy programming language written in Typescript for Kannadigas.

License

Notifications You must be signed in to change notification settings

chandansgowda/kannada-script

 
 

Repository files navigation

Kannada Script

This is official repository for kannada-script (Forked from BhaiLang)

Kannada Script is a toy programming language written in Typescript.


Installation

npm i -g kannada-script

Usage

Create a new file (test.kans)

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

namaskara
  helu "Hello anna";
matte sigona

Run

kannadascript test.kans

Output

hello anna

Documentation

General

namaskara is the entrypoint for the program and all program must end with matte sigona. Anything outside of it will be ignored.


This will be ignored

namaskara
// Write code here
matte sigona

This too

Variables

Variables can be declared using idu.


namaskara
  idu a = 10;
  idu b = "two";
  idu c = 15;
  a = a + 1;
  b = 21;
  c *= 2;
matte sigona

Types

Numbers and strings are like other languages. Null values can be denoted using khali. sari and thappu are the boolean values.


namaskara
  idu a = 10;
  idu b = 10 + (15*20);
  idu c = "two";
  idu d = 'ok';
  idu e = khali;
  idu f = sari;
  idu g = thappu;
matte sigona

Built-ins

Use helu to print anything to console.


namaskara
  helu "Hello World";
  idu a = 10;
  {
    idu b = 20;
    helu a + b;
  }
  helu 5, 'ok', khali , sari , thappu;
matte sigona

Conditionals

kannadascript supports if-else-if ladder construct , enadru block will execute if condition is sari, otherwise one of the subsequently added illa andre blocks will execute if their respective condition is sari, and the enu illa andre block will eventually execute if all of the above conditions are thappu


namaskara
  idu a = 10;
  enadru (a < 20) {
    helu "a is less than 20";
  } illa andre ( a < 25 ) {
    helu "a is less than 25";
  } enu illa andre {
    helu "a is greater than or equal to 25";
  }
matte sigona

Loops

Statements inside ellivargu blocks are executed as long as a specified condition evaluates to sari. If the condition becomes thappu, statement within the loop stops executing and control passes to the statement following the loop. Use saaku nilsu to break the loop and munde nodu to continue within loop.


namaskara
  idu a = 0;
  ellivargu (a < 10) {
   a += 1;
   enadru (a == 5) {
    helu "loop olaginda helu ", a;
    munde nodu;
   }
   enadru (a == 6) {
    saaku nilsu;
   }
   helu a;
  }
  helu "done";
matte sigona

Development

You can explore abstract syntax tree(AST) of kannadascript here.

About

A toy programming language written in Typescript for Kannadigas.

Resources

License

Code of conduct

Stars

Watchers

Forks

Languages

  • TypeScript 95.8%
  • JavaScript 3.5%
  • Other 0.7%