Skip to content

Allow leading whitespace in KV3 text headers - #23

Merged
kristiker merged 4 commits into
mainfrom
copilot/fix-leading-whitespace-in-kv3-header
May 6, 2026
Merged

kristiker merged 4 commits into
mainfrom
copilot/fix-leading-whitespace-in-kv3-header

Conversation

Copilot AI commented May 6, 2026 •

Copy link
Copy Markdown
Contributor

The parser rejected KV3 files with leading whitespace before the header comment, failing with Rule 'kv3' didn't match.

Changes

  • Grammar: Added optional ws* prefix to kv3 rule to accept leading whitespace
  • Visitor: Updated visit_kv3 to find header/data nodes by type rather than positional index, handling variable parse tree structure
  • Version: Bumped to 0.6

Example

Files like this now parse correctly:

text = ' <!-- kv3 encoding:text:version{...} format:generic:version{...} -->\n{}'
result = KV3TextReader().parse(text)  # Previously raised KV3DecodeError

Copilot AI linked an issue May 6, 2026 that may be closed by this pull request
Copilot AI and others added 3 commits May 6, 2026 14:37
- Updated grammar to allow optional whitespace before header
- Fixed visitor to correctly identify header and data when whitespace is present
- Added test for leading whitespace (space, multiple spaces, tab)
- Bumped version from 0.5 to 0.5.1

Agent-Logs-Url: https://github.com/kristiker/keyvalues3/sessions/37458b76-7f4e-4842-9e21-295594a83f79

Co-authored-by: kristiker <26466974+kristiker@users.noreply.github.com>
Agent-Logs-Url: https://github.com/kristiker/keyvalues3/sessions/37458b76-7f4e-4842-9e21-295594a83f79

Co-authored-by: kristiker <26466974+kristiker@users.noreply.github.com>
Agent-Logs-Url: https://github.com/kristiker/keyvalues3/sessions/37458b76-7f4e-4842-9e21-295594a83f79

Co-authored-by: kristiker <26466974+kristiker@users.noreply.github.com>
@kristiker
kristiker marked this pull request as ready for review May 6, 2026 14:39
Copilot AI changed the title [WIP] Fix leading whitespace in KV3 header causing parser error Allow leading whitespace in KV3 text headers May 6, 2026
Copilot AI requested a review from kristiker May 6, 2026 14:40
@kristiker
kristiker merged commit 06a5009 into main May 6, 2026
1 check passed
@kristiker
kristiker deleted the copilot/fix-leading-whitespace-in-kv3-header branch May 6, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Leading whitespace in KV3 header causes error.

2 participants