LyangLang
A programming language featuring natural Nepali syntax, designed to help Nepali speakers learn programming concepts in a familiar language. LyangLang bridges the gap between natural Nepali language and programming logic, creating an accessible entry point for native speakers.
Get Lyangpiler in one step
From the terminal (recommended) — copy one block, paste, press Enter.
Mac or Linux
|
Windows (PowerShell)
irm https://raw.githubusercontent.com/Konseptt/LyangLang/main/install.ps1 | iex
Windows if scripts are blocked
powershell -ExecutionPolicy Bypass -Command "irm https://raw.githubusercontent.com/Konseptt/LyangLang/main/install.ps1 | iex"
One-click download — save the file for your computer, extract it, then:
- Windows: open the
lyangpilerfolder and double-clickinstall.cmd(or openSTART_HERE.txt). - Mac / Linux: open Terminal in the extracted
lyangpilerfolder and runbash install-from-folder.sh, thensource ~/.lyangpiler/enable.sh.
| System | Direct download (latest release) |
|---|---|
| Windows 64-bit | lyangpiler-windows-x86_64.zip |
| Linux 64-bit Intel/AMD | lyangpiler-linux-x86_64.tar.gz |
| Linux 64-bit ARM | lyangpiler-linux-aarch64.tar.gz |
| macOS Apple Silicon | lyangpiler-macos-aarch64.tar.gz |
| macOS Intel | lyangpiler-macos-x86_64.tar.gz |
After the terminal installer finishes, Mac/Linux can run source ~/.lyangpiler/enable.sh once in that same window so lyangpiler works immediately without opening a new terminal.
With Rust installed: run cargo install lyanglyang --locked. This installs the lyangpiler command from crates.io.
Table of Contents
- Features
- Get Lyangpiler in one step
- Installation
- Running Programs
- Language Guide
- Loop Examples
- Sample Programs
- Error Handling
- Lyangpiler VM
- Project Structure
- Development
- Troubleshooting
- License
Features
-
Natural Nepali Syntax: Write code using familiar Nepali words and phrases for a more intuitive programming experience. Commands like
bol mug(print) andoi mug bhan(input) provide a close connection to everyday language. -
Bytecode Virtual Machine: The Lyangpiler VM offers efficient execution with precompiled bytecode for optimal performance across different platforms. The VM is stack-based with a clean and simple architecture.
-
Programming constructs (current Lyangpiler):
- Variables and assignments (
oi mug,mug jod/ghata/guna/bhag…lai) - Arithmetic:
jod,ghata,guna,bhag - Strings and
+concatenation;bol mugandoi mug bhanfor I/O - Conditionals:
yedi/yadi,aile feri,sakiyowith string comparisons (case-insensitive) //line comments
- Variables and assignments (
-
Language guide sections below also describe planned features (e.g.
ghumu,jabsamma,kaam, richeryadi/natra) that are not all implemented in this repository yet—uselyangpiler checkon.nbhfiles to confirm what parses today. -
Error Handling: Comprehensive error messages in English with clear line indicators and detailed explanations for debugging.
-
Cross-Platform Support: Runs on Windows, Linux, and macOS with consistent behavior and native installation packages.
-
Beginner-Friendly Design: Specifically crafted for educational purposes, making programming accessible to Nepali speakers with little to no programming experience.
-
Interpreter and Compiler: Use either the direct interpreter or the VM compilation mode to run your programs with a simple command-line interface.
Installation
Fastest way to try (binary, no Rust)
Use the Get Lyangpiler in one step section at the top of this page (terminal one-liners and download links).
Any OS with Docker:
Any OS with Rust already installed:
After a binary install: on Mac/Linux run source ~/.lyangpiler/enable.sh in the same terminal to use lyangpiler immediately, or open a new terminal. On Windows, the installer updates PATH for the current PowerShell window so lyangpiler usually works at once. If the command is not found, confirm ~/.lyangpiler/bin or %USERPROFILE%\.lyangpiler\bin is on your PATH.
Release archives use names like lyangpiler-linux-x86_64.tar.gz, lyangpiler-macos-aarch64.tar.gz, and lyangpiler-windows-x86_64.zip (see Releases). Older releases may use *-amd64* names; the install scripts try those as a fallback on Linux/mac x86_64.
Prerequisites
- Binary install: none (uses
curlorwgeton Unix, built-in PowerShell on Windows). - Build from source: Rust toolchain and Cargo.
Windows
- Recommended: one-liner in PowerShell (see Get Lyangpiler in one step).
- From a release zip: download
lyangpiler-windows-x86_64.zip, extract it, then runinstall.cmdfrom inside thelyangpilerfolder (or add that folder to your PATH manually). - From source: clone the repo, then
cargo build --releaseand copytarget\release\lyangpiler.exeto a directory on your PATH.
Linux/macOS
- Recommended: one-liner with
curl(see Get Lyangpiler in one step). - From a release tarball: download the matching
lyangpiler-*-*.tar.gzfor your OS and CPU, extract it, and run./install.shfrom the repository if you cloned it, or put thelyangpilerbinary on your PATH. - From source:
cargo build --releaseand copytarget/release/lyangpilerto a directory on your PATH (for example/usr/local/bin).
Building from Source
- Clone the repository:
- Build the project:
The executable will be available at target/release/lyangpiler.exe (Windows) or target/release/lyangpiler (Unix-like systems).
- Make the file executable (Unix-like systems only):
Quick Installation
If you already downloaded a release archive, extract it and run install.cmd (Windows) from inside the lyangpiler folder, or use the one-line installers in Get Lyangpiler in one step so lyangpiler is on your PATH.
Running Programs
- Create a new file with
.nbhextension - Write your LyangLang code
- Run using the Lyangpiler (VM recommended):
Legacy shorthand (same as above when the first arg is a file):
Using the Command Line
Windows
# VM mode (recommended)
lyangpiler.exe run your_program.nbh --vm
Linux/macOS
# From a clone, before install:
After install, use lyangpiler from your PATH (same run … --vm commands).
Command Line Arguments
run <file.nbh> [--vm]— run a program (--vmuses the bytecode VM; recommended)<file.nbh> [--vm]— same asrunwhen the first token is a path ending in.nbh
Examples
# Windows
# Linux/macOS (from repo clone before install)
Command Line Interface
The Lyangpiler provides a modern CLI with several subcommands for different operations:
# Run a program
# Check a program for errors
# Create a new project
# Running with VM (recommended for performance)
Command Line Options
run: Execute a LyangLang program- Example:
lyangpiler run program.nbh - Options:
--vmto use the virtual machine execution mode
- Example:
check: Validate syntax without executing- Example:
lyangpiler check program.nbh
- Example:
new: Create a new LyangLang project with template files- Example:
lyangpiler new myproject
- Example:
version: Display version information- Example:
lyangpiler --version
- Example:
help: Show help message and available commands- Example:
lyangpiler --helporlyangpiler help
- Example:
Language Guide
1. Basic Syntax
Variables and Assignment
# Number variable
mug rakhnu 42 lai number
# String variable
mug rakhnu "Hello" lai text
# Boolean variable
mug rakhnu sahi lai bool_var
# Variable assignment with calculation
number = 10 jod 5 # number = 15
Input/Output
# Output to console
bol mug "Namaste!"
# Output with variable interpolation
bol mug "Your score is: " jod score
# Input from user
oi mug bhan user_input
# Input with prompt
bol mug "Enter your name:"
oi mug bhan user_name
Operators
- Arithmetic:
jod(add),ghata(subtract),guna(multiply),bhag(divide) - Comparison:
barabar(equals),thulo(greater than),sano(less than) - Logical:
ra(and),wa(or),hoina(not)
Functions
# Function definition
kaam namaste_bhan(naam) {
bol mug "Namaste " jod naam jod "!"
}
# Function call
namaste_bhan("Sathi")
2. Control Flow
Conditional Statements
# Simple if-else
yadi age >= 18 bhane
bol mug "You can vote!"
natra
bol mug "Too young to vote"
sakiyo
# Multiple conditions
yadi score >= 90 bhane
bol mug "Grade A"
aile feri score >= 80 bhane
bol mug "Grade B"
aile feri score >= 70 bhane
bol mug "Grade C"
natra
bol mug "Need improvement"
sakiyo
Loops
# Basic for loop (repeat 5 times)
ghumu 5 choti
bol mug "Iteration"
sakiyo
# While loop
jabsamma number <= 10 cha
bol mug number
number = number jod 1
sakiyo
# Loop with break
jabsamma sahi cha
oi mug bhan input
yadi input barabar "exit" bhane
rokana
sakiyo
bol mug "You entered: " jod input
sakiyo
# Loop with continue
ghumu 10 choti
yadi count % 2 barabar 0 bhane
arko hernu # Skip even numbers
sakiyo
bol mug count # Print odd numbers only
sakiyo
Control Flow Examples
Loops
# Count-controlled loop (repeat 5 times)
ghumu 5 choti
bol mug "Iteration number" jod count
sakiyo
# Condition-controlled loop (while loop)
jabsamma number sano 10 cha
bol mug "Current number:" jod number
number = number jod 1
sakiyo
Nested Control Flow
You can nest both loops and conditionals:
ghumu 3 choti
yedi count babaal 2 bhane
bol mug "Second iteration"
natra
bol mug "Other iteration"
sakiyo
sakiyo
3. Operations
Arithmetic
jod: Additionresult = 5 jod 3 # result = 8ghata: Subtractionresult = 10 ghata 4 # result = 6guna: Multiplicationresult = 6 guna 3 # result = 18bhag: Divisionresult = 15 bhag 3 # result = 5
Comparison
barabar: Equal toyadi a barabar b bhanethulo: Greater thanyadi age thulo 18 bhanesano: Less thanyadi score sano 60 bhane
Logical Operations
ra: Logical ANDyadi (age thulo 18) ra (score thulo 70) bhanewa: Logical ORyadi (member barabar sahi) wa (vip barabar sahi) bhanehoina: Logical NOTyadi (finished hoina) bhane
4. Data Types
LyangLang supports three primary data types:
Numbers
age = 25
temperature = -5
result = 10 jod 15
Strings
name = "Ram Bahadur"
greeting = "Namaste"
message = greeting jod ", " jod name jod "!"
Booleans
isValid = sahi # true
isComplete = galat # false
5. Functions and Procedures
Define reusable blocks of code:
kaam add_numbers(a, b) {
result = a jod b
bol mug "Sum: " jod result
result # Return value
}
# Call the function
sum = add_numbers(5, 7)
Loop Examples
Counted Loop (For Loop)
# Print numbers 1 to 5
ghumu 5 choti
bol mug k
sakiyo
While Loop
k = 1
jabsamma k <= 5 cha
bol mug k
k = k jod 1
sakiyo
Both loops support break ("rokana") and continue ("arko hernu") statements.
Sample Programs
Hello World
bol mug "Namaste, world!"
Expected Output:
Namaste, world!
Simple Calculator
# Simple calculator
bol mug "Pahilo Number:"
oi mug bhan num1
bol mug "Dosro Number:"
oi mug bhan num2
mug rakhnu num1 jod num2 lai result
bol mug "Sum: " jod result
mug rakhnu num1 ghata num2 lai diff
bol mug "Difference: " jod diff
mug rakhnu num1 guna num2 lai product
bol mug "Product: " jod product
mug rakhnu num1 bhag num2 lai quotient
bol mug "Quotient: " jod quotient
Expected Input/Output:
Pahilo Number:
> 10
Dosro Number:
> 5
Sum: 15
Difference: 5
Product: 50
Quotient: 2
User Greeting
bol mug "Timro naam k ho?"
oi mug bhan userName
bol mug "Namaste, " jod userName jod "!"
Expected Input/Output:
Timro naam k ho?
> Ram
Namaste, Ram!
Age Verification
bol mug "Timro umer kati ho?"
oi mug bhan age
yadi age babaal "18" bhane
bol mug "Tapai adult hununcha!"
aile feri age babaal "18" hoina bhane
bol mug "Tapai adult hunuhunna!"
sakiyo
Expected Input/Output:
Timro umer kati ho?
> 20
Tapai adult hununcha!
or
Timro umer kati ho?
> 16
Tapai adult hunuhunna!
Color Preference
bol mug "Timro favourite color k ho?"
oi mug bhan color
yedi color babaal "rato" bhane
bol mug "Rato rang maya ko rang ho"
aile feri color babaal "nilo" bhane
bol mug "Nilo rang aakash jastai shanta cha"
aile feri
bol mug color jod " ramro color ho"
sakiyo
Expected Input/Output:
Timro favourite color k ho?
> rato
Rato rang maya ko rang ho
Error Handling
Error Types
- Syntax Errors: Malformed code or invalid token sequences
- Runtime Errors: Issues that occur during program execution
- Type Errors: Invalid operations between incompatible data types
- Name Errors: Using undefined variables or functions
Error Format
Error at line X: [Error Type]
Details: [Error Description]
Code: [Problematic code snippet]
^---- Error location indicator
Common Error Messages
अपरिभाषित चर(Undefined variable): Occurs when you try to use a variable that hasn't been declared.अमान्य संचालन(Invalid operation): Happens when you perform an operation that's not permitted, like dividing by zero.प्रकार बेमेल(Type mismatch): When you try to perform operations on incompatible types, like adding a number to a boolean.वाक्य रचना त्रुटि(Syntax error): This occurs when your code doesn't follow the LyangLang grammar rules.
Lyangpiler VM
Architecture
- Stack-based virtual machine: Uses a stack to store and manipulate values during execution
- Register-free design for simplicity: No need to manage registers, making the VM easier to understand
- Bytecode instruction set: Optimized for Nepali language constructs and efficient execution
Bytecode Instructions
PUSH: Push value onto stack (PushNumber,PushString,PushBoolean)POP: Remove top value from stackLOAD/STORE: Load and store variables (LoadVariable,StoreVariable)ADD/SUB/MUL/DIV: Arithmetic operationsCONCAT: String concatenationPRINT: Output value to consoleINPUT: Read user input from consoleJMP: Conditional and unconditional jumps (Jump,JumpIfTrue,JumpIfFalse)CMP: Compare values (Equal,NotEqual) on the VM todayHALT: Stop program execution
Memory Management
- Stack-based memory allocation: Values are pushed and popped from the stack as needed
- Variable storage: Separate from the stack for quick access
- String pool: Efficiently stores string literals
- Automatic cleanup: Resources are automatically reclaimed when the VM terminates
Execution Model
- Source code is parsed into an Abstract Syntax Tree (AST)
- AST is compiled into bytecode instructions
- VM initializes the stack and variable storage
- VM executes instructions sequentially, manipulating the stack
- Control flow instructions alter execution path as needed
- Program terminates when the HALT instruction is reached
Project Structure
src/
├── lexer.rs # Tokenization of source code
├── parser.rs # Parsing tokens into AST
├── ast.rs # Abstract Syntax Tree definitions
├── token.rs # Token definitions and types
├── bytecode.rs # Bytecode instruction definitions
├── compiler.rs # Compiles AST to bytecode
├── vm.rs # Virtual Machine implementation
├── error.rs # Error handling definitions
├── interpreter.rs # Direct interpreter (alternative to VM)
└── main.rs # Entry point and CLI handling
example.nbh # Sample program at repo root
myapp/
├── main.nbh # Longer sample (slang + hisab demo)
└── README.md # How to run myapp
Development
Building from Source
# Clone the repository
# Build the project
# Run the executable
Running Tests
# Run all tests
# Run specific tests
# Run with verbose output
Contributing
- Fork the repository on GitHub
- Create a feature branch:
git checkout -b feature-name - Make your changes and add tests when possible
- Ensure all tests pass:
cargo test - Commit your changes:
git commit -m 'Add new feature' - Push to the branch:
git push origin feature-name - Submit a pull request through GitHub
Troubleshooting
Common Issues
-
Installation failures
- Verify Rust toolchain installation:
rustc --version - Check system PATH configuration: Ensure the installation directory is in your PATH
- For permissions issues on Linux/macOS, try using
sudofor installation
- Verify Rust toolchain installation:
-
Compilation errors
- Update Rust to latest stable version:
rustup update stable - Clean and rebuild project:
cargo clean && cargo build - Check for missing dependencies:
cargo check
- Update Rust to latest stable version:
-
Runtime errors
- Check syntax matches LyangLang specifications
- Verify variable declarations and types
- Look for missing
sakiyostatements to close blocks - Ensure string literals are properly quoted
- Check for variable scope issues
-
Command not found errors
- Make sure the installation was successful
- Verify the PATH configuration in your shell
- Try using the full path to the executable
Getting Help
- Open an issue on the project repository
- Check existing documentation in the wiki
- Try
example.nbhin the repository root - Join the community discussions in the forums
License
MIT License - See LICENSE file for details.
Copyright (c) 2023 LyangLang Team
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.