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

Function lex_try_ident

src/cypher/cypher.c:290–309  ·  view source on GitHub ↗

Try to lex an identifier or keyword starting at position i. Returns true if matched. */

Source from the content-addressed store, hash-verified

288
289/* Try to lex an identifier or keyword starting at position i. Returns true if matched. */
290static bool lex_try_ident(const char *input, int len, int *i, cbm_lex_result_t *out) {
291 char c = input[*i];
292 if (!isalpha((unsigned char)c) && c != '_') {
293 return false;
294 }
295 int start = *i;
296 while (*i < len && (isalnum((unsigned char)input[*i]) || input[*i] == '_')) {
297 (*i)++;
298 }
299 char word[CBM_SZ_256];
300 int wlen = *i - start;
301 if (wlen >= (int)sizeof(word)) {
302 wlen = (int)sizeof(word) - SKIP_ONE;
303 }
304 memcpy(word, input + start, wlen);
305 word[wlen] = '\0';
306 cbm_token_type_t type = keyword_lookup(word);
307 lex_push_n(out, type, input + start, *i - start, start);
308 return true;
309}
310
311/* Try to lex a number starting at position i. Returns true if matched. */
312static bool lex_try_number(const char *input, int len, int *i, cbm_lex_result_t *out) {

Callers 1

cbm_lexFunction · 0.85

Calls 2

keyword_lookupFunction · 0.85
lex_push_nFunction · 0.85

Tested by

no test coverage detected