feat: simplify ABNF for v0.1 and introduce section in main document#27
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the JSONC specification site to better surface and simplify the formal grammar, and refreshes the generated railroad diagram to match the revised ABNF and styling goals.
Changes:
- Add a “Formal grammar” section to the main document linking to the ABNF file and railroad diagram.
- Simplify and make the ABNF more self-contained (removing reliance on RFC 5234 core rules and removing LS/PS mentions).
- Update the railroad diagram generator script and the generated HTML/CSS output to reflect the new grammar and a revised visual style/order.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
index.markdown |
Adds a dedicated section linking to the ABNF grammar and railroad diagram. |
grammar/README.md |
Updates documented paths/examples to use grammar/JSONC.abnf. |
grammar/JSONC.abnf |
Simplifies comment terminators and inlines core-rule equivalents (digit/hexdigit), reorders value, and updates string escape hexdigits rule. |
generate-railroad.js |
Updates default input, adds inlining/reordering logic, and post-processes generated HTML header. |
grammar/railroad-diagram.html |
Regenerated diagram output reflecting the updated grammar and ordering. |
grammar/railroad-diagram.css |
Adjusts diagram styling (terminal/nonterminal appearance and labels). |
Comments suppressed due to low confidence (1)
grammar/JSONC.abnf:26
single-line-comment-endallows a bare CR (%x0D), but the spec defines a “line ending” as LF or CRLF (index.markdown:23) and defines single-line comments as continuing until a line ending. Please either (a) remove the standalone CR alternative here so the formal grammar matches the spec’s terminology, or (b) update the spec’s line-ending definition to explicitly include lone CR as well.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
The suppressed comment:
Is actually relevant, the ABNF indeed allows a lone CR as a line-comment-terminator. Similarly, jsonc-parser and EcmaScript also consider that a lone CR is a valid line-comment-terminator. In the case of EcmaScript, a lone CR is a valid LineTerminatorSequence. For these reasons, the text of the spec should actually reflect that acceptance and specify that a lone CR is a valid line line ending. |
This PR: