Parse bracket content of a relationship: [var:TYPE*hops] */
| 706 | |
| 707 | /* Parse bracket content of a relationship: [var:TYPE*hops] */ |
| 708 | static int parse_rel_bracket(parser_t *p, cbm_rel_pattern_t *out) { |
| 709 | /* Optional variable */ |
| 710 | if (check(p, TOK_IDENT) && !check(p, TOK_COLON)) { |
| 711 | out->variable = heap_strdup(advance(p)->text); |
| 712 | } |
| 713 | /* Optional :Types */ |
| 714 | if (match(p, TOK_COLON)) { |
| 715 | if (parse_rel_types(p, out) < 0) { |
| 716 | return CBM_NOT_FOUND; |
| 717 | } |
| 718 | } |
| 719 | /* Optional *hop_range */ |
| 720 | if (match(p, TOK_STAR)) { |
| 721 | parse_hop_range(p, &out->min_hops, &out->max_hops); |
| 722 | } |
| 723 | if (!expect(p, TOK_RBRACKET)) { |
| 724 | return CBM_NOT_FOUND; |
| 725 | } |
| 726 | return 0; |
| 727 | } |
| 728 | |
| 729 | /* Parse relationship: -[:TYPE|TYPE2*min..max]-> or <-[...]- */ |
| 730 | static int parse_rel(parser_t *p, cbm_rel_pattern_t *out) { |
no test coverage detected