add multiline string literal
and make multiple lines in normal string literals an error
This commit is contained in:
@@ -226,6 +226,16 @@ static uint8_t parse_char_literal(ParseContext *pc, Token *token) {
|
||||
static void parse_string_literal(ParseContext *pc, Token *token, Buf *buf, bool *out_c_str,
|
||||
ZigList<SrcPos> *offset_map)
|
||||
{
|
||||
if (token->raw_string_start > 0) {
|
||||
uint8_t c1 = *((uint8_t*)buf_ptr(pc->buf) + token->start_pos);
|
||||
uint8_t c2 = *((uint8_t*)buf_ptr(pc->buf) + token->start_pos + 1);
|
||||
assert(c1 == 'r');
|
||||
*out_c_str = (c2 == 'c');
|
||||
const char *str = buf_ptr(pc->buf) + token->raw_string_start;
|
||||
buf_init_from_mem(buf, str, token->raw_string_end - token->raw_string_start);
|
||||
return;
|
||||
}
|
||||
|
||||
// skip the double quotes at beginning and end
|
||||
// convert escape sequences
|
||||
// detect c string literal
|
||||
|
||||
Reference in New Issue
Block a user