nepdai
v2.0.3
Published
Nepdai CLI - A command line interface for the Nepdai programming language
Maintainers
Readme
नेपदाइ
A Programming Language with Nepali Keywords
About NepDai
NepDai is a fun Nepali programming language inspired by Bhailang and adds a unique Nepali twist to the playful coding experience. The language combines familiar programming concepts with Nepali terminology, creating a unique and culturally relevant coding experience.
"Namaste Dai" - Every NepDai program begins with this traditional Nepali greeting!
npm i -g nepdai📖 Language Keywords
| NepDai | English | Description |
|--------|---------|-------------|
| solti | let/var | Variable declaration |
| yadi (condition) bhane | if | Conditional statement |
| natra | else | Else clause |
| jaba samma | while | While loop |
| vai vayo rokki | break | Break statement |
| aghi badh vai | continue | Continue statement |
| lekh | print | Print to console |
| thik | true | Boolean true |
| galat | false | Boolean false |
| khali | null | Null value |
Namaste Dai
lekh "Namaste Dai";nepdai test.nepdai Namaste Dai tokens <file> Show tokens for a Nepdai program
ast <file> Show AST for a Nepdai program
repl Start Nepdai REPL// Error: If anything is present here, greeting above all
Namaste Dai
// code here, and no semicolon after greetingNamaste Dai
lekh "Hello, World!";
solti name = "Nepal";
lekh "Country:", name;
solti a = 5;
solti b = 10;
lekh "Sum:", a + b;Namaste Dai
solti a = 1;
solti b = "sahil";
a = a++;
b = "sahilverse";
c = a + 10;Namaste Dai
solti string = "string";
solti number = 10;
solti float = 10.2; // Also a number
solti true = thik;
solti false = galat;
solti null = khali; Namaste Dai
// Array examples in Nepdai
solti numbers = [1, 2, 3, 4, 5];
solti names = ["Ram", "Shyam", "Gita"];
solti mixed = [1, "hello", thik, khali];
lekh "Numbers:", numbers;
lekh "Names:", names;
lekh "Mixed array:", mixed;
// Empty array
solti empty = [];
lekh "Empty array:", empty;
// Other Operations on Arrays are not supported right now
| Operator | Description | Example | Result |
|----------|-------------|---------|--------|
| + | Addition | 5 + 3 | 8 |
| - | Subtraction | 5 - 3 | 2 |
| * | Multiplication | 5 * 3 | 15 |
| / | Division | 6 / 3 | 2 |
| % | Modulo (Remainder) | 7 % 3 | 1 |
| ** | Exponentiation | 2 ** 3 | 8 |
Namaste Dai
solti a = 10;
solti b = 3;
lekh "Addition:", a + b; // 13
lekh "Subtraction:", a - b; // 7
lekh "Multiplication:", a * b; // 30
lekh "Division:", a / b; // 3.333...
lekh "Modulo:", a % b; // 1
lekh "Power:", a ** b; // 1000| Operator | Description | Example | Result |
|----------|-------------|---------|--------|
| == | Equal to | 5 == 5 | thik |
| != | Not equal to | 5 != 3 | thik |
| > | Greater than | 5 > 3 | thik |
| < | Less than | 3 < 5 | thik |
| >= | Greater than or equal | 5 >= 5 | thik |
| <= | Less than or equal | 3 <= 5 | thik |
Namaste Dai
solti age = 25;
lekh "Is adult:", age >= 18; // thik
lekh "Is teenager:", age < 20; // galat
lekh "Exact age:", age == 25; // thik| Operator | Description | Example | Result |
|----------|-------------|---------|--------|
| && | Logical AND | thik && galat | galat |
| \|\| | Logical OR | thik \|\| galat | thik |
| ! | Logical NOT | !thik | galat |
Namaste Dai
solti age = 25;
solti hasLicense = thik;
yadi (age >= 18 && hasLicense) bhane {
lekh "Can drive!";
}
yadi (age < 16 || !hasLicense) bhane {
lekh "Cannot drive!";
}| Operator | Description | Example | Equivalent |
|----------|-------------|---------|------------|
| = | Simple assignment | a = 5 | a = 5 |
| += | Add and assign | a += 3 | a = a + 3 |
| -= | Subtract and assign | a -= 2 | a = a - 2 |
| *= | Multiply and assign | a *= 2 | a = a * 2 |
| /= | Divide and assign | a /= 2 | a = a / 2 |
Namaste Dai
solti score = 100;
score += 50; // score is now 150
score -= 25; // score is now 125
score *= 2; // score is now 250
score /= 5; // score is now 50
lekh "Final score:", score;| Operator | Description | Example | Effect |
|----------|-------------|---------|--------|
| ++ | Increment (postfix) | a++ | Increase a by 1 |
| -- | Decrement (postfix) | a-- | Decrease a by 1 |
Namaste Dai
solti counter = 0;
lekh "Initial:", counter; // 0
counter++;
lekh "After increment:", counter; // 1
counter--;
lekh "After decrement:", counter; // 0Namaste Dai
solti firstName = "Ram";
solti lastName = "Sharma";
solti fullName = firstName + " " + lastName;
lekh "Full name:", fullName; // Ram Sharma
// Mixing strings and numbers
solti age = 25;
solti message = "I am " + age + " years old";
lekh message; // I am 25 years old!(Logical NOT),-(Unary minus)**(Exponentiation)*,/,%(Multiplication, Division, Modulo)+,-(Addition, Subtraction)<,<=,>,>=(Comparison)==,!=(Equality)&&(Logical AND)||(Logical OR)=,+=,-=,*=,/=(Assignment)
Namaste Dai
solti result = 2 + 3 * 4; // 14 (not 20)
solti result2 = (2 + 3) * 4; // 20 (parentheses change order)
lekh "Result 1:", result; // 14
lekh "Result 2:", result2; // 20Namaste Dai
// Conditional statements in Nepdai
solti age = 25;
solti name = "Ram";
lekh "Name:", name;
lekh "Age:", age;
yadi (age >= 18) bhane {
lekh name, "is an adult";
} natra {
lekh name, "is a minor";
}
// Nested conditionals
solti score = 85;
yadi (score >= 90) bhane {
lekh "Grade: A";
} natra yadi (score >= 80) bhane {
lekh "Grade: B";
} natra yadi (score >= 70) bhane {
lekh "Grade: C";
} natra {
lekh "Grade: F";
}
Namaste Dai
// While loop with break and continue
solti i = 1;
lekh "Counting with break and continue:";
jaba samma (i <= 10) {
yadi (i == 5) bhane {
lekh "Skipping", i;
i++;
aghi badh vai;
}
yadi (i == 8) bhane {
lekh "Breaking at", i;
vai vayo rokki;
}
lekh "Number:", i;
i++;
}
lekh "Loop finished!";
Crafted in Sahilverse for the Nepali programming community
