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

Function parse_rel

src/cypher/cypher.c:740–775  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

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