Skip to content

Client playground for YaarScript - a rust-based multi-pass compiler with Urdu-inspired syntax. This repository builds optimized Three-Address Code, running natively in-browser via WebAssembly

Notifications You must be signed in to change notification settings

BazilSuhail/YaarScript-Client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

58 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

YaarScript YaarScript Logo

A slang-infused Urdu styled programming language that turns regular code into cool slang

Next.js React WebAssembly Rust License

Try Online Playground โ€ข Documentation โ€ข Examples โ€ข Actual Compiler


๐Ÿ“– Overview

YaarScript is a modern, professional programming language that brings the warmth and familiarity of the Urdu language to software development. Built with Rust and compiled to WebAssembly, YaarScript offers a unique blend of cultural accessibility and cutting-edge technology.

๐ŸŽฏ Key Highlights

  • ๐ŸŒ Urdu-Inspired Syntax โ€“ Natural keywords like agar, warna, dohrao, bolo make coding intuitive for Urdu speakers
  • โšก Lightning Fast โ€“ Entire compiler runs in the browser via WebAssembly (wasm32-unknown-unknown)
  • ๐Ÿ”ง Industrial-Grade โ€“ Multi-pass compiler with fixed-point optimization, constant folding, and dead code elimination
  • ๐ŸŽจ Modern IDE โ€“ Professional web-based editor with syntax highlighting and real-time execution
  • ๐Ÿ”’ Strong Type System โ€“ Strict typing with no implicit coercion for safer code
  • ๐Ÿš€ Zero Installation โ€“ Run directly in your browser with our online playground

โœจ Features

๐Ÿ› ๏ธ Compiler Architecture

YaarScript features a sophisticated multi-pass compilation pipeline:

  1. Lexical Analysis โ€“ Tokenization with full Unicode support
  2. Syntax Analysis โ€“ Top-Down Operator Precedence (Pratt) Parser
  3. Semantic Analysis โ€“ Comprehensive scope management and type checking
  4. IR Generation โ€“ Three-Address Code (TAC) intermediate representation
  5. Optimization โ€“ Fixed-point optimization passes
  6. Execution โ€“ High-performance WASM virtual machine

๐Ÿ’ก Language Features

  • โœ… Strong Type System โ€“ number, float, double, char, lafz (string), faisla (boolean)
  • โœ… Control Flow โ€“ agar/warna (if/else), dohrao (for), jabtak (while), karo-jabtak (do-while)
  • โœ… Switch Statements โ€“ intekhab with agar_ho cases
  • โœ… Functions โ€“ First-class functions with return types
  • โœ… Enumerations โ€“ qism for defining custom enums
  • โœ… Constants โ€“ pakka for immutable values, sab_ke_liye for globals
  • โœ… Operators โ€“ Full arithmetic, logical, and comparison operations
  • โœ… Loop Control โ€“ bas_kar (break), aagay_baro (continue)

๐Ÿš€ Getting Started

Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js (v18 or higher) โ€“ Download
  • Rust (for building compiler) โ€“ Install via rustup
  • wasm-pack (for WebAssembly compilation) โ€“ cargo install wasm-pack

Installation

Step 1: Build the WASM Compiler

# Clone the compiler repository (wasm-compiler branch)
git clone -b wasm-compiler https://github.com/YourUsername/YaarScript-Compiler.git
cd YaarScript-Compiler

# Build the WASM package
wasm-pack build --target web

# This generates a 'pkg' folder with the compiled WASM files

Step 2: Setup the Web Interface

# Clone the web client repository
git clone https://github.com/BazilSuhail/YaarScript-Client.git
cd YaarScript-Client

# Copy the compiled WASM package
# Copy the 'pkg' folder from the compiler to the client root directory

# Install dependencies
npm install

# Run the development server
npm run dev

Open http://localhost:3000 in your browser to see the application.

Directory Structure

YaarScript-Client/
โ”œโ”€โ”€ pkg/                      # WASM compiled files (from compiler)
โ”‚   โ”œโ”€โ”€ compiler.js
โ”‚   โ”œโ”€โ”€ compiler_bg.wasm
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ page.jsx             # Home page
โ”‚   โ”œโ”€โ”€ editor/              # Online code editor
โ”‚   โ””โ”€โ”€ docs/                # Documentation pages
โ”œโ”€โ”€ components/
โ”‚   โ”œโ”€โ”€ home-page/           # Landing page components
โ”‚   โ”œโ”€โ”€ editor/              # Editor components
โ”‚   โ””โ”€โ”€ docs/                # Documentation components
โ”œโ”€โ”€ public/                  # Static assets
โ””โ”€โ”€ package.json

๐Ÿ“ Quick Examples

Hello World

yaar {
    bolo("Assalam-o-Alaikum, World!\n");
}

Variables and Types

yaar {
    number age = 25;
    float price = 99.99;
    lafz name = "Ahmed";
    faisla is_valid = sahi;
    
    bolo("Name: ", name, "\n");
    bolo("Age: ", age, "\n");
}

Conditionals (agar/warna)

yaar {
    number score = 85;
    
    agar (score >= 90) {
        bolo("Grade: A\n");
    } warna agar (score >= 80) {
        bolo("Grade: B\n");
    } warna agar (score >= 70) {
        bolo("Grade: C\n");
    } warna {
        bolo("Grade: F\n");
    }
}

Loops (dohrao)

yaar {
    dohrao (number i = 0; i < 5; i++) {
        bolo("Iteration: ", i, "\n");
    }
}

Functions

number add(number a, number b) {
    wapsi a + b;
}

khaali greet(lafz name) {
    bolo("Hello, ", name, "!\n");
}

yaar {
    number sum = add(10, 20);
    bolo("Sum: ", sum, "\n");
    
    greet("YaarScript");
}

Switch Statement (intekhab)

yaar {
    number day = 3;
    
    intekhab (day) {
        agar_ho 1:
            bolo("Monday\n");
            bas_kar;
        agar_ho 2:
            bolo("Tuesday\n");
            bas_kar;
        agar_ho 3:
            bolo("Wednesday\n");
            bas_kar;
        aakhir:
            bolo("Other day\n");
    }
}

๐Ÿ“š Documentation

Data Types

Type Description Example
number Integer values 42
float Single precision 3.14
double Double precision 2.718281828
char Single character 'A'
lafz String values "Hello"
faisla Boolean sahi, galat
khaali Void/Empty Function return type

Keywords Reference

Keyword English Equivalent Usage
yaar main Main function entry point
bolo print Output to console
agar if Conditional statement
warna else Alternative branch
dohrao for For loop
jabtak while While loop
karo do Do-while loop
intekhab switch Switch statement
agar_ho case Case in switch
aakhir default Default case
wapsi return Return from function
bas_kar break Break loop/switch
aagay_baro continue Continue loop
pakka const Constant declaration
sab_ke_liye global Global scope
qism enum Enumeration
sahi true Boolean true
galat false Boolean false

Operators

Arithmetic: +, -, *, /, %
Comparison: ==, !=, >, <, >=, <=
Logical: &&, ||, !
Increment/Decrement: ++, --


๐ŸŽฎ Online Playground

Visit our Online Editor to start coding immediately without any installation. The playground features:

  • ๐ŸŽจ Syntax Highlighting โ€“ Clean, readable code editor
  • โšก Instant Compilation โ€“ Real-time compilation and execution
  • ๐Ÿ“บ Live Terminal โ€“ See output as you code
  • ๐Ÿ’พ Auto-Save โ€“ Your code is saved automatically
  • ๐ŸŒ™ Dark Theme โ€“ Easy on the eyes

๐Ÿ› ๏ธ Development

Available Scripts

# Start development server
npm run dev

# Build for production
npm run build

# Start production server
npm start

# Lint code
npm run lint

Tech Stack

  • Frontend: Next.js 16.1, React 19.2, Tailwind CSS 4
  • Animations: Framer Motion
  • Backend Compiler: Rust (compiled to WASM)
  • Icons: React Icons
  • Code Editor: Custom implementation

๐Ÿค Contributing

We welcome contributions from the community! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Areas for Contribution

  • ๐Ÿ› Bug fixes and improvements
  • ๐Ÿ“ Documentation enhancements
  • ๐ŸŽจ UI/UX improvements
  • ๐ŸŒ Translations and localization
  • โœจ New language features
  • ๐Ÿงช Test coverage

๐ŸŽฏ Roadmap

  • Array and list data structures
  • String manipulation functions
  • File I/O operations
  • Standard library expansion
  • Module system
  • Package manager
  • Debugging tools
  • Mobile app version
  • VS Code extension

๐Ÿ“„ License

This project is open source and available under the MIT License.


๐Ÿ™ Acknowledgments

  • Built with โค๏ธ for the Urdu-speaking developer community
  • Powered by Rust and WebAssembly
  • UI framework by Next.js and React
  • Special thanks to all contributors and supporters

๐Ÿ“ง Contact & Support


Made with โค๏ธ by the YaarScript Team

โญ Star this repo if you find it helpful! โญ

About

Client playground for YaarScript - a rust-based multi-pass compiler with Urdu-inspired syntax. This repository builds optimized Three-Address Code, running natively in-browser via WebAssembly

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published