| ... | @@ -267,6 +267,29 @@ static void parse_string_literal(ParseContext *pc, Token *token, Buf *buf, bool | ... | @@ -267,6 +267,29 @@ static void parse_string_literal(ParseContext *pc, Token *token, Buf *buf, bool |
| 267 | } | 267 | } |
| 268 | const char *str = buf_ptr(pc->buf) + token->raw_string_start; | 268 | const char *str = buf_ptr(pc->buf) + token->raw_string_start; |
| 269 | buf_init_from_mem(buf, str, token->raw_string_end - token->raw_string_start); | 269 | buf_init_from_mem(buf, str, token->raw_string_end - token->raw_string_start); |
| | 270 | if (offset_map) { |
| | 271 | SrcPos pos = {token->start_line, token->start_column}; |
| | 272 | for (int i = token->start_pos; i < token->raw_string_start; i += 1) { |
| | 273 | uint8_t c = buf_ptr(pc->buf)[i]; |
| | 274 | if (c == '\n') { |
| | 275 | pos.line += 1; |
| | 276 | pos.column = 0; |
| | 277 | } else { |
| | 278 | pos.column += 1; |
| | 279 | } |
| | 280 | } |
| | 281 | for (int i = token->raw_string_start; i < token->raw_string_end; i += 1) { |
| | 282 | offset_map->append(pos); |
| | 283 | |
| | 284 | uint8_t c = buf_ptr(pc->buf)[i]; |
| | 285 | if (c == '\n') { |
| | 286 | pos.line += 1; |
| | 287 | pos.column = 0; |
| | 288 | } else { |
| | 289 | pos.column += 1; |
| | 290 | } |
| | 291 | } |
| | 292 | } |
| 270 | return; | 293 | return; |
| 271 | } | 294 | } |
| 272 | | 295 | |