From eb55930264a347d4656aae9d1aa82cc7dc1cfd7f Mon Sep 17 00:00:00 2001 From: Christopher Durham Date: Sun, 10 Dec 2023 20:44:55 -0500 Subject: [PATCH] Update formal grammar for KDL 2.0 (#285) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: https://github.com/kdl-org/kdl/issues/284 * Update formal grammar * Update SPEC.md for KDL 2.0 preview * Update SPEC.md Co-authored-by: Christopher Durham --------- Co-authored-by: Tab Atkins Jr Co-authored-by: Kat Marchán --- SPEC.md | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/SPEC.md b/SPEC.md index cbd90c7..b06c311 100644 --- a/SPEC.md +++ b/SPEC.md @@ -473,12 +473,20 @@ Note that for the purpose of new lines, CRLF is considered _a single newline_. ## Full Grammar ``` -nodes := linespace* (node nodes?)? linespace* +nodes := (line-space* node)* line-space* -node := ('/-' node-space*)? type? identifier (node-space+ node-prop-or-arg)* (node-space* node-children ws*)? node-space* node-terminator -node-prop-or-arg := ('/-' node-space*)? (prop | value) -node-children := ('/-' node-space*)? '{' nodes '}' -node-space := ws* escline ws* | ws+ +plain-line-space := newline | ws | single-line-comment +plain-node-space := ws* escline ws* | ws+ + +line-space := plain-line-space+ ('/-' plain-node-space* node)? +node-space := plain-node-space+ ('/-' plain-node-space* (node-prop-or-arg | node-children))? + +required-node-space := node-space* plain-node-space+ +optional-node-space := node-space* + +node := type? identifier (required-node-space node-prop-or-arg)* (required-node-space node-children)? optional-node-space node-terminator +node-prop-or-arg := prop | value +node-children := '{' nodes '}' node-terminator := single-line-comment | newline | ';' | eof identifier := string | bare-identifier @@ -486,7 +494,7 @@ bare-identifier := (unambiguous-ident | numberish-ident | stringish-ident) - key unambiguous-ident := (identifier-char - digit - sign - "r") identifier-char* numberish-ident := sign ((identifier-char - digit) identifier-char*)? stringish-ident := "r" ((identifier-char - "#") identifier-char*)? -identifier-char := unicode - linespace - [\/(){}<>;[]=,"] +identifier-char := unicode - line-space - [\/(){}<>;[]=,"] keyword := boolean | 'null' prop := identifier '=' value value := type? (string | number | keyword) @@ -518,8 +526,6 @@ boolean := 'true' | 'false' escline := '\\' ws* (single-line-comment | newline) -linespace := newline | ws | single-line-comment - newline := See Table (All line-break white_space) ws := bom | unicode-space | multi-line-comment