diff options
author | Aleksey Kladov <[email protected]> | 2018-07-31 21:38:19 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-07-31 21:44:31 +0100 |
commit | 7912189ec304b28c4df0030b5282cf3d21074154 (patch) | |
tree | 03a0a1b128439fdefbd1d012b392995ca8a6e264 /src/parser/grammar/patterns.rs | |
parent | d1400e95d7ad701fcba1191cb00968c2eae8b394 (diff) |
reorganize
Diffstat (limited to 'src/parser/grammar/patterns.rs')
-rw-r--r-- | src/parser/grammar/patterns.rs | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/src/parser/grammar/patterns.rs b/src/parser/grammar/patterns.rs deleted file mode 100644 index 7216807fd..000000000 --- a/src/parser/grammar/patterns.rs +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
1 | use super::*; | ||
2 | |||
3 | pub(super) fn pattern(p: &mut Parser) { | ||
4 | match p.current() { | ||
5 | UNDERSCORE => placeholder_pat(p), | ||
6 | AMPERSAND => ref_pat(p), | ||
7 | IDENT | REF_KW | MUT_KW => bind_pat(p), | ||
8 | _ => p.err_and_bump("expected pattern"), | ||
9 | } | ||
10 | } | ||
11 | |||
12 | // test placeholder_pat | ||
13 | // fn main() { let _ = (); } | ||
14 | fn placeholder_pat(p: &mut Parser) { | ||
15 | assert!(p.at(UNDERSCORE)); | ||
16 | let m = p.start(); | ||
17 | p.bump(); | ||
18 | m.complete(p, PLACEHOLDER_PAT); | ||
19 | } | ||
20 | |||
21 | // test ref_pat | ||
22 | // fn main() { | ||
23 | // let &a = (); | ||
24 | // let &mut b = (); | ||
25 | // } | ||
26 | fn ref_pat(p: &mut Parser) { | ||
27 | assert!(p.at(AMPERSAND)); | ||
28 | let m = p.start(); | ||
29 | p.bump(); | ||
30 | p.eat(MUT_KW); | ||
31 | pattern(p); | ||
32 | m.complete(p, REF_PAT); | ||
33 | } | ||
34 | |||
35 | // test bind_pat | ||
36 | // fn main() { | ||
37 | // let a = (); | ||
38 | // let mut b = (); | ||
39 | // let ref c = (); | ||
40 | // let ref mut d = (); | ||
41 | // let e @ _ = (); | ||
42 | // let ref mut f @ g @ _ = (); | ||
43 | // } | ||
44 | fn bind_pat(p: &mut Parser) { | ||
45 | let m = p.start(); | ||
46 | p.eat(REF_KW); | ||
47 | p.eat(MUT_KW); | ||
48 | name(p); | ||
49 | if p.eat(AT) { | ||
50 | pattern(p); | ||
51 | } | ||
52 | m.complete(p, BIND_PAT); | ||
53 | } | ||