Add directive plugin for jsonic Go implementation#1
Merged
Conversation
Port of the TypeScript @jsonic/directive plugin to Go, following the pattern established by github.com/jsonicjs/ini/go. Includes: - directive.go: types (DirectiveOptions, Action, RuleMod, etc.) and Apply() helper - plugin.go: Directive plugin function with open/close token registration, grammar rule modification, and replacement chain resolution for Go slices - directive_test.go: tests covering happy path, close tokens, adder/multiplier directives, edge cases, and custom rule modifications https://claude.ai/code/session_01RiMHE2zSU49VFuFzWygBBF
- Replace Node 18/20/22 matrix with 24.x and latest - Add Go job that builds and tests the go/ directory - Update actions/checkout to v4, actions/setup-node to v4 https://claude.ai/code/session_01RiMHE2zSU49VFuFzWygBBF
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.
Summary
This PR introduces a new directive plugin for the jsonic Go library that enables custom syntax extensions through configurable open/close token sequences. Directives allow users to define custom parsing behaviors that transform parsed content.
Key Changes
New
directive.gomodule: Core directive implementation with:Actioncallback type for processing directive contentRuleModstruct for configuring grammar rule integrationRulesOptionfor specifying which rules detect open/close tokensDirectiveOptionsconfiguration structApply()helper function for easy plugin registrationNew
plugin.gomodule: MainDirective()plugin function that:CustomFunccallback for advanced rule customizationComprehensive test suite (
directive_test.go):Notable Implementation Details
dlist,dmap) controls implicit list/map creation within directive boundariesRulesOptionhttps://claude.ai/code/session_01RiMHE2zSU49VFuFzWygBBF