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

Function parse_hop_range

src/cypher/cypher.c:634–656  ·  view source on GitHub ↗

Parse *min..max hop range after the star token has been consumed */

Source from the content-addressed store, hash-verified

632
633/* Parse *min..max hop range after the star token has been consumed */
634static void parse_hop_range(parser_t *p, int *min_hops, int *max_hops) {
635 if (check(p, TOK_NUMBER)) {
636 int val = (int)strtol(peek(p)->text, NULL, CBM_DECIMAL_BASE);
637 advance(p);
638 if (match(p, TOK_DOTDOT)) {
639 *min_hops = val;
640 *max_hops =
641 check(p, TOK_NUMBER) ? (int)strtol(advance(p)->text, NULL, CBM_DECIMAL_BASE) : 0;
642 } else {
643 /* *N means 1..N */
644 *min_hops = SKIP_ONE;
645 *max_hops = val;
646 }
647 } else if (match(p, TOK_DOTDOT)) {
648 *min_hops = SKIP_ONE;
649 *max_hops =
650 check(p, TOK_NUMBER) ? (int)strtol(advance(p)->text, NULL, CBM_DECIMAL_BASE) : 0;
651 } else {
652 /* * alone = unbounded */
653 *min_hops = SKIP_ONE;
654 *max_hops = 0;
655 }
656}
657
658/* Parse relationship type list after ':' inside brackets. Returns -1 on error. */
659static int parse_rel_types(parser_t *p, cbm_rel_pattern_t *out) {

Callers 1

parse_rel_bracketFunction · 0.85

Calls 4

peekFunction · 0.85
matchFunction · 0.85
checkFunction · 0.70
advanceFunction · 0.70

Tested by

no test coverage detected