RaggieScript v1.3.0
Browse Table of Contents (17 chapters)
Getting Started (2)
Language Reference (4)
Core Standard Library (3)
Windows, MSI SQL & Native FFI (3)
Wizard UI & Studio Sandboxes (3)
Diagnostics & Bytecode ISA (2)
Master Symbol Index
4 min read Module: raggiesoft.raggiescript F1: IDH_RSSC_SYNTAX (0x2003)

Lexical Grammar, Preprocessor & Expressions

RaggieScript uses UTF-8 source files (.rssc) with C# / TypeScript-style curly-brace blocks, ;-terminated statements, // line comments, and /* ... */ block comments.

Compile-Time Preprocessor & include

Before tokenization, RaggieScript resolves compile-time conditionals and modular .rssc includes:

DirectiveExampleBehavior
#define KEY VALUE#define EDITION "Architect"Defines a compile-time macro constant readable via def("KEY") or #ifdef.
#ifdef KEY / #ifndef KEY#ifndef BOOK_SLUGIncludes block when KEY was (or was not) passed via -DKEY=VAL or #define.
#if / #elif / #else / #endif#if TARGET_ARCH == "arm64"Conditional compilation supporting ==, !=, defined(KEY), &&, and ||.
include "rel/path.rssc";include "../includes/common.rssc";Splices reusable helper functions, structs, and enums with cycle protection.
#ifndef RELEASE_RING
#define RELEASE_RING "stable"
#endif

include "shared-enterprise-checks.rssc";
const activeRing = def("RELEASE_RING", "stable");

Literals (string, Raw r"...", Single '...', SemVer v"...")

1. Interpolated Double-Quoted Strings ("...")

Double-quoted strings expand ${expr} expressions automatically (calling str(expr) on any inner expression) and support \n, \r, \t, \\, \", and \$ escapes:

const summary = "Installing ${product.name} on ${sys.arch()} (Build ${sys.osBuild()})";

2. Single-Quoted Non-Interpolated Strings ('...')

Single-quoted strings do not expand ${...} and can be nested cleanly inside "${...}" interpolations without escaping double quotes:

log("Manufacturer: ${msi.getProperty(dbFile, 'Manufacturer')}");

3. Raw Windows Path & Registry Strings (r"...")

Prefixing a string with r disables backslash escape processing—ideal for Windows Registry keys, UNC shares, and regular expressions:

const uninstallKey = r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";

4. First-Class Semantic Version Literals (v"..." & Bare 3-Part Versions)

Version literals parse into 4-part Major.Minor.Build.Revision 64-bit tuples so relational comparisons (<, <=, >, >=, ==, !=) never suffer lexicographical "10.0.9" > "10.0.22000" string bugs:

const minWin11: version = v"10.0.22000.0";
if (sys.osVersion() >= minWin11) {
    log.info("Windows 11 or newer verified.");
}

5. Numbers, Booleans, Arrays & Maps

Operators & Precedence (Highest to Lowest)

PrecedenceOperatorsDescription
1 (Postfix)obj.prop, obj?.prop, arr[i], arr?.[i], fn(a, name: b)Member access, v1.3 null-safe optional chaining (?. / ?.[), indexing, & calls
2 (Unary)!x, -x, ref varNameLogical NOT, numeric negation, two-way mutable ref binding
3 (Multiplicative)*, / (Path Join or Divide), %When either operand is path, a / b joins path segments cleanly!
4 (Additive)+, -Numeric add/subtract, string concatenation, or array + array merge
5 (Relational)<, <=, >, >=Numeric or 4-part version (SemVer) comparison
6 (Equality)==, !=Deep structural value equality
7 (Logical)&&, ||Short-circuit boolean AND / OR
8 (Coalesce)lhs ?? rhsEvaluates to rhs when lhs is null or empty ""; otherwise lhs
9 (Conditional)cond ? whenTrue : whenFalseTernary conditional expression
10 (Assignment)=, +=, -=, *=, /=Mutable let / param assignment (const rejected by RSW713)

Control-Flow Statements

// 1. if / elif / else
if (sys.isArm64()) {
    log.info("ARM64 silicon");
} elif (sys.isX64()) {
    log.info("x64 silicon");
} else {
    exit(EXIT_UNSUPPORTED_OS);
}

// 2. for-in over arrays or (key, value) over maps
for (item in ["Core", "Docs"]) {
    log.info(item);
}
for (k, v in { channel: "stable", ring: "1" }) {
    log.info("${k}=${v}");
}

// 3. while & repeat-until loops (with break; and continue;)
let attempts = 0;
repeat {
    attempts += 1;
} until (attempts >= 3);

// 4. Structured exception handling & setup exit codes
try {
    assert(sys.freeDiskMB(installDir) >= 100, "At least 100 MB free space is required.");
} catch (err: string) {
    ui.error("Pre-Flight Check Failed", err);
    exit(1603);
}

// 5. v1.3 LIFO Scope-Exit Cleanup ('defer { ... }') & Optional Chaining ('?.')
fn inspectEndpoint(cfg: any) : int {
    defer { log.info("Finished inspecting endpoint configuration."); }
    return cfg?.network?.port ?? 8443;
}

// 6. v1.3 First-Class Unit Test Blocks ('raggiescript.exe test <file_or_dir> [--json]')
test "Optional chaining falls back to port 8443 when config is null" {
    assert(inspectEndpoint(null) == 8443, "Expected fallback port 8443");
}
Indexed API Calls & Symbols on This Page (3):