Berry Allow comments in multi-line strings (#18848)

This commit is contained in:
s-hadinger 2023-06-10 22:23:43 +02:00 committed by GitHub
parent 5cb9bae72c
commit 5da84c52ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View File

@ -394,7 +394,9 @@ static int skip_delimiter(blexer *lexer) {
int c = lgetc(lexer);
int delimeter_present = 0;
while (1) {
if (c == '\r' || c == '\n') {
if (c == '#') {
skip_comment(lexer);
} else if (c == '\r' || c == '\n') {
skip_newline(lexer);
} else if (c == ' ' || c == '\t' || c == '\f' || c == '\v') {
next(lexer);

View File

@ -88,3 +88,25 @@ assert(string.replace("hellollo", "aa", "xx") == "hellollo")
assert(string.replace("hello", "ll", "") == "heo")
assert(string.replace("hello", "", "xx") == "hello")
assert(string.replace("hello", "", "") == "hello")
# multi-line strings
var s = "a" "b""c"
assert(s == 'abc')
s = 'a'"b"'''c'
assert(s == 'abc')
s = "a"
'b'
""
"c"
assert(s == 'abc')
s = "a" #- b -# "b" #--# "c"
assert(s == 'abc')
s = "a"#
# "z"
"b" # zz
"c"
assert(s == 'abc')