The rest of a preprocessor line, backslash continuations included. */
| 364 | |
| 365 | /* The rest of a preprocessor line, backslash continuations included. */ |
| 366 | static void tm_read_directive(tm_lex_t *lx, tm_tok_t *tok) { |
| 367 | lx->p++; /* '#' */ |
| 368 | tok->kind = TM_TOK_DIRECTIVE; |
| 369 | tok->text = lx->p; |
| 370 | while (lx->p < lx->end && *lx->p != '\n') { |
| 371 | if (tm_raw_literal_starts(lx->p, lx->end)) { |
| 372 | tm_lex_uncertain(lx); |
| 373 | } |
| 374 | if (*lx->p == '/' && lx->p + 1 < lx->end && lx->p[1] == '/') { |
| 375 | tm_skip_line_comment(lx); |
| 376 | continue; |
| 377 | } |
| 378 | if (*lx->p == '"' || *lx->p == '\'') { |
| 379 | tm_skip_literal(lx); |
| 380 | continue; |
| 381 | } |
| 382 | size_t splice = tm_splice_len(lx->p, lx->end); |
| 383 | if (splice) { |
| 384 | /* Next to a blank a continuation only separates tokens; with |
| 385 | * token characters on both sides it could join them, which the |
| 386 | * re-lexing of this text (tm_directive_word) does not do. The |
| 387 | * '#' precedes the text, so p[-1] is in bounds. */ |
| 388 | const char *after = lx->p + splice; |
| 389 | if (!tm_blank(lx->p[-1]) && after < lx->end && !tm_blank(*after) && *after != '\n' && |
| 390 | *after != '\r') { |
| 391 | tm_lex_uncertain(lx); |
| 392 | } |
| 393 | lx->line++; |
| 394 | lx->p = after; |
| 395 | continue; |
| 396 | } |
| 397 | if (*lx->p == '/' && lx->p + 1 < lx->end && lx->p[1] == '*') { |
| 398 | tm_skip_block_comment(lx); /* may run on to later lines */ |
| 399 | continue; |
| 400 | } |
| 401 | lx->p++; |
| 402 | } |
| 403 | tok->len = (size_t)(lx->p - tok->text); |
| 404 | } |
| 405 | |
| 406 | static void tm_next(tm_lex_t *lx, tm_tok_t *tok) { |
| 407 | memset(tok, 0, sizeof(*tok)); |
no test coverage detected