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