From eaf34d3b4550dd1e2f52a991066d0bb464550247 Mon Sep 17 00:00:00 2001 From: mrdgo Date: Thu, 21 Nov 2024 09:31:07 +0100 Subject: [PATCH] feat: allow empty raw strings, add test with empty string --- src/scanner.c | 2 +- test/corpus/decl/raw-strings.nu | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/scanner.c b/src/scanner.c index 9e7a9a4..eac5cc4 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -109,7 +109,7 @@ static bool scan_raw_string_content(TSLexer *lexer, Scanner *s) { adv; uint8_t level = consume_chars(lexer, '#'); lexer->log(lexer, "Consumed [%i] #\n", level); - if (level == s->level && len != 0) { + if (level == s->level) { lexer->log(lexer, "Detected end\n" ); return true; } else if (level == s->level && len == 0) { diff --git a/test/corpus/decl/raw-strings.nu b/test/corpus/decl/raw-strings.nu index 0d59d35..8a49a9f 100644 --- a/test/corpus/decl/raw-strings.nu +++ b/test/corpus/decl/raw-strings.nu @@ -61,3 +61,19 @@ r#####'string '#'##'##### (raw_string_begin) (raw_string_content) (raw_string_end))))) + +===== +raw-strings-005-empty-string +===== + +r#''# + +----- + +(nu_script + (pipeline + (pipe_element + (val_string + (raw_string_begin) + (raw_string_content) + (raw_string_end)))))