# 🟢 The Gujju Lang (TGL) v1.0 - Shuruaat The Gujju Lang (TGL) is a **beginner-friendly, dynamically-typed interpreted programming language** featuring **Gujarati keywords** combined with a highly intuitive, **Pythonic syntax** (optional parentheses, optional colons before blocks). Built entirely in C++17, TGL operates natively on Windows with **sub-millisecond execution times** (eliminating WSL/virtual machine startup delays), making it an educational and fun language to learn, read, and write. --- ## 🚀 Key Features * **Gujarati Syntax**: Write code using local, native keywords (`batav`, `jo`, `naito`, `ferthi`, `kam`, etc.). * **Pythonic Control Flow**: Parentheses around conditional statements and loops are completely optional, and colons `:` can be placed before code blocks. * **Else-If Chaining**: Smooth conditional nesting with `anai_to_aa` (else if) and `naito` (else). * **Tree-Walking Interpreter**: Parses code into an Abstract Syntax Tree (AST) and evaluates statements dynamically with robust lexical and semantic error reporting. * **Module Import System**: Seamlessly import other `.gujju` modules into your workspace with the `lav` keyword. * **Built-in Standard Library**: Equipped with 14 out-of-the-box functions for console I/O, array mutation, string parsing, type querying, and mathematical operations. --- ## 📂 Repository Structure ``` The Gujju lang/ ├── CMakeLists.txt # CMake build configuration ├── gujju.bat # Standalone CLI execution script ├── chalu.bat # "chalu kar" execution script wrapper ├── chalukar.bat # "chalukar" execution script wrapper ├── run_tests.bat # Automated integration test runner ├── README.md # Complete language documentation & reference ├── build/bin/gujju.exe # Native, zero-latency Windows binary ├── src/ # Interpreter Source Code │ ├── main.cpp # REPL and CLI file execution logic │ ├── lexer/ # Lexer scanner and tokens definition │ ├── parser/ # AST declarations and recursive descent parsing │ ├── interpreter/ # Scoped environments, built-ins, and evaluator │ └── utils/ # Errors & Logging utilities └── examples/ # Annotated feature scripts ├── 01_hello.gujju # Prints Hello World ├── 02_variables.gujju # Variable types and math ├── 03_loops.gujju # If-Else, Switch, For, While, Foreach ├── 04_functions.gujju # Closures, recursion, and calls ├── 05_arrays.gujju # Stack arrays & string operations ├── 06_modules.gujju # Modular imports ('lav') └── helper.gujju # Module target file ``` --- ## 🛠️ Getting Started & Installation TGL is pre-compiled as a standalone native Windows binary. You do **not** need WSL, Visual Studio, or a C++ compiler installed on your host system to run it. ### Prerequisites * Windows 10/11 system. ### Running scripts Clone the repository, open Command Prompt or PowerShell in the folder, and run: #### 1. The Pythonic way (`chalu kar`): ```cmd chalu kar examples\01_hello.gujju ``` #### 2. The Standard way (`gujju`): ```cmd gujju examples\01_hello.gujju ``` #### 3. Start the Interactive REPL: Simply execute `gujju` without args to spin up the interactive prompt: ```cmd gujju ``` Type `bahar` to exit the REPL shell. #### 4. Version and Help: ```cmd gujju --version gujju --help ``` --- ## 📝 Complete Keyword Reference | English Equivalent | Gujarati Keyword | Purpose | Example / Syntax | |:---|:---|:---|:---| | `print` | **`batav`** | Print to stdout | `batav("Kem chho!")` | | `input` | **`puch`** | Read input from stdin | `naam = puch("Naam: ")` | | `if` | **`jo`** | If block conditional | `jo age >= 18: { ... }` | | `else if` | **`anai_to_aa`** | Else-if block conditional | `anai_to_aa age >= 13: { ... }` | | `else` | **`naito`** | Else block fallback | `naito: { ... }` | | `while` | **`jyasudhi`** | While loop conditional | `jyasudhi i <= 5: { ... }` | | `for` | **`ferthi`** | Traditional C-like for loop | `ferthi i=0; i<5; i++: { ... }` | | `foreach` | **`darek`** | Iterate array/string | `darek item mathi list: { ... }` | | `in` | **`mathi`** | Used in foreach loops | `darek x mathi array: { ... }` | | `switch` | **`pasand`** | Switch block conditional | `pasand day: { ... }` | | `case` | **`kisso`** | Case value condition | `kisso 1: { ... }` | | `default` | **`baki_to`** | Default switch fallback | `baki_to: { ... }` | | `break` | **`ubhore`** | Terminate loop execution | `jo x == 5: ubhore` | | `continue` | **`chalurakho`** | Skip current loop cycle | `jo x % 2 != 0: chalurakho` | | `function` | **`kam`** | Declare function block | `kam greet(name): { ... }` | | `return` | **`pachhu_kar`** | Return function value | `pachhu_kar result` | | `true` | **`sachu`** | Boolean True constant | `student = sachu` | | `false` | **`khotu`** | Boolean False constant | `active = khotu` | | `null` | **`khali`** | Unassigned/empty literal | `x = khali` | | `import` | **`lav`** | Load external module file | `lav "helper.gujju"` | | `exit` | **`bahar`** | Exit the REPL prompt | `bahar` | --- ## 🧰 Complete Built-in Functions TGL includes **14 built-in standard library functions** mapped directly to Gujarati names: | Function | Output | Purpose | Example | |:---|:---|:---|:---| | **`batav(val)`** | `null` | Print value to console | `batav("Hello")` | | **`puch(prompt)`** | `string` | Read input from user | `name = puch("> ")` | | **`lambai(val)`** | `int` | Get size of string or array | `len = lambai(arr)` | | **`prakar(val)`** | `string` | Get type of value as string | `prakar(42) // "int"` | | **`ank(val)`** | `int` | Parse string/float to integer | `ank("100")` | | **`dashansh(val)`**| `float` | Parse string/int to float | `dashansh("3.14")` | | **`lakhan(val)`** | `string` | Convert any value to string | `lakhan(sachu) // "sachu"` | | **`push(arr, val)`**| `null` | Append value to end of array | `push(stack, 42)` | | **`pop(arr)`** | `any` | Remove and return last element | `val = pop(stack)` | | **`math_sqrt(val)`**| `float` | Square root of number | `math_sqrt(16)` | | **`math_sin(val)`** | `float` | Sine of radian angle | `math_sin(0)` | | **`math_cos(val)`** | `float` | Cosine of radian angle | `math_cos(0)` | | **`math_tan(val)`** | `float` | Tangent of radian angle | `math_tan(0)` | | **`math_pow(b, e)`**| `number` | Compute base raised to power | `math_pow(2, 8)` | --- ## 📖 Comprehensive Syntax Guide ### 1. Variables & Dynamic Scoping Variables are dynamically typed and declared automatically upon assignment: ```gujju umar = 19 height = 5.9 naam = "Yax Patel" student = sachu // Boolean (sachu/khotu) x = khali // Null literal ``` To output variables, query their type, or check values: ```gujju batav("Naam: " + naam) batav("Type: " + prakar(umar)) // Output: "int" ``` ### 2. Arithmetic, Relational & Logical Operators TGL supports standard expressions plus exponentiation (`**`): ```gujju a = 10 b = 3 // Mathematical operations add = a + b // 13 sub = a - b // 7 mul = a * b // 30 div = a / b // 3.33333 mod = a % b // 1 power = a ** b // 1000 // Compound assignments c = 100 c += 10 // c is now 110 c -= 5 // c is now 105 // Comparison & Logics jo a > b ane b > 0: { batav("Sachu chhe!") } ``` ### 3. Conditionals (`jo`, `anai_to_aa`, `naito`) You can chain conditions using `anai_to_aa` (else if) and `naito` (else). Parentheses are optional, and colons are supported: ```gujju score = 82 jo score >= 90: { batav("A Grade") } anai_to_aa score >= 80: { batav("B Grade") } naito: { batav("Fail") } ``` ### 4. Switch Case (`pasand`, `kisso`, `baki_to`) Evaluates matching integer/string/boolean expressions: ```gujju day = 2 pasand day: { kisso 1: { batav("Monday") } kisso 2: { batav("Tuesday") } baki_to: { batav("Other day") } } ``` ### 5. Loops (`jyasudhi`, `ferthi`, `darek ... mathi`) #### While loop (`jyasudhi`) ```gujju i = 1 jyasudhi i <= 3: { batav(lakhan(i)) i++ } ``` #### For loop (`ferthi`) ```gujju ferthi j = 0; j < 5; j++: { batav(lakhan(j)) } ``` #### Foreach loop (`darek`) Iterate through arrays or characters in a string: ```gujju names = ["Yax", "Dev", "Raj"] darek naam mathi names: { batav("Naam: " + naam) } word = "GUJJU" darek ch mathi word: { batav(ch) } ``` ### 6. Functions, Recursion & Closures (`kam`) Declare functions with the `kam` keyword and return values with `pachhu_kar`: ```gujju // Simple function kam add(a, b): { pachhu_kar a + b } // Recursive function kam factorial(n): { jo n <= 1: { pachhu_kar 1 } pachhu_kar n * factorial(n - 1) } // Lexical closure kam makeCounter(): { count = 0 kam increment(): { count = count + 1 pachhu_kar count } pachhu_kar increment } ``` ### 7. Dynamic Arrays Arrays store multiple types and support index assignments: ```gujju arr = [10, "Hello", sachu] batav(lakhan(arr[1])) // Output: Hello arr[0] = 99 // modify index push(arr, "new element") popped = pop(arr) ``` ### 8. Module imports (`lav`) Split code across files and load external modules: **helper.gujju** ```gujju kam greet(name): { batav("Kem Chho, " + name + "!") } const_val = 42 ``` **main.gujju** ```gujju lav "helper.gujju" kam mukhya(): { greet("Yax") batav(lakhan(const_val)) } ``` *Note: The module loader automatically prevents duplicate or circular imports.*