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

Function cbm_lex

src/cypher/cypher.c:366–425  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

364}
365
366int cbm_lex(const char *input, cbm_lex_result_t *out) {
367 memset(out, 0, sizeof(*out));
368 if (!input) {
369 return CBM_NOT_FOUND;
370 }
371
372 int len = (int)strlen(input);
373 int i = 0;
374
375 while (i < len) {
376 if (lex_skip_whitespace_comments(input, len, &i)) {
377 continue;
378 }
379
380 char c = input[i];
381
382 /* String literals */
383 if (c == '"' || c == '\'') {
384 char quote = c;
385 i++;
386 lex_string_literal(input, len, &i, quote, out);
387 continue;
388 }
389
390 /* Numbers — stop before ".." (DOTDOT operator) */
391 if (lex_try_number(input, len, &i, out)) {
392 continue;
393 }
394
395 /* Identifiers / keywords */
396 if (lex_try_ident(input, len, &i, out)) {
397 continue;
398 }
399
400 /* Two-character tokens */
401 {
402 bool found_two = lex_try_two_char(input, len, &i, out);
403 if (found_two) {
404 continue;
405 }
406 }
407
408 /* Single-character tokens */
409 cbm_token_type_t stype = lex_single_char(c);
410
411 if (stype != TOK_EOF) {
412 char buf[PAIR_LEN] = {c, '\0'};
413 lex_push(out, stype, buf, i);
414 i++;
415 continue;
416 }
417
418 /* Unknown character — skip */
419 i++;
420 }
421
422 /* Add EOF */
423 lex_push(out, TOK_EOF, "", i);

Callers 2

cbm_cypher_parseFunction · 0.85
test_cypher.cFile · 0.85

Calls 7

lex_string_literalFunction · 0.85
lex_try_numberFunction · 0.85
lex_try_identFunction · 0.85
lex_try_two_charFunction · 0.85
lex_single_charFunction · 0.85
lex_pushFunction · 0.85

Tested by

no test coverage detected