KaleshScript Documentation
Aagye nikamme? Achhe se paddh and phir code kar.
What is KaleshScript?
KaleshScript is a fun, toy programming language that brings Delhi's slang language to code. It's built for entertainment and certainly NO LEARNING purposes, featuring everything that kids should not learn. Don't cancel me. Read, code and laugh!
Quick Start
Here's your first KaleshScript program:
bhauk "Hello from Delhi!" nikal lawde
That's it! bhauk prints output, and nikal lawde exits the program.
Language Syntax
1. Variable Declaration
Declare variables using chutiye ye followed by variable name,hai, and the value.
chutiye ye x hai 42 chutiye ye naam hai "Rahul" chutiye ye status hai sahi chutiye ye price hai 99.99
Variables can hold:
- Numbers (integers and decimals)
- Strings (text in quotes)
- Booleans (sahi/bekaar)
- Arrays and Hashes
2. Boolean Values
KaleshScript has its own boolean values with Delhi flavor:
sahi- means true (correct/right)bekaar- means false (useless/wrong)
chutiye ye truth hai sahi chutiye ye lie hai bekaar bhauk truth // Prints: sahi bhauk lie // Prints: bekaar
3. Print Statement
Use bhauk (bark) to print output to console:
bhauk "Hello Delhi!" bhauk 42 bhauk x bhauk "Score: " + score
4. Arithmetic Operations
Standard arithmetic operators work as expected:
chutiye ye a hai 10 chutiye ye b hai 5 chutiye ye sum hai a + b // 15 chutiye ye diff hai a - b // 5 chutiye ye prod hai a * b // 50 chutiye ye quot hai a / b // 2 bhauk sum
Type Safety: Arithmetic operations require numbers. Trying to subtract a string from a boolean will throw: "Dimag use kar thoda: Cannot subtract string from boolean"
5. Comparison Operators
Compare values using standard operators:
chutiye ye x hai 10 chutiye ye y hai 20 bhauk x == y // bekaar (false) bhauk x != y // sahi (true) bhauk x < y // sahi (true) bhauk x > y // bekaar (false)
Available operators: ==,!=,<,>
6. If-Else Statements
Conditional logic using bsdk agar (if) and warna (else):
// Simple if bsdk agar x > 10 kar: bhauk "X is big" // If with else bsdk agar score > 90 kar: bhauk "Grade A" warna: bhauk "Grade B" // Multiple conditions chutiye ye temp hai 45 bsdk agar temp > 40 kar: bhauk "Too hot!" bsdk agar temp < 10 kar: bhauk "Too cold!" bsdk agar temp == 25 kar: bhauk "Perfect!"
Syntax: bsdk agar [condition] kar: [statement]
7. Loops
Use jab tak maa [condition] na maane(while mother doesn't agree) for loops:
// Count from 0 to 5 chutiye ye count hai 0 jab tak maa count < 5 na maane: count = count + 1 bhauk count // Prints: 5 // Loop with multiple statements chutiye ye i hai 0 jab tak maa i < 3 na maane: i = i + 1
Infinite Loop Protection: Loops are limited to 10,000 iterations. If exceeded, you'll get: "Lafda ho gaya: Infinite loop detected!"
// This will error after 10,000 iterations jab tak maa sahi na maane: x = x + 1
8. Break & Continue
Control loop execution with break and continue statements:
ruk jaa bc- break (stop the loop)aage baddh bc- continue (skip to next iteration)
// Break example chutiye ye x hai 0 jab tak maa x < 10 na maane: x = x + 1 // Continue example chutiye ye y hai 0 jab tak maa y < 5 na maane: y = y + 1
9. Switch Case
Use mood for switch statements and dekh for each case:
chutiye ye mood hai "happy"
mood mood {
dekh "happy": bhauk "Party karte hain!"
dekh "sad": bhauk "Daaru lao yaar"
dekh "angry": bhauk "Chill maar bhai"
default: bhauk "Sab theek hai"
}
// Works with numbers too
chutiye ye day hai 1
mood day {
dekh 1: bhauk "Monday"
dekh 2: bhauk "Tuesday"
default: bhauk "Other day"
}Syntax: mood [variable] { dekh [value]: [statement] }
10. Functions
Define functions using kaand (mischief/function):
// Function with parameter
kaand greet(naam) {
bhauk "Hello"
bhauk naam
}
// Call the function
greet("Rahul")
greet("Delhi")
// Function with multiple parameters
kaand add(a, b) {
chutiye ye sum hai a + b
bhauk sum
}
add(10, 20) // Prints: 30Syntax: kaand [name]([params]) { [body] }
11. Try-Catch
Handle errors using try kar (try) and pakad mc (catch):
// Try-catch example try kar: bhauk "Risky operation" , pakad mc: bhauk "Error handled!" // Program continues after error bhauk "Still running!"
Syntax: try kar: [statement] , pakad mc: [error handler]
12. Arrays
Create and access arrays (lists) of values:
// Create an array chutiye ye numbers hai [10, 20, 30, 40, 50] // Access elements (0-indexed) bhauk numbers[0] // First element: 10 bhauk numbers[2] // Third element: 30 bhauk numbers[4] // Last element: 50 // Array of strings chutiye ye cities hai ["Delhi", "Mumbai", "Bangalore"] bhauk cities[0] // Delhi // Mixed types chutiye ye mixed hai [42, "text", sahi]
Arrays are zero-indexed. First element is at index 0.
13. Hash/Dictionary
Store key-value pairs using hash/dictionary syntax:
// Create a hash
chutiye ye person hai {"name": "Rahul", "age": 25, "city": "Delhi"}
// Access values by key
bhauk person["name"] // Rahul
bhauk person["age"] // 25
bhauk person["city"] // Delhi
// Nested hash
chutiye ye data hai {
"user": "admin",
"settings": {"theme": "dark", "lang": "hi"}
}
bhauk data["user"]Keys must be strings in quotes. Values can be any type.
14. String Operations
Work with text using string operations:
// String concatenation with + chutiye ye first hai "Delhi" chutiye ye second hai " Rocks" chutiye ye combined hai first + second bhauk combined // Delhi Rocks // Strings in quotes chutiye ye greeting hai "Namaste" chutiye ye message hai "Welcome to KaleshScript!"
15. Input
Get user input using Suna lawde() (listen up):
// Get input from user chutiye ye naam hai Suna lawde() bhauk "Your name is:" bhauk naam // Use input in calculations chutiye ye age hai Suna lawde() bhauk age
In the web version, this will prompt for input via browser prompt dialog.
// Complete input example bhauk "What's your name?" chutiye ye naam hai Suna lawde() bhauk "Hello" bhauk naam bhauk "How old are you?" chutiye ye age hai Suna lawde() bhauk "You are" bhauk age bhauk "years old" nikal lawde
16. Exit Program (REQUIRED)
IMPORTANT Rule
Every KaleshScript program MUST end with nikal lawde. Without this statement, your program will throw an error and refuse to run.
Use nikal lawde (get out) to exit the program. This is MANDATORY - programs without it will not run!
bhauk "Starting program..." bhauk "Doing some work..." bhauk "Almost done..." nikal lawde // REQUIRED to end program // Code after this won't execute bhauk "This won't print"
Think of it as the program saying "I'm done, getting out of here!"
17. Comments
Add comments to your code using //:
// This is a comment // Comments are ignored by the interpreter chutiye ye x hai 42 // Inline comment // Use comments to explain your code // They help others understand what you're doing nikal lawde
Data Types
Numbers
Integers and decimals
42, -10, 3.14, 99.99Strings
Text enclosed in double quotes
"Hello", "Delhi", "KaleshScript"Booleans
True or false values
sahi (true), bekaar (false)Arrays
Ordered lists of values
[1, 2, 3], ["a", "b", "c"]Hashes
Key-value pairs (dictionaries)
{"name": "Rahul", "age": 25}Operators
Arithmetic Operators
+Addition-Subtraction*Multiplication/DivisionComparison Operators
==Equal to!=Not equal to<Less than>Greater thanAssignment Operator
=Assign value to variableError Messages (Delhi Style)
KaleshScript has its own unique error messages with Delhi flavor. Here's what they mean:
Syntax Error
"Ye kya bakchodi likh di?"Translation: "What nonsense did you write?" - You have a syntax error in your code. Check for missing keywords, wrong punctuation, or typos.
Type Error
"Dimag use kar thoda"Translation: "Use your brain a little" - You're trying to perform an operation with incompatible types. For example, subtracting a string from a boolean.
Runtime Error
"Lafda ho gaya"Translation: "Trouble happened" - Something went wrong while running your program. Could be division by zero, accessing invalid array index, etc.
Null/Undefined Error
"Khali dimaag"Translation: "Empty brain" - You're trying to use a variable that doesn't exist or has no value.
Infinite Loop Error
"Lafda ho gaya: Infinite loop detected!"Your loop has run more than 10,000 times. Check your loop condition to make sure it can eventually become false.
Missing Exit Statement
"Ye kya bakchodi likh di? Program must end with 'nikal lawde'"Every KaleshScript program MUST end with nikal lawde. Add it at the end of your program.
Best Practices
1. Always End with nikal lawde
This is not optional! Every program must end with the exit statement.
2. Use Comments
Add comments to explain complex logic. Future you will thank present you!
3. Watch Your Loop Conditions
Make sure your loops can eventually end. Avoid conditions like jab tak maa sahi na maaneunless you have a break statement.
4. Type Consistency
Be mindful of data types. You can't do math with strings and booleans mixed together.
5. Meaningful Variable Names
Use descriptive names like naam,age,score instead ofx,y,z.
Complete Example Program
Here's a comprehensive example that demonstrates multiple features:
// Delhi Temperature Checker
bhauk "=== Delhi Weather App ==="
bhauk ""
// Variables
chutiye ye city hai "Delhi"
chutiye ye temp hai 45
chutiye ye humidity hai 60
// Print info
bhauk "City:"
bhauk city
bhauk "Temperature:"
bhauk temp
bhauk "Humidity:"
bhauk humidity
bhauk ""
// Conditional check
bsdk agar temp > 40 kar: bhauk "Garmi bahut hai bc!"
bsdk agar temp < 15 kar: bhauk "Thandi hai bhai"
// Array of metro stations
chutiye ye stations hai ["Rajiv Chowk", "Kashmere Gate", "Chandni Chowk"]
bhauk "Popular Metro Stations:"
bhauk stations[0]
bhauk stations[1]
// Hash with Delhi facts
chutiye ye facts hai {
"food": "Chole Bhature",
"transport": "Metro",
"language": "Hindi"
}
bhauk ""
bhauk "Best food:"
bhauk facts["food"]
// Function
kaand checkWeather(temperature) {
bsdk agar temperature > 35 kar: bhauk "AC chala le"
bsdk agar temperature < 20 kar: bhauk "Sweater pehen le"
}
bhauk ""
checkWeather(temp)
// Loop
bhauk ""
bhauk "Counting down:"
chutiye ye count hai 5
jab tak maa count > 0 na maane: count = count - 1
bhauk "Done!"
// Switch case
chutiye ye season hai "summer"
bhauk ""
bhauk "Season advice:"
mood season {
dekh "summer": bhauk "Stay hydrated!"
dekh "winter": bhauk "Bundle up!"
dekh "monsoon": bhauk "Carry umbrella!"
default: bhauk "Enjoy the weather!"
}
bhauk ""
bhauk "=== Program Complete ==="
nikal lawdeKeywords Reference
Quick reference of all KaleshScript keywords:
chutiye ye ... haiVariable declaration
bhaukPrint/output statement
sahiBoolean true
bekaarBoolean false
bsdk agar ... kar:If statement
warna:Else statement
jab tak maa ... na maane:While loop
ruk jaa bcBreak statement
aage baddh bcContinue statement
mood ... { }Switch statement
dekh ... :Switch case
default:Switch default case
kaand ... { }Function definition
try kar: ... , pakad mc:Try-catch
Suna lawde()Input function
nikal lawdeExit program (REQUIRED)
Tere baap ne mehnat se banayi hai
KaleshScript - NOT RECOMMENDED FOR KIDS!