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

Function parse_rel

src/cypher/cypher.c:730–765  ·  view source on GitHub ↗

Parse relationship: -[:TYPE|TYPE2*min..max]-> or <-[...]- */

Source from the content-addressed store, hash-verified

728
729/* Parse relationship: -[:TYPE|TYPE2*min..max]-> or <-[...]- */
730static int parse_rel(parser_t *p, cbm_rel_pattern_t *out) {
731 memset(out, 0, sizeof(*out));
732 out->min_hops = SKIP_ONE;
733 out->max_hops = SKIP_ONE;
734
735 /* Check for leading < (inbound) */
736 bool leading_lt = match(p, TOK_LT);
737 if (!expect(p, TOK_DASH)) {
738 return CBM_NOT_FOUND;
739 }
740
741 /* Optional bracket content */
742 if (match(p, TOK_LBRACKET)) {
743 if (parse_rel_bracket(p, out) < 0) {
744 return CBM_NOT_FOUND;
745 }
746 }
747
748 if (!expect(p, TOK_DASH)) {
749 return CBM_NOT_FOUND;
750 }
751
752 /* Check for trailing > (outbound) */
753 bool trailing_gt = match(p, TOK_GT);
754
755 /* Determine direction */
756 if (leading_lt && !trailing_gt) {
757 out->direction = heap_strdup("inbound");
758 } else if (!leading_lt && trailing_gt) {
759 out->direction = heap_strdup("outbound");
760 } else {
761 out->direction = heap_strdup("any");
762 }
763
764 return 0;
765}
766
767/* ── Expression tree helpers ────────────────────────────────────── */
768

Callers 2

parse_exists_predicateFunction · 0.85
parse_match_patternFunction · 0.85

Calls 4

matchFunction · 0.85
expectFunction · 0.85
parse_rel_bracketFunction · 0.85
heap_strdupFunction · 0.70

Tested by

no test coverage detected