multi-line string literals

This commit is contained in:
2026-06-26 22:53:49 +02:00
parent f2ed0b4c4f
commit f926bbc605
5 changed files with 117 additions and 16 deletions
+28
View File
@@ -277,6 +277,34 @@ lex :: proc(
)
append_token(&stream, source_file, .Invalid, start, cursor, diagnostic=id)
}
case '`':
// Multi-line string: each line is marked with a leading '`'; raw
// content (no escapes) runs to end of line. Consecutive backtick
// lines collapse into one token; the trailing '\n' is left to
// become the statement-terminating Newline.
start := cursor
content_end := cursor
for {
cursor += 1 // skip backtick
for cursor < len(bytes) && bytes[cursor] != '\n' {
cursor += 1
}
content_end = cursor
look := cursor
if look < len(bytes) && bytes[look] == '\n' {
look += 1
}
for look < len(bytes) && (bytes[look] == ' ' || bytes[look] == '\t') {
look += 1
}
if look < len(bytes) && bytes[look] == '`' {
cursor = look
continue
}
break
}
cursor = content_end
append_token(&stream, source_file, .Multiline_String, start, content_end)
case ';':
append_token(&stream, source_file, .Semicolon, cursor, cursor+1)
cursor += 1