add multiline string literal

and make multiple lines in normal string literals an error
This commit is contained in:
Andrew Kelley committed 2016-04-03 18:59:43 -07:00
1 parent 5bae9ba086
commit e144ddab24
7 files changed
+162 -11

No files matched your search

+10
View File
@@ -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