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

Function cbm_lex

src/cypher/cypher.c:359–418  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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