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

Function parse_match_chain

src/cypher/cypher.c:1988–2010  ·  view source on GitHub ↗

Parse a chain of MATCH / OPTIONAL MATCH patterns into query. * Returns -1 on error (fills p->error). */

Source from the content-addressed store, hash-verified

1986/* Parse a chain of MATCH / OPTIONAL MATCH patterns into query.
1987 * Returns -1 on error (fills p->error). */
1988static int parse_match_chain(parser_t *p, cbm_query_t *q, int *pat_cap) {
1989 while (check(p, TOK_MATCH) || check(p, TOK_OPTIONAL)) {
1990 bool opt = false;
1991 if (check(p, TOK_OPTIONAL)) {
1992 advance(p);
1993 opt = true;
1994 }
1995 if (!expect(p, TOK_MATCH)) {
1996 break;
1997 }
1998 if (q->pattern_count >= *pat_cap) {
1999 *pat_cap *= PAIR_LEN;
2000 q->patterns = safe_realloc(q->patterns, *pat_cap * sizeof(cbm_pattern_t));
2001 q->pattern_optional = safe_realloc(q->pattern_optional, *pat_cap * sizeof(bool));
2002 }
2003 if (parse_match_pattern(p, &q->patterns[q->pattern_count]) < 0) {
2004 return CBM_NOT_FOUND;
2005 }
2006 q->pattern_optional[q->pattern_count] = opt;
2007 q->pattern_count++;
2008 }
2009 return 0;
2010}
2011
2012/* Parse post-WHERE clauses: additional MATCH, WITH, RETURN. A UNION keyword
2013 * is left for cbm_parse, which reads the branches in a loop. */

Callers 2

parse_post_whereFunction · 0.85
parse_query_blockFunction · 0.85

Calls 5

expectFunction · 0.85
safe_reallocFunction · 0.85
parse_match_patternFunction · 0.85
checkFunction · 0.70
advanceFunction · 0.70

Tested by

no test coverage detected