Something went wrong. Try again.
A general purpose .. programming language written in zig ijadux2.tngl.sh/Rinnescript
zig language
Something went wrong. Try again.
9.9 kB · 136 lines
HTML
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>API Reference · RinneScript</title><link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;800&family=JetBrains+Mono:wght@400&display=swap" rel="stylesheet"><link rel="stylesheet" href="assets/styles.css"><script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.30.0/components/prism-core.min.js" defer></script><script src="assets/prism-lang.js" defer></script><script src="assets/main.js" defer></script></head><body><nav class="nav"> <a class="brand" href="./index.html">RinneScript</a> <div class="nlinks"> <a class="nl" href="./index.html">Home</a> <a class="nl" href="./api.html">API</a> <a class="nl on" href="./docs.html">Docs</a> <a class="nl" href="./examples.html">Examples</a> </div></nav><main class="wrap"><div class="apigroups">
<div class="ghead" id="g-core"><span class="dot" style="background:var(--blue)"></span><h2>Core I/O & values</h2></div><table><tr><th>Call</th><th class="desc">Description</th></tr><tr><td><code>@stdout(fmt, .{})</code> / <code>@stderr</code> / <code>@log</code></td><td class="desc">Format output; only <code>{}</code> placeholders, exact count match required.</td></tr><tr><td><code>std.print(fmt, .{})</code></td><td class="desc">Namespaced spelling of @stdout (requires std import).</td></tr><tr><td><code>print(x)</code> / <code>println(x)</code></td><td class="desc">(selfhost bridge) host-side print used inside interpreted programs.</td></tr><tr><td><code>len(v)</code></td><td class="desc">Length of str / array / map entries.</td></tr><tr><td><code>int(v)</code> · <code>float(v)</code> · <code>str(v)</code></td><td class="desc">Conversions; int truncates toward zero.</td></tr><tr><td><code>@as(type, v)</code></td><td class="desc">Cast with alias table: i32/i64/u8/u32/u64/usize→int, f32/f64→float, string→str, bool→truthy. Unknown type = compile error.</td></tr><tr><td><code>env("KEY")</code> · <code>clock()</code></td><td class="desc">Environment lookup ("" if unset); seconds since VM start.</td></tr><tr><td><code>read_file(p)</code> / <code>write_file(p,d)</code> / <code>file_exists(p)</code></td><td class="desc">Filesystem (Io-backed).</td></tr><tr><td><code>args()</code></td><td class="desc">CLI argument vector as array of strings.</td></tr><tr><td><code>@vector(n,t)</code> / <code>@splat(n,v)</code> / <code>@reduce(op,xs)</code></td><td class="desc">Vector intrinsics (interpreted scalar fallback; op ∈ add/mul/min/max).</td></tr><tr><td><code>select(cond,a,b)</code></td><td class="desc">Branch-free select.</td></tr></table>
<div class="ghead" id="g-str"><span class="dot" style="background:var(--green)"></span><h2>Strings</h2></div><table><tr><th>Call</th><th class="desc">Description</th></tr><tr><td><code>split(s, sep)</code> / <code>join(arr, sep)</code></td><td class="desc">Split into array / join array of strings.</td></tr><tr><td><code>trim(s)</code></td><td class="desc">Strip surrounding whitespace.</td></tr><tr><td><code>replace(s, old, new)</code></td><td class="desc">Replace all occurrences.</td></tr><tr><td><code>contains(hay, needle)</code></td><td class="desc">Substring test → bool.</td></tr><tr><td><code>starts_with(s,p)</code> / <code>ends_with(s,suf)</code></td><td class="desc">Prefix/suffix tests.</td></tr><tr><td><code>to_lower(s)</code> / <code>to_upper(s)</code></td><td class="desc">ASCII case conversion.</td></tr><tr><td><code>slice(v, a, b)</code></td><td class="desc">Slice str or array, end-exclusive; negatives from end.</td></tr></table>
<div class="ghead" id="g-coll"><span class="dot" style="background:var(--yellow)"></span><h2>Arrays & maps</h2></div><table><tr><th>Call</th><th class="desc">Description</th></tr><tr><td><code>push(arr, v)</code></td><td class="desc">Returns a NEW array with v appended (functional growth).</td></tr><tr><td><code>.{ k = v }</code></td><td class="desc">Map literal (string keys). Empty <code>.{}</code> is the format tuple — use <code>map_new()</code>.</td></tr><tr><td><code>m["key"]</code> / <code>m["key"] = v</code></td><td class="desc">Get (missing → null) / set by string key.</td></tr><tr><td><code>m.keys()</code> / <code>m.values()</code></td><td class="desc">Iterate contents (order unspecified).</td></tr><tr><td><code>m.has(k)</code> / <code>m.remove(k)</code></td><td class="desc">Membership / delete.</td></tr><tr><td><code>map_new()</code></td><td class="desc">Fresh empty map.</td></tr></table>
<div class="ghead" id="g-data"><span class="dot" style="background:var(--peach)"></span><h2>JSON & CSV</h2></div><table><tr><th>Call</th><th class="desc">Description</th></tr><tr><td><code>json_parse(text)</code></td><td class="desc">Objects→maps, arrays→arrays; invalid input is a runtime error.</td></tr><tr><td><code>json_stringify(v)</code></td><td class="desc">Maps/arrays/scalars to JSON text (key order unspecified).</td></tr><tr><td><code>csv_parse(text)</code></td><td class="desc">RFC4180-ish: quotes, "" escapes, embedded commas/newlines, CRLF.</td></tr><tr><td><code>csv_format(rows)</code></td><td class="desc">Render rows; quotes cells containing , " or newlines.</td></tr></table>
<div class="ghead" id="g-x"><span class="dot" style="background:var(--red)"></span><h2>Crypto & assertions</h2></div><table><tr><th>Call</th><th class="desc">Description</th></tr><tr><td><code>sha256(s)</code></td><td class="desc">64-char lowercase hex digest.</td></tr><tr><td><code>base64_encode(s)</code> / <code>base64_decode(s)</code></td><td class="desc">Standard alphabet; invalid input rejected.</td></tr><tr><td><code>assert(cond)</code> / <code>assert_eq(a,b)</code></td><td class="desc">Runtime checks; assert_eq prints both values on failure.</td></tr><tr><td><code>panic(msg)</code></td><td class="desc">Raise a catchable runtime error carrying msg.</td></tr><tr><td><code>try(fn_call())</code></td><td class="desc">Run one call guarded → <code>[ok, result_or_message]</code>; nested try works.</td></tr><tr><td><code>log_write(level, msg)</code></td><td class="desc">Structured stderr line "[INFO] msg"; level int 0..4 or custom tag.</td></tr></table>
<h2 class="sec">tensor <span class="badge b-ai">@tensor core</span></h2><table><tr><th>Form</th><th class="desc">Description</th></tr><tr><td><code>@tensor(dtype, [shape], .{.device=.cpu, .fill=v})</code></td><td class="desc">Contiguous row-major tensor; cuda/rocm degrade with clear error in v1.</td></tr><tr><td><code>t[i]</code> / <code>t[i] = v</code></td><td class="desc">Linear indexing; out-of-bounds is a runtime error.</td></tr><tr><td><code>t.shape() t.numel() t.dtype() t.data() t.fill(v) t.deinit()</code></td><td class="desc">Methods; deinit idempotent, later use rejected. defer cannot capture locals — call explicitly.</td></tr><tr><td><code>t.apply_simd(fn(x: @vector(N,T)) T { ... })</code></td><td class="desc">Element-wise kernel, runs in place; lane width is a hint.</td></tr></table>
<h2 class="sec">ai <span class="badge b-ai">zero-copy readers</span></h2><table><tr><th>Call</th><th class="desc">Description</th></tr><tr><td><code>load_safetensors(path)</code></td><td class="desc">Array of named read-only tensor views over mmap. F32/F64/I32/I64.</td></tr><tr><td><code>load_gguf(path)</code></td><td class="desc">GGUF v2/v3; ggml NE dims reversed to row-major; F32/I32/I64/F64 dtypes.</td></tr></table>
<h2 class="sec">llm <span class="badge b-ai">transformer</span></h2><table><tr><th>Call</th><th class="desc">Description</th></tr><tr><td><code>llm_load(path)</code></td><td class="desc">GGUF model using the rinne.llm.* metadata convention (see docs/libs/llm.md).</td></tr><tr><td><code>m.forward(.{ids...})</code></td><td class="desc">Last-token logits over F32 weights (RMSNorm·RoPE·GQA·SwiGLU).</td></tr><tr><td><code>m.deinit()</code></td><td class="desc">Idempotent close; later use rejected.</td></tr></table>
<h2 class="sec">net <span class="badge b-net">tcp</span></h2><table><tr><th>Call</th><th class="desc">Description</th></tr><tr><td><code>tcp_listen(port)</code></td><td class="desc">Listener on 0.0.0.0; port 0 = ephemeral, discover via <code>l.port()</code>.</td></tr><tr><td><code>tcp_connect(host, port)</code></td><td class="desc">Stream to remote host.</td></tr><tr><td><code>l.accept()</code> / <code>l.port()</code> / <code>l.close()</code></td><td class="desc">Accept one stream; bound port; close listener.</td></tr><tr><td><code>s.read(max)</code> / <code>s.write(str)</code></td><td class="desc">Up-to-max bytes (returns early at EOF); write flushes before returning.</td></tr><tr><td><code>s.shutdown(how)</code></td><td class="desc">Half-close: send|recv|both (default send) — frame messages on blocking platforms.</td></tr><tr><td><code>s.close()</code></td><td class="desc">Close stream.</td></tr></table>
<h2 class="sec">c <span class="badge b-c">dlopen FFI</span></h2><table><tr><th>Call</th><th class="desc">Description</th></tr><tr><td><code>load_lib(name)</code></td><td class="desc">Open shared library; sonames resolve via the system loader ("libc.so.6").</td></tr><tr><td><code>lib.call_int(sym, .{args≤4})</code></td><td class="desc">Call C function returning i64.</td></tr><tr><td><code>lib.call_float(sym, .{args≤4})</code></td><td class="desc">Call C function returning f64 (note: fabs lives in libm).</td></tr><tr><td><code>lib.deinit()</code></td><td class="desc">dlclose; idempotent.</td></tr></table>
</div></main><footer><div class="wrap">RinneScript — write scripts, ship native binaries. Hand-built site, vanilla JS only.</div></footer></body></html>