Skip to content

Commit a15818b

Browse files
eugenesvkeilvelia
andauthored
Add an optional version marker (#444)
* Add version marker to the grammer * Add version marker to the Changelog * Update SPEC.md Co-authored-by: eilvelia <[email protected]> * add a mandatory newline after the version marker * add mandatory space between version number --------- Co-authored-by: eilvelia <[email protected]>
1 parent da5cbf5 commit a15818b

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

CHANGELOG.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@
7373
intuitive. They can now be used in exactly three different places: before nodes,
7474
before entire entries, or before entire child blocks.
7575
* Furthermore, The ordering of slashdashed elements has been restricted such
76-
that a slashdashed child block cannot go before an entry (including slashdashed
77-
entries).
76+
* Optional version marker `/- kdl-version 2` (or `1`) as the first line in a document, optionally preceded by the BOM.
7877

7978
### KQL
8079

SPEC.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -828,14 +828,18 @@ They may be represented in Strings (but not Raw Strings) using [Unicode Escapes]
828828
* `U+FEFF`, aka Zero-width Non-breaking Space (ZWNBSP)/Byte Order Mark (BOM),
829829
except as the first code point in a document.
830830

831+
### Version marker
832+
833+
A version marker `/- kdl-version 2` (or `1`) _MAY_ be added to the beginning of a KDL document, optionally preceded by the BOM, and parsers _MAY_ use that as a hint as to which version to parse the document as.
834+
831835
## Full Grammar
832836

833837
This is the full official grammar for KDL and should be considered
834838
authoritative if something seems to disagree with the text above. The [grammar
835839
language syntax](#grammar-language) is defined below.
836840

837841
```
838-
document := bom? nodes
842+
document := bom? version? nodes
839843
840844
// Nodes
841845
nodes := (line-space* node)* line-space*
@@ -920,6 +924,9 @@ newline := See Table (All Newline White_Space)
920924
line-space := node-space | newline | single-line-comment
921925
// Whitespace within nodes, where newline-ish things must be esclined.
922926
node-space := ws* escline ws* | ws+
927+
928+
// Version marker
929+
version := '/-' unicode-space* 'kdl-version' unicode-space+ ('1' | '2') unicode-space* newline
923930
```
924931

925932
### Grammar language

0 commit comments

Comments
 (0)