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