# Floating-point numbers let pi = 3.14159 let percent = 85%
# Strings let str1 = "Double-quoted string,\nwith escape support" let str2 = 'Single-quoted raw string,\nno escape' let template = `Template string $var${var + 1}`
# Booleans let flag = True let disabled = False
# Null values let empty = None
# File sizes let a = 3000K
Collection Types
# Lists (List) let arr = [1, 2, 3, "mixed", True] let nested = [[1, 2], [3, 4]]
# Hash Map (HMap) - Unordered, fast lookup # let hmap = H{name: "Alice", age: 25}
# Ordered Map (Map) - Ordered, supports range queries let map = {a: 1, b: 2, c: 3}
# Ranges (Range) let range1 = 1..10 # 1 to 9 (excluding 10) let range2 = 1..=10 # 1 to 10 (including 10) let range3 = 1..10:2 # 1, 3, 5, 7, 9 (step of 2)
let array = 1...10 # Create an array directly from the range
Variables and Assignment
Basic Assignment
# Variable declaration and assignment let x = 10 let name = "Lumesh"
# Multiple variable assignment let a, b, c = 1, 2, 3 let x, y = getValue()
Delayed Assignment
Lumesh’s unique delayed assignment feature:
# Use := for delayed assignment; the expression will not execute immediately let cmd := ls -l /tmp let calculation := 2 + 3 * 4
# Execute only when needed eval(cmd) # Executes ls -l /tmp eval(calculation) # Calculates to 14
# If it's a command, it can also be executed directly cmd
Destructuring Assignment
Supports destructuring assignment for arrays and maps:
# Array destructuring let [first, second, *rest] = [1, 2, 3, 4, 5] # first = 1, second = 2, rest = [3, 4, 5]
# Map destructuring let {name, age} = {name: "Bob", age: 30, city: "NYC"} # name = "Bob", age = 30
# Renaming destructuring let {name: username, age: userAge} = user_data
Operators
Arithmetic Operators
let a = 10 + 5 # Addition: 15 let b = 10 - 3 # Subtraction: 7 let c = 4 * 6 # Multiplication: 24 let d = 15 / 3 # Division: 5 let e = 17 % 5 # Modulus: 2 let f = 2 ^ 3 # Exponentiation: 8
Comparison Operators
# Basic comparisons a == b # Equal a != b # Not equal a > b # Greater than a < b # Less than a >= b # Greater than or equal a <= b # Less than or equal
# Pattern matching text ~= "pattern"# Regex match text ~: "substring"# Contains match text !~= "pattern"# Regex not match text !~: "substring"# Does not contain match
Logical Operators
condition1 && condition2 # Logical AND condition1 || condition2 # Logical OR !condition # Logical NOT
Pipeline Operations
Lumesh provides various types of pipelines, which is its unique feature:
# Standard pipeline - Pass standard output or structured data cmd1 | cmd2
# String interpolation let name = "World" let age = 18 let greeting = `Hello, ${age > 18 ? "Mr." : "Dear"}$name!`
# Multi-line string let multiline = " This is a multi-line string "
# Raw string (no escape) let raw = 'C:\path\to\file'
Collection Operations
# List operations let numbers = [1, 2, 3, 4, 5] numbers.append(6) # Add element numbers + 6 # Add element # numbers.pop() # Remove last element numbers - 4 # Remove specified element numbers.len() # Get length
# Map operations let person = {name: "Bob", age: 30} # person.city = "NYC" # Add property person + {city: "NYC"} # Add property # del person.age # Delete property person.keys() # Get all keys
The design philosophy of Lumesh is to combine the elegant syntax of modern programming languages with the practicality of shell scripting, providing powerful error handling, pipeline operations, and a module system. The priority system implemented through the Pratt parser ensures the correct parsing of complex expressions, while the rich built-in modules and configuration options make it suitable for various scenarios, from simple command-line operations to complex system management scripts.