diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-04-03 18:44:17 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-04-03 18:59:43 -0700 |
| commit | e144ddab249af3737f04267c7f1f0f0e093ed314 (patch) | |
| tree | 13a209862d84c916b5789caf2caf52d3281b235c /src/parser.cpp | |
| parent | 5bae9ba0869409598d272a03477641d234ace8e6 (diff) | |
| download | zig-e144ddab249af3737f04267c7f1f0f0e093ed314.tar.gz zig-e144ddab249af3737f04267c7f1f0f0e093ed314.zip | |
add multiline string literal
and make multiple lines in normal string literals an error
Diffstat (limited to 'src/parser.cpp')
| -rw-r--r-- | src/parser.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index f9115181d1..14ac0fb916 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -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 |
