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

Function parse_match_pattern

src/cypher/cypher.c:1697–1729  ·  view source on GitHub ↗

Parse a single MATCH pattern into pat */

Source from the content-addressed store, hash-verified

1695
1696/* Parse a single MATCH pattern into pat */
1697static int parse_match_pattern(parser_t *p, cbm_pattern_t *pat) {
1698 memset(pat, 0, sizeof(*pat));
1699 int node_cap = CYP_INIT_CAP4;
1700 int rel_cap = CYP_INIT_CAP4;
1701 pat->nodes = malloc(node_cap * sizeof(cbm_node_pattern_t));
1702 pat->rels = calloc(rel_cap, sizeof(cbm_rel_pattern_t));
1703
1704 if (parse_node(p, &pat->nodes[0]) < 0) {
1705 return CBM_NOT_FOUND;
1706 }
1707 pat->node_count = SKIP_ONE;
1708
1709 while (check(p, TOK_DASH) || check(p, TOK_LT)) {
1710 if (pat->rel_count >= rel_cap) {
1711 rel_cap *= PAIR_LEN;
1712 pat->rels = safe_realloc(pat->rels, rel_cap * sizeof(cbm_rel_pattern_t));
1713 }
1714 if (parse_rel(p, &pat->rels[pat->rel_count]) < 0) {
1715 return CBM_NOT_FOUND;
1716 }
1717 pat->rel_count++;
1718
1719 if (pat->node_count >= node_cap) {
1720 node_cap *= PAIR_LEN;
1721 pat->nodes = safe_realloc(pat->nodes, node_cap * sizeof(cbm_node_pattern_t));
1722 }
1723 if (parse_node(p, &pat->nodes[pat->node_count]) < 0) {
1724 return CBM_NOT_FOUND;
1725 }
1726 pat->node_count++;
1727 }
1728 return 0;
1729}
1730
1731/* Parse UNWIND [...] AS var clause into query */
1732static void parse_unwind_clause(parser_t *p, cbm_query_t *q) {

Callers 2

parse_match_chainFunction · 0.85
cbm_parseFunction · 0.85

Calls 4

parse_nodeFunction · 0.85
checkFunction · 0.85
safe_reallocFunction · 0.85
parse_relFunction · 0.85

Tested by

no test coverage detected