Guru lang is a fun programming language forked from BhaiLang :)
Do checkout the online Guru Lang PlayGround.
npm i -g gurulang
gurulang test.guru
Hello Guru
namskara guru
is the entrypoint for the program and all program must end with aythu guru
. Anything outside of it will be ignored.
This will be ignored
namskara guru
// Write code here
aythu guru
This too
Variables can be declared using nodu guru
.
namskara guru
nodu guru a = 10;
nodu guru b = "two";
nodu guru c = 15;
a = a + 1;
b = 21;
c *= 2;
aythu guru
Numbers and strings are like other languages. Null values can be denoted using nalla
. nija
and sullu
are the boolean values.
namskara guru
nodu guru a = 10;
nodu guru b = 10 + (15*20);
nodu guru c = "two";
nodu guru d = 'ok';
nodu guru e = nalla;
nodu guru f = nija;
nodu guru g = sullu;
aythu guru
Use helu guru
to print anything to console.
namskara guru
helu guru "Hello World";
nodu guru a = 10;
{
nodu guru b = 20;
helu guru a + b;
}
helu guru 5, 'ok' , nija , sullu;
aythu guru
Gurulang supports simple if else construct , guru eega
block will execute if condition is nija
and illandre guru
block will execute if condition is sullu
.
namskara guru
nodu guru a = 10;
guru eega (a < 25) aadre{
helu guru "a is less than 25";
} illandre guru {
helu guru "a is greater than or equal to 25";
}
aythu guru
Statements inside guru ellivargu
blocks are executed as long as a specified condition evaluates to nija. If the condition becomes sullu
, statement within the loop stops executing and control passes to the statement following the loop. Use saak bidu guru
to break the loop and mundhe nodu guru
to continue within loop.
namskara guru
nodu guru a = 0;
guru ellivargu (a < 10) {
a += 1;
guru eega (a == 5) aadre{
helu guru "olaginda helu guru ", a;
mundhe nodu guru;
}
guru eega (a == 6) aadre{
saak bidu guru;
}
helu guru a;
}
helu guru "done";
aythu guru