Claude/update jsonic library 1s txf#8
Conversation
Enables callers to use Exclude('yaml') (Go) / rule.exclude (TS) to
remove YAML-specific alternates when needed.
https://claude.ai/code/session_01SiXBTMzEYfyzgQg12Jg2K6
Mirrors the jsonicjs/ini pattern: the grammar spec (rule open/close alts) lives in yaml-grammar.jsonic at the repo root and is embedded verbatim into src/yaml.ts and go/grammar.go between BEGIN/END markers. Run 'node embed-grammar.js' (or 'npm run embed') to re-sync after edits. - Alt conditions/actions become @funcref strings resolved via a refs map defined in the plugin (so closures can capture per-parse state). - State handlers (bo/ao/bc/ac) stay in code — they need closure access to anchors/pendingAnchors and aren't straightforwardly declarative. - Added a guard (Decoration in Go, __yamlInstalled in TS) against re-entry during options()/SetOptions() plugin re-application, which otherwise double-installs grammar rules and BC handlers. https://claude.ai/code/session_01SiXBTMzEYfyzgQg12Jg2K6
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8815fdfc52
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if ((jsonic as any).__yamlInstalled) return | ||
| ;(jsonic as any).__yamlInstalled = true |
There was a problem hiding this comment.
Remove permanent install guard from TS YAML plugin
This __yamlInstalled short-circuit turns the plugin into a one-shot initializer, so any later jsonic.options(...) call that triggers plugin re-application will skip YAML setup entirely. In flows that adjust options after use(Yaml), the YAML lexer/rule customizations from this plugin are no longer reasserted and parsing can regress to base Jsonic behavior. A re-entry guard should only suppress recursive re-entry during the current install, not permanently disable future re-applies.
Useful? React with 👍 / 👎.
| if j.Decoration("yaml-installed") == true { | ||
| return nil | ||
| } | ||
| j.Decorate("yaml-installed", true) |
There was a problem hiding this comment.
Avoid permanently skipping Go plugin re-application
Using a persistent decoration flag here makes subsequent SetOptions-driven plugin re-application a no-op, even though this plugin later mutates lexer/config state (FixedTokens, checks, matcher wiring) that may need to be re-applied after config rebuilds. In applications that call SetOptions after installing YAML, this can leave the parser without YAML-specific behavior and produce incorrect parses.
Useful? React with 👍 / 👎.
No description provided.