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