Allow whitespace in more places

Fixes: https://github.com/kdl-org/kdl/issues/355
This commit is contained in:
Kat Marchán 2023-12-12 22:28:52 -08:00
parent c8488db13e
commit 13799de32b
No known key found for this signature in database
GPG Key ID: AEB529C08A3C7E9E
2 changed files with 11 additions and 4 deletions

View File

@ -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

View File

@ -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* '"'