be a bit more specific about ordering + add line continuations

This commit is contained in:
Kat Marchán 2020-12-15 21:18:48 -08:00
parent 951eed8f43
commit 3ed2f0aa27
No known key found for this signature in database
GPG Key ID: AEB529C08A3C7E9E
2 changed files with 30 additions and 5 deletions

View File

@ -18,7 +18,7 @@ to jump in and give us your 2 cents!
1. Maintainability
1. Flexibility
1. Cognitive simplicity
1. Cognitive simplicity and Learnability
1. Ease of de/serialization
1. Ease of implementation

33
SPEC.md
View File

@ -33,10 +33,18 @@ Being a node-oriented language means that the real core component of any KDL
document is the "node". Every node must have a name, which is either a legal
[Identifier](#identifier), or a quoted [String](#string).
Following the name are zero or more whitespace-separated [Values](#value) or
[Properties](#property). Values and Properties may be interspersed in any
order, much like is common with positional arguments vs options in command
line tools.
Following the name are zero or more [Values](#value) or
[Properties](#property), separated by either [whitespace](#whitespace) or [a
slash-escaped line continuation](#line-continuation). Values and Properties
may be interspersed in any order, much like is common with positional
arguments vs options in command line tools.
Values are ordered relative to each other and that order must be
preserved in order to maintain the semantics.
By contrast, Property order _should not matter_ to implementations.
[Children](#children-block) should be used if an order-sensitive key/value
data structure must be represented in KDL.
Finally, a node is terminated by either a [Newline](#newline), a [Children
Block](#children-block), a semicolon (`;`) or the end of the file/stream (an
@ -77,6 +85,23 @@ The following characters cannot be used anywhere in a bare
* Any codepoint with hexadecimal value higher than `0x10FFF`.
* Any of "\\{};[]=,"
### Line Continuation
Line continuations allow [Nodes](#node) to be spread across multiple lines.
A line continuation is one or more [whitespace](#whitespace) characters,
followed by a `/` character. This character can then be followed by more
[whitespace](#whitespace) and must be terminated by a [Newline](#newline)
(including the Newline that is part of single-line comments).
Following a line continuation, processing of a Node can continue as usual.
#### Example
```kdl
my-node 1 2 \ // this is a comment
3 4 // This is the actual end of the Node.
```
## Full Grammar
```