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

Function lex_try_two_char

src/cypher/cypher.c:234–256  ·  view source on GitHub ↗

Try to match a two-character token at position i. Returns true and advances i if matched. */

Source from the content-addressed store, hash-verified

232
233/* Try to match a two-character token at position i. Returns true and advances i if matched. */
234static bool lex_try_two_char(const char *input, int len, int *i, cbm_lex_result_t *out) {
235 static const struct {
236 char c1, c2;
237 cbm_token_type_t type;
238 const char *text;
239 } pairs[] = {
240 {'!', '=', TOK_NEQ, "!="}, {'<', '>', TOK_NEQ, "<>"}, {'=', '~', TOK_EQTILDE, "=~"},
241 {'>', '=', TOK_GTE, ">="}, {'<', '=', TOK_LTE, "<="}, {'.', '.', TOK_DOTDOT, ".."},
242 };
243 char c = input[*i];
244 if (*i + SKIP_ONE >= len) {
245 return false;
246 }
247 char c2 = input[*i + SKIP_ONE];
248 for (int p = 0; p < (int)(sizeof(pairs) / sizeof(pairs[0])); p++) {
249 if (c == pairs[p].c1 && c2 == pairs[p].c2) {
250 lex_push(out, pairs[p].type, pairs[p].text, *i);
251 *i += PAIR_LEN;
252 return true;
253 }
254 }
255 return false;
256}
257
258/* Try to match a single-character token. Returns TOK_EOF if not matched. */
259static cbm_token_type_t lex_single_char(char c) {

Callers 1

cbm_lexFunction · 0.85

Calls 1

lex_pushFunction · 0.85

Tested by

no test coverage detected