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

Function parse_match_pattern

src/cypher/cypher.c:1846–1878  ·  view source on GitHub ↗

Parse a single MATCH pattern into pat */

Source from the content-addressed store, hash-verified

1844
1845/* Parse a single MATCH pattern into pat */
1846static int parse_match_pattern(parser_t *p, cbm_pattern_t *pat) {
1847 memset(pat, 0, sizeof(*pat));
1848 int node_cap = CYP_INIT_CAP4;
1849 int rel_cap = CYP_INIT_CAP4;
1850 pat->nodes = malloc(node_cap * sizeof(cbm_node_pattern_t));
1851 pat->rels = calloc(rel_cap, sizeof(cbm_rel_pattern_t));
1852
1853 if (parse_node(p, &pat->nodes[0]) < 0) {
1854 return CBM_NOT_FOUND;
1855 }
1856 pat->node_count = SKIP_ONE;
1857
1858 while (check(p, TOK_DASH) || check(p, TOK_LT)) {
1859 if (pat->rel_count >= rel_cap) {
1860 rel_cap *= PAIR_LEN;
1861 pat->rels = safe_realloc(pat->rels, rel_cap * sizeof(cbm_rel_pattern_t));
1862 }
1863 if (parse_rel(p, &pat->rels[pat->rel_count]) < 0) {
1864 return CBM_NOT_FOUND;
1865 }
1866 pat->rel_count++;
1867
1868 if (pat->node_count >= node_cap) {
1869 node_cap *= PAIR_LEN;
1870 pat->nodes = safe_realloc(pat->nodes, node_cap * sizeof(cbm_node_pattern_t));
1871 }
1872 if (parse_node(p, &pat->nodes[pat->node_count]) < 0) {
1873 return CBM_NOT_FOUND;
1874 }
1875 pat->node_count++;
1876 }
1877 return 0;
1878}
1879
1880/* Parse UNWIND [...] AS var clause into query */
1881static 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
safe_reallocFunction · 0.85
parse_relFunction · 0.85
checkFunction · 0.70

Tested by

no test coverage detected