MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / tm_read_directive

Function tm_read_directive

src/mcp/test_impact.c:366–404  ·  view source on GitHub ↗

The rest of a preprocessor line, backslash continuations included. */

Source from the content-addressed store, hash-verified

364
365/* The rest of a preprocessor line, backslash continuations included. */
366static 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
406static void tm_next(tm_lex_t *lx, tm_tok_t *tok) {
407 memset(tok, 0, sizeof(*tok));

Callers 1

tm_nextFunction · 0.85

Calls 7

tm_raw_literal_startsFunction · 0.85
tm_lex_uncertainFunction · 0.85
tm_skip_line_commentFunction · 0.85
tm_skip_literalFunction · 0.85
tm_splice_lenFunction · 0.85
tm_blankFunction · 0.85
tm_skip_block_commentFunction · 0.85

Tested by

no test coverage detected