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

Function lex_try_two_char

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

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