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

Function lex_try_two_char

src/cypher/cypher.c:226–248  ·  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

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