lyanglyang 0.1.0

Lyangpiler - A VM for the LyangLang programming language with native Nepali syntax
lyanglyang-0.1.0 is not a library.

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.

LyangLang License Build

Get Lyangpiler in one step

From the terminal (recommended) — copy one block, paste, press Enter.

Mac or Linux

curl -fsSL https://raw.githubusercontent.com/Konseptt/LyangLang/main/install.sh | bash

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 lyangpiler folder and double-click install.cmd (or open START_HERE.txt).
  • Mac / Linux: open Terminal in the extracted lyangpiler folder and run bash install-from-folder.sh, then source ~/.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

  • Natural Nepali Syntax: Write code using familiar Nepali words and phrases for a more intuitive programming experience. Commands like bol mug (print) and oi 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 / bhaglai)
    • Arithmetic: jod, ghata, guna, bhag
    • Strings and + concatenation; bol mug and oi mug bhan for I/O
    • Conditionals: yedi / yadi, aile feri, sakiyo with string comparisons (case-insensitive)
    • // line comments
  • Language guide sections below also describe planned features (e.g. ghumu, jabsamma, kaam, richer yadi/natra) that are not all implemented in this repository yet—use lyangpiler check on .nbh files 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:

docker build -t lyangpiler .
docker run --rm -v "$PWD:/work" -w /work lyangpiler run ./example.nbh --vm

Any OS with Rust already installed:

cargo install lyanglyang --locked

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 curl or wget on Unix, built-in PowerShell on Windows).
  • Build from source: Rust toolchain and Cargo.

Windows

  1. Recommended: one-liner in PowerShell (see Get Lyangpiler in one step).
  2. From a release zip: download lyangpiler-windows-x86_64.zip, extract it, then run install.cmd from inside the lyangpiler folder (or add that folder to your PATH manually).
  3. From source: clone the repo, then cargo build --release and copy target\release\lyangpiler.exe to a directory on your PATH.

Linux/macOS

  1. Recommended: one-liner with curl (see Get Lyangpiler in one step).
  2. From a release tarball: download the matching lyangpiler-*-*.tar.gz for your OS and CPU, extract it, and run ./install.sh from the repository if you cloned it, or put the lyangpiler binary on your PATH.
  3. From source: cargo build --release and copy target/release/lyangpiler to a directory on your PATH (for example /usr/local/bin).

Building from Source

  1. Clone the repository:
git clone https://github.com/Konseptt/LyangLang.git
cd LyangLang
  1. Build the project:
cargo build --release

The executable will be available at target/release/lyangpiler.exe (Windows) or target/release/lyangpiler (Unix-like systems).

  1. Make the file executable (Unix-like systems only):
chmod +x target/release/lyangpiler

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

  1. Create a new file with .nbh extension
  2. Write your LyangLang code
  3. Run using the Lyangpiler (VM recommended):
lyangpiler run your_program.nbh --vm

Legacy shorthand (same as above when the first arg is a file):

lyangpiler your_program.nbh --vm

Using the Command Line

Windows

# VM mode (recommended)
lyangpiler.exe run your_program.nbh --vm

Linux/macOS

# From a clone, before install:
./target/release/lyangpiler run your_program.nbh --vm

After install, use lyangpiler from your PATH (same run … --vm commands).

Command Line Arguments

  • run <file.nbh> [--vm] — run a program (--vm uses the bytecode VM; recommended)
  • <file.nbh> [--vm] — same as run when the first token is a path ending in .nbh

Examples

# Windows
lyangpiler.exe run example.nbh --vm

# Linux/macOS (from repo clone before install)
./target/release/lyangpiler run example.nbh --vm

Command Line Interface

The Lyangpiler provides a modern CLI with several subcommands for different operations:

# Run a program
lyangpiler run your_program.nbh

# Check a program for errors
lyangpiler check your_program.nbh

# Create a new project
lyangpiler new project_name

# Running with VM (recommended for performance)
lyangpiler run your_program.nbh --vm

Command Line Options

  • run: Execute a LyangLang program
    • Example: lyangpiler run program.nbh
    • Options: --vm to use the virtual machine execution mode
  • check: Validate syntax without executing
    • Example: lyangpiler check program.nbh
  • new: Create a new LyangLang project with template files
    • Example: lyangpiler new myproject
  • version: Display version information
    • Example: lyangpiler --version
  • help: Show help message and available commands
    • Example: lyangpiler --help or lyangpiler help

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: Addition
    result = 5 jod 3  # result = 8
    
  • ghata: Subtraction
    result = 10 ghata 4  # result = 6
    
  • guna: Multiplication
    result = 6 guna 3  # result = 18
    
  • bhag: Division
    result = 15 bhag 3  # result = 5
    

Comparison

  • barabar: Equal to
    yadi a barabar b bhane
    
  • thulo: Greater than
    yadi age thulo 18 bhane
    
  • sano: Less than
    yadi score sano 60 bhane
    

Logical Operations

  • ra: Logical AND
    yadi (age thulo 18) ra (score thulo 70) bhane
    
  • wa: Logical OR
    yadi (member barabar sahi) wa (vip barabar sahi) bhane
    
  • hoina: Logical NOT
    yadi (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 stack
  • LOAD/STORE: Load and store variables (LoadVariable, StoreVariable)
  • ADD/SUB/MUL/DIV: Arithmetic operations
  • CONCAT: String concatenation
  • PRINT: Output value to console
  • INPUT: Read user input from console
  • JMP: Conditional and unconditional jumps (Jump, JumpIfTrue, JumpIfFalse)
  • CMP: Compare values (Equal, NotEqual) on the VM today
  • HALT: 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

  1. Source code is parsed into an Abstract Syntax Tree (AST)
  2. AST is compiled into bytecode instructions
  3. VM initializes the stack and variable storage
  4. VM executes instructions sequentially, manipulating the stack
  5. Control flow instructions alter execution path as needed
  6. 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
git clone https://github.com/Konseptt/LyangLang.git
cd LyangLang

# Build the project
cargo build --release

# Run the executable
./target/release/lyangpiler run example.nbh --vm
./target/release/lyangpiler run myapp/main.nbh --vm

Running Tests

# Run all tests
cargo test

# Run specific tests
cargo test lexer
cargo test parser

# Run with verbose output
cargo test -- --nocapture

Contributing

  1. Fork the repository on GitHub
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes and add tests when possible
  4. Ensure all tests pass: cargo test
  5. Commit your changes: git commit -m 'Add new feature'
  6. Push to the branch: git push origin feature-name
  7. Submit a pull request through GitHub

Troubleshooting

Common Issues

  1. 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 sudo for installation
  2. 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
  3. Runtime errors

    • Check syntax matches LyangLang specifications
    • Verify variable declarations and types
    • Look for missing sakiyo statements to close blocks
    • Ensure string literals are properly quoted
    • Check for variable scope issues
  4. 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.nbh in 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.