Skip to content

About

TypeScript runtime for the asciiunits PARG artifact — parse UnitsML AsciiUnits expressions in Node/browsers

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

asciiunits-ts

TypeScript runtime for the asciiunits PARG artifact (unitsml/asciiunits): parse UnitsML AsciiUnits unit expressions (mm*s^-2, sqrt(Hz), dB, …) in Node and browsers.

Status: complete — the artifact loads through the parsanol npm runtime (checksum-verified), and the conformance corpus replays 143/143 with tree equality (npm run replay).

Contract

  • artifacts/unitsml.json — the checksummed parsanol-tree/v2 artifact (vendored from unitsml/asciiunits releases; CI pins the checksum)

  • entry point: expression (terminal tables are embedded in the artifact)

  • captures: unit, prefix, dimension, integer, power_numerator, extender, sqrt, int_exp, sequence, first_set/second_set …

Conformance gate: replay asciiunits-testsuite (143 oracle-frozen cases) — kinds and tree shapes must match the Ruby runtime.

Typed model

parseModel(input) returns the generated LutaML Document for an expression, or null when the input is rejected. The classes and JSON codecs in src/generated are generated by lutaml-ts from model/asciiunits.bundle.json, the same LML bundle that asciiunits-rs uses. toPortableJson(model) writes the model’s declared JSON, with slice integers as decimal strings. parse and parseShape are unchanged.

model/codegen-provenance.json records the lutaml-ts revision, the bundle checksum and the checksum of every generated file. To regenerate, check out lutaml-ts at that revision and run node scripts/generate-models.mjs <lutaml-ts checkout>. CI does the same and fails if the output differs from the committed files.

npm test replays the pinned corpus through the model when CORPUS_DIR points at asciiunits-testsuite/corpora/unitsml: every accepted case writes the recorded tree and reads back to an equal model, and every rejected case returns null.

Development

npm install
npm run build
npm test
npm run replay   # corpus replay (needs the testsuite checkout)

About

TypeScript runtime for the asciiunits PARG artifact — parse UnitsML AsciiUnits expressions in Node/browsers

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages