From 13799de32b4a44bf802e681d25f608526c18526d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Tue, 12 Dec 2023 22:28:52 -0800 Subject: [PATCH] Allow whitespace in more places Fixes: https://github.com/kdl-org/kdl/issues/355 --- CHANGELOG.md | 7 +++++++ SPEC.md | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29904e6..cfbf263 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,13 @@ * The last node in a child block no longer needs to be terminated with `;`, even if the closing `}` is on the same line, so this is now a legal node: `node {foo;bar;baz}` +* More places allow whitespace (node-spaces, specifically) now. With great + power comes great responsibility: + * Inside `(foo)` annotations (so, `( foo )` would be legal (`( f oo )` would + not be, since it has two identifiers)) + * Between annotations and the thing they're annotating (`(blah) node (thing) + 1 y= (who) 2`) + * Around `=` for props (`x = 1`) ### KQL diff --git a/SPEC.md b/SPEC.md index 5067133..88332ac 100644 --- a/SPEC.md +++ b/SPEC.md @@ -527,7 +527,7 @@ node-space := plain-node-space+ ('/-' plain-node-space* (node-prop-or-arg | node required-node-space := node-space* plain-node-space+ optional-node-space := node-space* -base-node := type? identifier (required-node-space node-prop-or-arg)* (required-node-space node-children)? +base-node := type? optional-node-space identifier (required-node-space node-prop-or-arg)* (required-node-space node-children)? node := base-node optional-node-space node-terminator final-node := base-node optional-node-space node-terminator? node-prop-or-arg := prop | value @@ -541,9 +541,9 @@ numberish-ident := sign ((identifier-char - digit) identifier-char*)? identifier-char := unicode - line-space - [\\/(){};\[\]="#] - disallowed-literal-code-points keyword := '#' (boolean | 'null') -prop := identifier '=' value -value := type? (identifier | string | number | keyword) -type := '(' identifier ')' +prop := identifier optional-node-space '=' optional-node-space value +value := type? optional-node-space (identifier | string | number | keyword) +type := '(' optional-node-space identifier optional-node-space ')' string := raw-string | escaped-string escaped-string := '"' string-character* '"'