diff options
author | Aleksey Kladov <[email protected]> | 2018-01-12 17:59:19 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-01-12 17:59:19 +0000 |
commit | c111a1f7b8b9da2b4691c792e1658b2888ff5420 (patch) | |
tree | 95922433f8eb2a162896ba78a95de4fb8cc8aa73 /src/parser | |
parent | ca0c5ea38b623422e1a25388817e224c2c4f4ae2 (diff) |
Nest paths
Diffstat (limited to 'src/parser')
-rw-r--r-- | src/parser/event_parser/grammar/mod.rs | 2 | ||||
-rw-r--r-- | src/parser/event_parser/grammar/paths.rs | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/parser/event_parser/grammar/mod.rs b/src/parser/event_parser/grammar/mod.rs index 76f62b714..3c4b223a9 100644 --- a/src/parser/event_parser/grammar/mod.rs +++ b/src/parser/event_parser/grammar/mod.rs | |||
@@ -40,7 +40,7 @@ fn node<F: FnOnce(&mut Parser)>(p: &mut Parser, node_kind: SyntaxKind, rest: F) | |||
40 | p.finish(); | 40 | p.finish(); |
41 | } | 41 | } |
42 | 42 | ||
43 | fn many<F: Fn(&mut Parser) -> bool>(p: &mut Parser, f: F) { | 43 | fn many<F: FnMut(&mut Parser) -> bool>(p: &mut Parser, mut f: F) { |
44 | loop { | 44 | loop { |
45 | let pos = p.pos(); | 45 | let pos = p.pos(); |
46 | if !f(p) { | 46 | if !f(p) { |
diff --git a/src/parser/event_parser/grammar/paths.rs b/src/parser/event_parser/grammar/paths.rs index 16a8ce239..108545bc2 100644 --- a/src/parser/event_parser/grammar/paths.rs +++ b/src/parser/event_parser/grammar/paths.rs | |||
@@ -4,12 +4,16 @@ pub(crate) fn use_path(p: &mut Parser) { | |||
4 | if !AnyOf(&[IDENT, COLONCOLON]).is_ahead(p) { | 4 | if !AnyOf(&[IDENT, COLONCOLON]).is_ahead(p) { |
5 | return; | 5 | return; |
6 | } | 6 | } |
7 | let mut prev = p.mark(); | ||
7 | node(p, PATH, |p| { | 8 | node(p, PATH, |p| { |
8 | path_segment(p, true); | 9 | path_segment(p, true); |
9 | }); | 10 | }); |
10 | many(p, |p| { | 11 | many(p, |p| { |
12 | let curr = p.mark(); | ||
11 | node_if(p, COLONCOLON, PATH, |p| { | 13 | node_if(p, COLONCOLON, PATH, |p| { |
12 | path_segment(p, false); | 14 | path_segment(p, false); |
15 | p.forward_parent(prev, curr); | ||
16 | prev = curr; | ||
13 | }) | 17 | }) |
14 | }); | 18 | }); |
15 | } | 19 | } |