Skip to content

subhamghimire/nepaliko.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nepaliko.js

npm package npm version

This is the fun programming language. Do Programming in Nepali Language, kind of Nepangrezi.

Installation

  1. First, make sure you have Node.js installed. If not, install it from nodejs.org

  2. Clone this repository:

git clone https://github.com/subhamghimire/nepaliko.js.git
cd nepaliko.js
  1. Install dependencies:
npm install
  1. Make the CLI executable:
chmod +x src/cli.js
  1. Create a global link to the nepaliko command:
sudo ln -s "$(pwd)/src/cli.js" /usr/local/bin/nepaliko

Usage

Create a new file (example.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.

Run

nepaliko example.nepaliko

Output

Hello k cha khabar

Language Features

Variables

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

Types

  • Numbers: yo a = 2;
  • Strings: yo b = "Hello"; or yo c = 'World';
  • Boolean: yo d = thik; (true) or yo e = bethik; (false)
  • Null: yo f = khali;

Conditions

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

Loops

Use jaba samma for while loops:

namaste
  yo counter = 0;
  jaba samma (counter < 5) {
    bhana "Counter is ", counter;
    counter = counter + 1;
  }
dhanyabad

How It Works

The nepaliko.js interpreter works in several stages:

  1. Lexical Analysis (Tokenizer)

    • Converts source code into tokens
    • Recognizes keywords like namaste, dhanyabad, yo, bhana, etc.
    • Handles operators, identifiers, and literals
  2. Parsing (Parser)

    • Converts tokens into an Abstract Syntax Tree (AST)
    • Validates syntax and structure
    • Creates nodes for different program elements (variables, conditions, loops)
  3. Interpretation (Interpreter)

    • Walks through the AST
    • Converts nepaliko syntax to JavaScript
    • Handles variable scoping and operations
  4. Execution

    • The generated JavaScript is executed using Node.js
    • Results are displayed in the console

Example Translation

Nepaliko code:

namaste
  yo a = 10;
  bhana "Value is ", a;
dhanyabad

Gets translated to JavaScript:

let a = 10;
console.log("Value is ", a);

Contributing

Feel free to contribute to this project by:

  1. Forking the repository
  2. Creating a feature branch
  3. Making your changes
  4. Submitting a pull request

License

MIT License - feel free to use this project for any purpose.

About

nepaliko.js 2022 is finally updated.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published