multi-line string literals
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user