Conversation
Per YAML spec, anchor and alias names can contain colons and other special characters. Only terminate alias names at colon when followed by space/tab (key-value separator context). Also resolve aliases immediately in the lexer when the anchor exists, since deferred markers can be lost through Jsonic's rule processing for indented values. https://claude.ai/code/session_01H3rUS9E1u5eXZrzyYiBPB3
Parse %TAG directives during source cleanup and store handle→prefix mappings. When !! has been redefined by %TAG, skip built-in type conversion (!!int, !!float, etc.) and treat the value as a plain string. https://claude.ai/code/session_01H3rUS9E1u5eXZrzyYiBPB3
When a block scalar indicator (|2, >1) appears on a separate line from the mapping colon (e.g., after a standalone tag like !foo), look backward to find the parent mapping key's indent for correct blockIndent calculation. Also consume trailing newline after standalone local tags to prevent extra #IN tokens. https://claude.ai/code/session_01H3rUS9E1u5eXZrzyYiBPB3
When a continuation line starts with "- ", check whether its indent matches the nearest enclosing sequence marker's indent. Only treat it as a new sequence entry at the matching indent level — at other indents, it's plain scalar text continuation. https://claude.ai/code/session_01H3rUS9E1u5eXZrzyYiBPB3
The explicit key handler set pnt.cI = 1 after processing ": value", causing incorrect column info for the element marker. This broke multi-entry sequences as values of explicit keys. Fix by computing the actual column position on the value line. https://claude.ai/code/session_01H3rUS9E1u5eXZrzyYiBPB3
…, JTV5) - Handle block scalar indicators (| and >) as explicit key content, parsing indented continuation lines as literal/folded block scalar text - Fix keyIndent calculation in text.check to use current line indent (colon's line) instead of previous line indent for map value continuation https://claude.ai/code/session_01H3rUS9E1u5eXZrzyYiBPB3
…KB6, 9BXH, CT4Q, K3WX)
Add flow collection preprocessor to handle YAML-specific features that
Jsonic's core parser doesn't natively support:
- Implicit null-valued keys in flow mappings: {a, b: c} → {a: ~, b: c}
- Comments between key and colon in flow context
- Multiline quoted scalars in flow collections
- Explicit keys (?) inside flow sequences
All 374 YAML Test Suite tests now pass with 0 skipped.
https://claude.ai/code/session_01H3rUS9E1u5eXZrzyYiBPB3
Implements a Go version of the @jsonic.dev/yaml parser as a Jsonic plugin, following the same architecture as the CSV Go plugin. Includes: - yaml.go: Public API (Parse, MakeJsonic), helper functions, YAML value maps - plugin.go: Yaml plugin with custom matcher, TextCheck for block scalars/ tags/plain scalars, anchor/alias handling, quoted strings, indentation - grammar.go: YAML-specific grammar rules for block mappings, sequences, indent-based nesting, element markers, merge keys - yaml_test.go: 93 tests covering block mappings, sequences, scalar types, quoted strings, block scalars, flow collections, comments, anchors/aliases, merge keys, documents, tags, complex keys, directives, indentation, multiline scalars, CRLF, and real-world patterns https://claude.ai/code/session_01H3rUS9E1u5eXZrzyYiBPB3
Runs build and test on ubuntu, windows, and macos for both the TypeScript (Node 24) and Go (1.24) implementations. https://claude.ai/code/session_01H3rUS9E1u5eXZrzyYiBPB3
On Windows, readFileSync returns \r\n line endings which cause the YAML parser to fail on certain inputs (e.g. LE5A with trailing empty lines after !!str). Normalize to \n when reading in.yaml test files. https://claude.ai/code/session_01H3rUS9E1u5eXZrzyYiBPB3
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 significantly improves YAML parsing capabilities by adding comprehensive flow collection preprocessing and proper TAG directive handling. The changes enable the parser to handle YAML-specific features that Jsonic's core parser doesn't natively support, while also fixing edge cases in block scalar and multiline key handling.
Key Changes
Flow Collection Preprocessing
preprocessFlowCollections()function to transform flow collection syntax into Jsonic-compatible format before parsing{a, b: c}→{a: ~, b: c}?) inside flow collections[? key : val]syntax to[{key: val}]for proper parsingTAG Directive Support
tagHandlesmap to track%TAGdirective mappings!!is redefined by a custom TAG directiveBlock Scalar Key Handling
|and>) in explicit keys+,-) and explicit indentationAlias Resolution Improvements
Tag Processing Enhancements
Sequence Marker Detection
-) detection to only treat as new entry when indent matches enclosing sequence levelPosition Tracking Fixes
Test Suite Updates
https://claude.ai/code/session_01H3rUS9E1u5eXZrzyYiBPB3