aboutsummaryrefslogtreecommitdiff
path: root/src/parser/event_parser/grammar/paths.rs
blob: 16a8ce2396e2cb1a96b2044c2becc53e70428c0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use super::*;

pub(crate) fn use_path(p: &mut Parser) {
    if !AnyOf(&[IDENT, COLONCOLON]).is_ahead(p) {
        return;
    }
    node(p, PATH, |p| {
        path_segment(p, true);
    });
    many(p, |p| {
        node_if(p, COLONCOLON, PATH, |p| {
            path_segment(p, false);
        })
    });
}

fn path_segment(p: &mut Parser, first: bool) {
    node(p, PATH_SEGMENT, |p| {
        if first {
            p.eat(COLONCOLON);
        }
        p.expect(IDENT);
    })
}