From 4fc0837b56f7b99d89f1f5715340006bb1eb5c56 Mon Sep 17 00:00:00 2001 From: "Tab Atkins Jr." Date: Thu, 16 Jan 2025 14:45:36 -0800 Subject: [PATCH] Support empty multiline strings Per , 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. --- SPEC.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SPEC.md b/SPEC.md index 7f2a72c..010ab7f 100644 --- a/SPEC.md +++ b/SPEC.md @@ -874,7 +874,7 @@ dotted-ident := sign? '.' ((identifier-char - digit) identifier-char*)? identifier-char := unicode - unicode-space - newline - [\\/(){};\[\]"#=] - disallowed-literal-code-points disallowed-keyword-identifiers := 'true' | 'false' | 'null' | 'inf' | '-inf' | 'nan' -quoted-string := '"' single-line-string-body '"' | '"""' newline multi-line-string-body newline (unicode-space | ws-escape)* '"""' +quoted-string := '"' single-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)* string-character := '\\' (["\\bfnrts] | 'u{' hex-unicode '}') | ws-escape | [^\\"] - disallowed-literal-code-points @@ -886,7 +886,7 @@ surrogates := [dD][8-9a-fA-F]hex-digit{2} // D F FF raw-string := '#' raw-string-quotes '#' | '#' raw-string '#' -raw-string-quotes := '"' single-line-raw-string-body '"' | '"""' newline multi-line-raw-string-body newline unicode-space* '"""' +raw-string-quotes := '"' single-line-raw-string-body '"' | '"""' (newline multi-line-raw-string-body)? newline unicode-space* '"""' 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*? single-line-raw-string-char := unicode - newline - disallowed-literal-code-points multi-line-raw-string-body := (unicode - disallowed-literal-code-points)*?