Add support for flow map syntax (e.g., {key: value})#108
Open
guanchzhou wants to merge 1 commit intokubkon:mainfrom
Open
Add support for flow map syntax (e.g., {key: value})#108guanchzhou wants to merge 1 commit intokubkon:mainfrom
guanchzhou wants to merge 1 commit intokubkon:mainfrom
Conversation
83cad99 to
be8225d
Compare
This commit adds support for flow map syntax in YAML documents.
Previously, the parser failed when encountering flow maps (e.g., `{}`
or `{key: value}`) because the `value()` function did not handle
`.flow_map_start` tokens.
The issue manifested when parsing documents like:
```yaml
preferences: {}
current-context: test
```
The parser would fail with "expected end of document" error because:
1. It encountered `{` but had no handler for `.flow_map_start`
2. Returned `.none` as the value for `preferences`
3. Then failed when looking for document end, finding more content
This fix adds:
- A new `mapBracketed()` function similar to `listBracketed()` to
properly parse flow map syntax
- Handling for `.flow_map_start` case in the `value()` function
- Support for empty flow maps `{}`, single-entry maps, and
multi-entry maps
This makes the parser compatible with kubectl-generated kubeconfig
files and other YAML documents that use flow map syntax.
Fixes parsing of YAML 1.2 flow maps as specified in the spec.
be8225d to
b35bc9c
Compare
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.
This commit adds support for flow map syntax in YAML documents. Previously, the parser failed when encountering flow maps (e.g.,
{}or{key: value}) because thevalue()function did not handle.flow_map_starttokens.The issue manifested when parsing documents like:
The parser would fail with "expected end of document" error because:
{but had no handler for.flow_map_start.noneas the value forpreferencesThis fix adds:
mapBracketed()function similar tolistBracketed()to properly parse flow map syntax.flow_map_startcase in thevalue()function{}, single-entry maps, and multi-entry mapsThis makes the parser compatible with kubectl-generated kubeconfig files and other YAML documents that use flow map syntax.
Fixes parsing of YAML 1.2 flow maps as specified in the spec.