Skip to content

Commit 91cd421

Browse files
update SPEC to keep lines lengths short (#470)
1 parent 34e4259 commit 91cd421

File tree

1 file changed

+69
-36
lines changed

1 file changed

+69
-36
lines changed

SPEC.md

Lines changed: 69 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ IEEE 754-2008 decimal floating point numbers
266266
* `email`: RFC5322 email address.
267267
* `idn-email`: RFC6531 internationalized email address.
268268
* `hostname`: RFC1132 internet hostname (only ASCII segments)
269-
* `idn-hostname`: RFC5890 internationalized internet hostname (only `xn--`-prefixed ASCII "punycode" segments, or non-ASCII segments)
269+
* `idn-hostname`: RFC5890 internationalized internet hostname
270+
(only `xn--`-prefixed ASCII "punycode" segments, or non-ASCII segments)
270271
* `ipv4`: RFC2673 dotted-quad IPv4 address.
271272
* `ipv6`: RFC2373 IPv6 address.
272273
* `url`: RFC3986 URI.
@@ -608,7 +609,7 @@ while the following example is allowed
608609
bar
609610
baz
610611
\ """
611-
612+
612613
// equivalent to
613614
"""
614615
foo bar
@@ -653,23 +654,23 @@ The string contains the literal characters `hello\n\r\asd"#world`
653654

654655
```kdl
655656
raw-multi-line #"""
656-
You can show examples of """
657-
multi-line strings
657+
Here's a """
658+
multiline string
658659
"""
659-
without worrying about escapes.
660+
without escapes.
660661
"""#
661662
```
662663

663664
The string contains the value
664665

665-
```
666-
You can show examples of """
667-
multi-line strings
666+
~~~
667+
Here's a """
668+
multiline string
668669
"""
669-
without worrying about escapes.
670-
```
670+
without escapes.
671+
~~~
671672

672-
or equivalently, `"You can show examples of \"\"\"\n multi-line strings\n \"\"\"\nwithout worrying about escapes."` as a Quoted String.
673+
or equivalently, `"Here's a \"\"\"\n multiline string\n \"\"\"\nwithout escapes."` as a Quoted String.
673674

674675
### Number
675676

@@ -790,7 +791,7 @@ annotations, if present:
790791
* A [Children Block](#children-block): the entire block, including all
791792
children within, is treated as Whitespace. Only other children blocks, whether
792793
slashdashed or not, may follow a slashdashed children block.
793-
794+
794795
A slashdash may be be followed by any amount of whitespace, including newlines and
795796
comments (other than other slashdashes), before the element that it comments out.
796797

@@ -843,12 +844,12 @@ document := bom? version? nodes
843844
nodes := (line-space* node)* line-space*
844845
845846
base-node := slashdash? type? node-space* string
846-
(node-space+ slashdash? node-prop-or-arg)*
847-
// slashdashed node-children must always be after props and args.
848-
(node-space+ slashdash node-children)*
849-
(node-space+ node-children)?
850-
(node-space+ slashdash node-children)*
851-
node-space*
847+
(node-space+ slashdash? node-prop-or-arg)*
848+
// slashdashed node-children must always be after props and args.
849+
(node-space+ slashdash node-children)*
850+
(node-space+ node-children)?
851+
(node-space+ slashdash node-children)*
852+
node-space*
852853
node := base-node node-terminator
853854
final-node := base-node node-terminator?
854855
@@ -865,16 +866,31 @@ type := '(' node-space* string node-space* ')'
865866
string := identifier-string | quoted-string | raw-string ¶
866867
867868
identifier-string := unambiguous-ident | signed-ident | dotted-ident
868-
unambiguous-ident := ((identifier-char - digit - sign - '.') identifier-char*) - disallowed-keyword-strings
869-
signed-ident := sign ((identifier-char - digit - '.') identifier-char*)?
870-
dotted-ident := sign? '.' ((identifier-char - digit) identifier-char*)?
871-
identifier-char := unicode - unicode-space - newline - [\\/(){};\[\]"#=] - disallowed-literal-code-points
872-
disallowed-keyword-identifiers := 'true' | 'false' | 'null' | 'inf' | '-inf' | 'nan'
873-
874-
quoted-string := '"' single-line-string-body '"' | '"""' newline multi-line-string-body newline (unicode-space | ws-escape)* '"""'
869+
unambiguous-ident :=
870+
((identifier-char - digit - sign - '.') identifier-char*)
871+
- disallowed-keyword-strings
872+
signed-ident :=
873+
sign ((identifier-char - digit - '.') identifier-char*)?
874+
dotted-ident :=
875+
sign? '.' ((identifier-char - digit) identifier-char*)?
876+
identifier-char :=
877+
unicode - unicode-space - newline - [\\/(){};\[\]"#=]
878+
- disallowed-literal-code-points
879+
disallowed-keyword-identifiers :=
880+
'true' | 'false' | 'null' | 'inf' | '-inf' | 'nan'
881+
882+
quoted-string :=
883+
'"' single-line-string-body '"' |
884+
'"""' newline
885+
multi-line-string-body newline
886+
(unicode-space | ws-escape)* '"""'
875887
single-line-string-body := (string-character - newline)*
876888
multi-line-string-body := (('"' | '""')? string-character)*
877-
string-character := '\\' (["\\bfnrts] | 'u{' hex-unicode '}') | ws-escape | [^\\"] - disallowed-literal-code-points
889+
string-character :=
890+
'\\' (["\\bfnrts] |
891+
'u{' hex-unicode '}') |
892+
ws-escape |
893+
[^\\"] - disallowed-literal-code-points
878894
ws-escape := '\\' (unicode-space | newline)+
879895
hex-digit := [0-9a-fA-F]
880896
hex-unicode := hex-digit{1, 6} - surrogates
@@ -883,10 +899,21 @@ surrogates := [dD][8-9a-fA-F]hex-digit{2}
883899
// D F FF
884900
885901
raw-string := '#' raw-string-quotes '#' | '#' raw-string '#'
886-
raw-string-quotes := '"' single-line-raw-string-body '"' | '"""' newline multi-line-raw-string-body newline unicode-space* '"""'
887-
single-line-raw-string-body := '' | (single-line-raw-string-char - '"') single-line-raw-string-char*? | '"' (single-line-raw-string-char - '"') single-line-raw-string-char*?
888-
single-line-raw-string-char := unicode - newline - disallowed-literal-code-points
889-
multi-line-raw-string-body := (unicode - disallowed-literal-code-points)*?
902+
raw-string-quotes :=
903+
'"' single-line-raw-string-body '"' |
904+
'"""' newline
905+
multi-line-raw-string-body newline
906+
unicode-space* '"""'
907+
single-line-raw-string-body :=
908+
'' |
909+
(single-line-raw-string-char - '"')
910+
single-line-raw-string-char*? |
911+
'"' (single-line-raw-string-char - '"')
912+
single-line-raw-string-char*?
913+
single-line-raw-string-char :=
914+
unicode - newline - disallowed-literal-code-points
915+
multi-line-raw-string-body :=
916+
(unicode - disallowed-literal-code-points)*?
890917
891918
// Numbers
892919
number := keyword-number | hex | octal | binary | decimal
@@ -908,14 +935,17 @@ boolean := '#true' | '#false'
908935
909936
// Specific code points
910937
bom := '\u{FEFF}'
911-
disallowed-literal-code-points := See Table (Disallowed Literal Code Points)
938+
disallowed-literal-code-points :=
939+
See Table (Disallowed Literal Code Points)
912940
unicode := Any Unicode Scalar Value
913-
unicode-space := See Table (All White_Space unicode characters which are not `newline`)
941+
unicode-space := See Table
942+
(All White_Space unicode characters which are not `newline`)
914943
915944
// Comments
916945
single-line-comment := '//' ^newline* (newline | eof)
917946
multi-line-comment := '/*' commented-block
918-
commented-block := '*/' | (multi-line-comment | '*' | '/' | [^*/]+) commented-block
947+
commented-block :=
948+
'*/' | (multi-line-comment | '*' | '/' | [^*/]+) commented-block
919949
slashdash := '/-' line-space*
920950
921951
// Whitespace
@@ -924,12 +954,15 @@ escline := '\\' ws* (single-line-comment | newline | eof)
924954
newline := See Table (All Newline White_Space)
925955
// Whitespace where newlines are allowed.
926956
line-space := node-space | newline | single-line-comment
927-
// Whitespace within nodes, where newline-ish things must be esclined.
957+
// Whitespace within nodes,
958+
// where newline-ish things must be esclined.
928959
node-space := ws* escline ws* | ws+
929960
930961
// Version marker
931-
version := '/-' unicode-space* 'kdl-version' unicode-space+ ('1' | '2') unicode-space* newline
932-
```
962+
version :=
963+
'/-' unicode-space* 'kdl-version' unicode-space+ ('1' | '2')
964+
unicode-space* newline
965+
~~~
933966
934967
### Grammar language
935968

0 commit comments

Comments
 (0)