Language guide
Syntax & Keywords
Every keyword, operator, and construct in kemlang-py - with examples.
Program structure
Every kemlang-py program must be wrapped in kem bhai and aavjo bhai. Nothing runs outside these fences.
jskkem bhai // your code here aavjo bhai
- ›
kem bhai- Opens the program - literally "hello, brother" - ›
aavjo bhai- Closes the program - literally "goodbye, brother" - ›
//- Single-line comment - ignored by the interpreter
Variables
Declaration - aa x che val
Declare a new variable with aa (this) and che (is). Every type is inferred automatically.
jskkem bhai aa naam che "Sanket" // string aa age che 25 // integer aa pi che 3.14 // float aa flag che bhai chhe // boolean aavjo bhai
Reassignment - x che val
Reassign an existing variable using che without aa.
jskkem bhai aa count che 0 count che 1 count che count + 1 bhai bol count // 2 aavjo bhai
Data types
string"hello" · 'world'single or double quotesinteger42 · -7 · 0whole numbersfloat3.14 · -0.5decimal numbersbooleanbhai chhe · bhai nathialso: true / falsenone-result of failed inputOutput - bhai bol
bhai bol (brother, say) prints any value to stdout. It automatically converts numbers and booleans to strings.
jskkem bhai bhai bol "Hello, World!" bhai bol 42 bhai bol 3.14 bhai bol bhai chhe aavjo bhai
Hello, World! 42 3.14 true
Input - bapu tame bolo
bapu tame bolo (father, you say) reads a line from stdin and returns it as a string.
jskkem bhai bhai bol "What is your name?" aa naam che bapu tame bolo bhai bol "kem cho, " + naam + "!" aavjo bhai
String operations
Use + to concatenate strings. If either side is a string, the other side is automatically cast.
jskkem bhai aa first che "Sanket" aa last che "Patel" aa full che first + " " + last bhai bol full // Sanket Patel bhai bol "Age: " + 25 // Age: 25 aavjo bhai
Arithmetic
jskkem bhai aa a che 10 aa b che 3 bhai bol a + b // 13 bhai bol a - b // 7 bhai bol a * b // 30 bhai bol a / b // 3.333... bhai bol a % b // 1 (modulo) aavjo bhai
Comparison operators
All comparisons return bhai chhe (true) or bhai nathi (false).
==equal to!=not equal to<less than>greater than<=less than or equal>=greater than or equaljskkem bhai bhai bol 10 == 10 // true bhai bol 10 != 5 // true bhai bol 3 > 7 // false aavjo bhai
Conditionals - jo / nahi to
jo means “if”, nahi to means “otherwise”. Braces are required. There is no else if - nest another jo inside.
jskkem bhai aa score che 82 jo score >= 90 { bhai bol "A grade" } nahi to { jo score >= 75 { bhai bol "B grade" } nahi to { bhai bol "C grade" } } aavjo bhai
Loops - farvu / jya sudhi
farvu means “to do”, jya sudhi means “as long as”. The body runs first, then the condition is checked.
jskkem bhai aa i che 1 farvu { bhai bol i i che i + 1 } jya sudhi i <= 5 aavjo bhai
1 2 3 4 5
Loop control
tame jao - break
Exit the nearest loop immediately.
jskkem bhai aa i che 1 farvu { jo i == 4 { tame jao } bhai bol i i che i + 1 } jya sudhi bhai chhe aavjo bhai
aagal vado - continue
Skip the rest of the current iteration and move to the next.
jskkem bhai aa i che 0 farvu { i che i + 1 jo i % 2 == 0 { aagal vado } // skip evens bhai bol i } jya sudhi i < 10 aavjo bhai
Full keyword reference
kem bhaiprogram starthello, brotheraavjo bhaiprogram endgoodbye, brotheraa x che valdeclarethis x is valx che valreassignx is valbhai bol exprprintbrother, saybapu tame boloread inputfather, you sayjo cond { }ififnahi to { }elseotherwisefarvu { } jya sudhi condwhiledo whiletame jaobreakyou goaagal vadocontinuemove forwardbhai chhetruebrother isbhai nathifalsebrother is not