@tabnas/zon
v0.2.0
Published
This plugin allows the [Tabnas](https://github.com/tabnas/parser) JSON parser to support Zig Object Notation (ZON) syntax.
Maintainers
Readme
@tabnas/zon
A Tabnas grammar plugin that parses
Zig Object Notation (ZON)
text into objects, arrays, and scalar values. ZON is the anonymous-struct
data format used for Zig build.zig.zon manifests.
Install
npm install @tabnas/parser @tabnas/jsonic @tabnas/zonRequires @tabnas/parser >= 2 and @tabnas/jsonic >= 2 as peer
dependencies.
One example
The plugin layers onto a Tabnas engine that already has the jsonic grammar:
import { Tabnas } from '@tabnas/parser'
import { jsonic } from '@tabnas/jsonic'
import { Zon } from '@tabnas/zon'
const j = new Tabnas().use(jsonic).use(Zon)
j.parse('.{ .name = "Alice", .age = 30 }') // => { name: 'Alice', age: 30 }
j.parse('.{ 1, 2, 3 }') // => [1, 2, 3]Build the instance once and reuse it — constructing the grammar is the expensive part.
Documentation
Full documentation follows the Diátaxis framework:
- Tutorial — a guided first parse, start to finish.
- How-to guide — short recipes for individual tasks.
- Reference — the public API, every option, and the complete ZON syntax accepted.
- Concepts — how the plugin reshapes the engine, and why.
For the Go port, see ../go/README.md.
Grammar diagram
The grammar is defined in the top-level
zon-grammar.jsonic and embedded into this
implementation (and the Go port) by embed-grammar.js
during the build.
The installed grammar as a railroad/syntax diagram, generated with
@tabnas/railroad:
A vertical ASCII version is in doc/grammar.txt.
License
Copyright (c) 2025 Richard Rodger and other contributors, MIT License.
