This is the fun programming language. Do Programming in Nepali Language, kind of Nepangrezi.
-
First, make sure you have Node.js installed. If not, install it from nodejs.org
-
Clone this repository:
git clone https://github.com/subhamghimire/nepaliko.js.git
cd nepaliko.js
- Install dependencies:
npm install
- Make the CLI executable:
chmod +x src/cli.js
- Create a global link to the nepaliko command:
sudo ln -s "$(pwd)/src/cli.js" /usr/local/bin/nepaliko
namaste bhana "Hello k cha khabar"; dhanyabad
This is the example where namaste
is the entrypoint for the program and program must end with dhanyabad
. Anything outside of it will be ignored.
nepaliko example.nepaliko
Hello k cha khabar
Variables can be declared using yo
keyword:
namaste yo a = 1; yo b = "two"; yo c = 3; a = a + 1; b = 25; c *= 5; dhanyabad
- Numbers:
yo a = 2;
- Strings:
yo b = "Hello";
oryo c = 'World';
- Boolean:
yo d = thik;
(true) oryo e = bethik;
(false) - Null:
yo f = khali;
Use yadi
for if statements and nabhaye
for else:
namaste yo a = 10; yadi (a < 20) { bhana "a is less than 20"; } nabhaye { bhana "a is greater than or equal to 20"; } dhanyabad
Use jaba samma
for while loops:
namaste yo counter = 0; jaba samma (counter < 5) { bhana "Counter is ", counter; counter = counter + 1; } dhanyabad
The nepaliko.js interpreter works in several stages:
-
Lexical Analysis (Tokenizer)
- Converts source code into tokens
- Recognizes keywords like
namaste
,dhanyabad
,yo
,bhana
, etc. - Handles operators, identifiers, and literals
-
Parsing (Parser)
- Converts tokens into an Abstract Syntax Tree (AST)
- Validates syntax and structure
- Creates nodes for different program elements (variables, conditions, loops)
-
Interpretation (Interpreter)
- Walks through the AST
- Converts nepaliko syntax to JavaScript
- Handles variable scoping and operations
-
Execution
- The generated JavaScript is executed using Node.js
- Results are displayed in the console
Nepaliko code:
namaste yo a = 10; bhana "Value is ", a; dhanyabad
Gets translated to JavaScript:
let a = 10; console.log("Value is ", a);
Feel free to contribute to this project by:
- Forking the repository
- Creating a feature branch
- Making your changes
- Submitting a pull request
MIT License - feel free to use this project for any purpose.