Skip to content

Replace CSV plugin with ZON (Zig Object Notation) parser#1

Merged
rjrodger merged 1 commit into
mainfrom
claude/add-zig-zon-parsing-LktCp
Apr 18, 2026
Merged

Replace CSV plugin with ZON (Zig Object Notation) parser#1
rjrodger merged 1 commit into
mainfrom
claude/add-zig-zon-parsing-LktCp

Conversation

@rjrodger
Copy link
Copy Markdown
Contributor

Converts this jsonic plugin from parsing CSV to parsing Zig Object
Notation (ZON), the format used by build.zig.zon and similar Zig
configuration files. The package is renamed @jsonic/csv to @jsonic/zon,
and the Go module path becomes github.com/jsonicjs/zon/go.

Key design points:

  • .{ is disambiguated at lex time into #OB (struct/map) or #OS
    (tuple/list) by peeking ahead for .ident =, so a single two-token
    grammar lookahead is sufficient and } (lexed as #CB) closes both
    struct and tuple literals.
  • A custom lex matcher emits .identifier as a #TX token whose val is
    the identifier (sans dot) and whose use flag marks it as an enum
    literal for optional wrapping via the enumTag option.
  • Zig multi-line strings (\\-prefixed consecutive lines) and Zig
    character literals (including \x.., \u{...}) have dedicated
    matchers; the charAsNumber option returns character literals as
    code points instead of one-char strings.
  • The grammar text embedded into both the TS and Go sources only
    prepends ZON-specific alts to the base json rules and swaps the list
    terminator from #CS to #CB; rule.exclude: 'jsonic,imp' strips the
    implicit-top-level behaviours that are not valid ZON.

Both TypeScript (19 tests) and Go (20 tests) test suites pass. Pinned
to jsonic@2.24.0 (npm) and github.com/jsonicjs/jsonic/go@v0.1.18.

https://claude.ai/code/session_01TLYwCQbxYQNqzzZstKtRCx

Converts this jsonic plugin from parsing CSV to parsing Zig Object
Notation (ZON), the format used by build.zig.zon and similar Zig
configuration files. The package is renamed @jsonic/csv to @jsonic/zon,
and the Go module path becomes github.com/jsonicjs/zon/go.

Key design points:

- `.{` is disambiguated at lex time into #OB (struct/map) or #OS
  (tuple/list) by peeking ahead for `.ident =`, so a single two-token
  grammar lookahead is sufficient and `}` (lexed as #CB) closes both
  struct and tuple literals.
- A custom lex matcher emits `.identifier` as a #TX token whose val is
  the identifier (sans dot) and whose use flag marks it as an enum
  literal for optional wrapping via the `enumTag` option.
- Zig multi-line strings (`\\`-prefixed consecutive lines) and Zig
  character literals (including `\x..`, `\u{...}`) have dedicated
  matchers; the `charAsNumber` option returns character literals as
  code points instead of one-char strings.
- The grammar text embedded into both the TS and Go sources only
  prepends ZON-specific alts to the base json rules and swaps the list
  terminator from #CS to #CB; `rule.exclude: 'jsonic,imp'` strips the
  implicit-top-level behaviours that are not valid ZON.

Both TypeScript (19 tests) and Go (20 tests) test suites pass. Pinned
to jsonic@2.24.0 (npm) and github.com/jsonicjs/jsonic/go@v0.1.18.

https://claude.ai/code/session_01TLYwCQbxYQNqzzZstKtRCx
@rjrodger rjrodger merged commit 865dccc into main Apr 18, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants