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

Function tm_next

src/mcp/test_impact.c:406–466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

404}
405
406static void tm_next(tm_lex_t *lx, tm_tok_t *tok) {
407 memset(tok, 0, sizeof(*tok));
408 while (lx->p < lx->end) {
409 char c = *lx->p;
410 if (c == '\n') {
411 lx->line++;
412 lx->line_start = true;
413 lx->p++;
414 } else if (isspace((unsigned char)c)) {
415 lx->p++;
416 } else if (c == '/' && lx->p + 1 < lx->end && lx->p[1] == '/') {
417 tm_skip_line_comment(lx);
418 } else if (c == '/' && lx->p + 1 < lx->end && lx->p[1] == '*') {
419 tm_skip_block_comment(lx);
420 } else if (lx->directive && tm_splice_len(lx->p, lx->end)) {
421 /* A continuation tm_read_directive already followed and judged. */
422 lx->line++;
423 lx->p += tm_splice_len(lx->p, lx->end);
424 } else {
425 break;
426 }
427 }
428 tok->line = lx->line;
429 if (lx->p >= lx->end) {
430 return; /* TM_TOK_EOF */
431 }
432 char c = *lx->p;
433 if (tm_raw_literal_starts(lx->p, lx->end)) {
434 tm_lex_uncertain(lx);
435 }
436 if (tm_splice_len(lx->p, lx->end)) {
437 tm_lex_uncertain(lx); /* a splice in plain code can join tokens */
438 }
439 bool line_start = lx->line_start;
440 lx->line_start = false;
441 if (c == '#' && line_start) {
442 tm_read_directive(lx, tok);
443 } else if (c == '"' || c == '\'') {
444 tm_skip_literal(lx);
445 tok->kind = TM_TOK_PUNCT;
446 tok->ch = c;
447 } else if (tm_ident_start(c)) {
448 tok->kind = TM_TOK_IDENT;
449 tok->text = lx->p;
450 while (lx->p < lx->end && tm_ident_char(*lx->p)) {
451 lx->p++;
452 }
453 tok->len = (size_t)(lx->p - tok->text);
454 } else if (isdigit((unsigned char)c)) {
455 /* A number, suffix included: `0x1F`, `10u`. Never an identifier. */
456 while (lx->p < lx->end && tm_ident_char(*lx->p)) {
457 lx->p++;
458 }
459 tok->kind = TM_TOK_PUNCT;
460 tok->ch = '0';
461 } else {
462 tok->kind = TM_TOK_PUNCT;
463 tok->ch = c;

Callers 10

tm_macro_argFunction · 0.85
tm_body_opensFunction · 0.85
tm_suite_functionFunction · 0.85
tm_invocation_parseFunction · 0.85
tm_descriptor_identFunction · 0.85
tm_directive_wordFunction · 0.85
tm_is_include_guardFunction · 0.85
tm_directiveFunction · 0.85
tm_file_scope_identFunction · 0.85
tm_scan_sourceFunction · 0.85

Calls 9

tm_skip_line_commentFunction · 0.85
tm_skip_block_commentFunction · 0.85
tm_splice_lenFunction · 0.85
tm_raw_literal_startsFunction · 0.85
tm_lex_uncertainFunction · 0.85
tm_read_directiveFunction · 0.85
tm_skip_literalFunction · 0.85
tm_ident_startFunction · 0.85
tm_ident_charFunction · 0.85

Tested by

no test coverage detected