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

Function cbm_lex

src/cypher/cypher.c:356–415  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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