Logo Lanfrica

nooher/snil-core

Domaine:

natural language processing

Type de record:

software
Créateur:
noo
Hôte:
@laetoli/snil — embeddable engine for SNIL, the sovereign Kiswahili programming language. # @laetoli/snil **Embeddable engine for SNIL — the sovereign Kiswahili programming language.** Zero-dependency, offline, deterministic. Drop it into any JS/TS app to **tokenize, parse, run**, or **compile** SNIL source to **Python** or **JavaScript**. > SNIL — *Swahili Native Intent Language* — is a real programming language whose > keywords are Kiswahili (`onyesha`, `weka … kuwa`, `kama`, `kwa`, `kazi`, `leta`). > This package is the pure language engine — no UI, no network, no API keys. > Lugha ya programu yenye mizizi ya Kiswahili, inayotekelezwa ndani ya app yako. --- ## Install / Sakinisha ```bash npm install github:nooher/snil-core ``` (Published as `@laetoli/snil`; `dist/` is committed so `github:` installs need no build step.) ## Use / Tumia ```ts import { run, toPython, toJS } from '@laetoli/snil'; const r = run('onyesha "Habari, dunia!"'); // r.output === "Habari, dunia!" r.error === null toPython('weka x kuwa 5\nonyesha x'); // → Python source toJS('onyesha 1 + 2'); // → JavaScript source ``` `run` **never throws** — errors come back in Kiswahili inside `r.error`: ```ts const r = run('onyesha y'); // y haijatangazwa if (r.error) console.log(r.error.message); // ujumbe wa kosa kwa Kiswahili ``` ## API | Function | Signature | Description | |---|---|---| | `run` | `run(source, io?) → RunResult` | Tekeleza chanzo. Captures `onyesha` output; never throws. | | `parse` | `parse(source) → Program` | Source → AST (tokenize + parse). Throws `SnilError` on lexical/syntax errors. | | `tokenize` | `tokenize(source) → Token[]` | Source → token stream. | | `toPython` | `toPython(source, somaModuli?) → string` | Compile to Python. Throws `SnilError` on syntax errors. | | `toJS` | `toJS(source, somaModuli?) → string` | Compile to JavaScript (ES2020, runnable via `node`). | ### `SnilIO` — the I/O contract `run`'s second argument lets you wire SNIL up to the host. All fields optional: ```ts interface SnilIO { andika?: (text: string) = …