Support empty multiline strings (#483)

* Support empty multiline strings

Per <https://github.com/kdl-org/kdl/discussions/481>, the grammar doesn't actually allow the first and last newline in a multiline string to be the same (indicating an empty string). This looks like the minimal fix for it.

* Add tests for empty multilines

* remove accidental newline
This commit is contained in:
Tab Atkins Jr. 2025-01-17 16:28:52 -08:00 committed by GitHub
parent 20375a187e
commit 0c2dde6d3c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 14 additions and 2 deletions

View File

@ -889,7 +889,7 @@ disallowed-keyword-identifiers :=
quoted-string :=
'"' single-line-string-body '"' |
'"""' newline
multi-line-string-body newline
(multi-line-string-body newline)?
(unicode-space | ws-escape)* '"""'
single-line-string-body := (string-character - newline)*
multi-line-string-body := (('"' | '""')? string-character)*
@ -909,7 +909,7 @@ raw-string := '#' raw-string-quotes '#' | '#' raw-string '#'
raw-string-quotes :=
'"' single-line-raw-string-body '"' |
'"""' newline
multi-line-raw-string-body newline
(multi-line-raw-string-body newline)?
unicode-space* '"""'
single-line-raw-string-body :=
'' |

View File

@ -0,0 +1 @@
node ""

View File

@ -0,0 +1 @@
node ""

View File

@ -0,0 +1 @@
node ""

View File

@ -0,0 +1 @@
node ""

View File

@ -0,0 +1,2 @@
node #"""
"""#

View File

@ -0,0 +1,2 @@
node #"""
"""#

View File

@ -0,0 +1,2 @@
node """
"""

View File

@ -0,0 +1,2 @@
node """
"""