Parse bracket content of a relationship: [var:TYPE*hops] */
| 681 | |
| 682 | /* Parse bracket content of a relationship: [var:TYPE*hops] */ |
| 683 | static int parse_rel_bracket(parser_t *p, cbm_rel_pattern_t *out) { |
| 684 | /* Optional variable */ |
| 685 | if (check(p, TOK_IDENT) && !check(p, TOK_COLON)) { |
| 686 | out->variable = heap_strdup(advance(p)->text); |
| 687 | } |
| 688 | /* Optional :Types */ |
| 689 | if (match(p, TOK_COLON)) { |
| 690 | if (parse_rel_types(p, out) < 0) { |
| 691 | return CBM_NOT_FOUND; |
| 692 | } |
| 693 | } |
| 694 | /* Optional *hop_range */ |
| 695 | if (match(p, TOK_STAR)) { |
| 696 | parse_hop_range(p, &out->min_hops, &out->max_hops); |
| 697 | } |
| 698 | if (!expect(p, TOK_RBRACKET)) { |
| 699 | return CBM_NOT_FOUND; |
| 700 | } |
| 701 | return 0; |
| 702 | } |
| 703 | |
| 704 | /* Parse relationship: -[:TYPE|TYPE2*min..max]-> or <-[...]- */ |
| 705 | static int parse_rel(parser_t *p, cbm_rel_pattern_t *out) { |
no test coverage detected