Expand description
A wasm32-unknown-unknown wrapper exposing the [elly] parse + eval
pipeline to JavaScript.
The elly and muon crates are no_std; this thin shim links std only
for the allocator that wasm32-unknown-unknown provides, so no
wasm-bindgen (or any post-processing tool) is needed — the .wasm is
loaded directly.
§ABI
Strings cross the boundary as (ptr, len) into wasm linear memory:
elly_alloc(len) -> ptr— reservelenbytes for JS to write UTF-8 into.elly_run(ptr, len) -> out— parse and evaluate those bytes; returns a pointer to a length-prefixed result: a little-endianu32byte length followed by that many bytes of UTF-8 JSON (see below).elly_free(ptr, len)— release a block obtained fromelly_alloc.
The JSON result is one of:
{"ast":<expr>,"value":"<display>"}— parsed and evaluated.<expr>is the tagged AST dump (elly::Expr::to_json).{"ast":<expr>,"error":{"stage":"eval","raised":"<display>"}}— parsed, but evaluation raised a value that unwound to the top level (an explicit__Err_raiseor a host failure like.div_by_zero); the AST is still shown.{"error":{"stage":"parse","kind":"…"}}— a valid Muon tree but not a valid Elly program in this subset.{"error":{"stage":"syntax","offset":N,"kind":"…"}}— the syntax layer (Muon) rejected the input.
Functions§
- elly_
alloc - Reserve
lenbytes of linear memory and hand ownership to the caller. - elly_
free ⚠ - Release a block previously returned by
elly_alloc(samelen). - elly_
run ⚠ - Run
lenUTF-8 bytes atptrthrough the pipeline; return length-prefixed JSON.