Parse *min..max hop range after the star token has been consumed */
| 623 | |
| 624 | /* Parse *min..max hop range after the star token has been consumed */ |
| 625 | static void parse_hop_range(parser_t *p, int *min_hops, int *max_hops) { |
| 626 | if (check(p, TOK_NUMBER)) { |
| 627 | int val = (int)strtol(peek(p)->text, NULL, CBM_DECIMAL_BASE); |
| 628 | advance(p); |
| 629 | if (match(p, TOK_DOTDOT)) { |
| 630 | *min_hops = val; |
| 631 | *max_hops = |
| 632 | check(p, TOK_NUMBER) ? (int)strtol(advance(p)->text, NULL, CBM_DECIMAL_BASE) : 0; |
| 633 | } else { |
| 634 | /* *N means 1..N */ |
| 635 | *min_hops = SKIP_ONE; |
| 636 | *max_hops = val; |
| 637 | } |
| 638 | } else if (match(p, TOK_DOTDOT)) { |
| 639 | *min_hops = SKIP_ONE; |
| 640 | *max_hops = |
| 641 | check(p, TOK_NUMBER) ? (int)strtol(advance(p)->text, NULL, CBM_DECIMAL_BASE) : 0; |
| 642 | } else { |
| 643 | /* * alone = unbounded */ |
| 644 | *min_hops = SKIP_ONE; |
| 645 | *max_hops = 0; |
| 646 | } |
| 647 | } |
| 648 | |
| 649 | /* Parse relationship type list after ':' inside brackets. Returns -1 on error. */ |
| 650 | static int parse_rel_types(parser_t *p, cbm_rel_pattern_t *out) { |
no test coverage detected