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

Function cbm_lex

src/cypher/cypher.c:358–417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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