Parse *min..max hop range after the star token has been consumed */
| 597 | |
| 598 | /* Parse *min..max hop range after the star token has been consumed */ |
| 599 | static void parse_hop_range(parser_t *p, int *min_hops, int *max_hops) { |
| 600 | if (check(p, TOK_NUMBER)) { |
| 601 | int val = (int)strtol(peek(p)->text, NULL, CBM_DECIMAL_BASE); |
| 602 | advance(p); |
| 603 | if (match(p, TOK_DOTDOT)) { |
| 604 | *min_hops = val; |
| 605 | *max_hops = |
| 606 | check(p, TOK_NUMBER) ? (int)strtol(advance(p)->text, NULL, CBM_DECIMAL_BASE) : 0; |
| 607 | } else { |
| 608 | /* *N means 1..N */ |
| 609 | *min_hops = SKIP_ONE; |
| 610 | *max_hops = val; |
| 611 | } |
| 612 | } else if (match(p, TOK_DOTDOT)) { |
| 613 | *min_hops = SKIP_ONE; |
| 614 | *max_hops = |
| 615 | check(p, TOK_NUMBER) ? (int)strtol(advance(p)->text, NULL, CBM_DECIMAL_BASE) : 0; |
| 616 | } else { |
| 617 | /* * alone = unbounded */ |
| 618 | *min_hops = SKIP_ONE; |
| 619 | *max_hops = 0; |
| 620 | } |
| 621 | } |
| 622 | |
| 623 | /* Parse relationship type list after ':' inside brackets. Returns -1 on error. */ |
| 624 | static int parse_rel_types(parser_t *p, cbm_rel_pattern_t *out) { |
no test coverage detected