Replace CSV plugin with ZON (Zig Object Notation) parser#1
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-tokengrammar lookahead is sufficient and
}(lexed as #CB) closes bothstruct and tuple literals.
.identifieras a #TX token whose val isthe identifier (sans dot) and whose use flag marks it as an enum
literal for optional wrapping via the
enumTagoption.\\-prefixed consecutive lines) and Zigcharacter literals (including
\x..,\u{...}) have dedicatedmatchers; the
charAsNumberoption returns character literals ascode points instead of one-char strings.
prepends ZON-specific alts to the base json rules and swaps the list
terminator from #CS to #CB;
rule.exclude: 'jsonic,imp'strips theimplicit-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