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

Function parse_match_pattern

src/cypher/cypher.c:1845–1877  ·  view source on GitHub ↗

Parse a single MATCH pattern into pat */

Source from the content-addressed store, hash-verified

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