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/grammar/type_args.rs | |
parent | d1400e95d7ad701fcba1191cb00968c2eae8b394 (diff) |
reorganize
Diffstat (limited to 'src/grammar/type_args.rs')
-rw-r--r-- | src/grammar/type_args.rs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/grammar/type_args.rs b/src/grammar/type_args.rs new file mode 100644 index 000000000..5b960f10b --- /dev/null +++ b/src/grammar/type_args.rs | |||
@@ -0,0 +1,48 @@ | |||
1 | use super::*; | ||
2 | |||
3 | pub(super) fn type_arg_list(p: &mut Parser, colon_colon_required: bool) { | ||
4 | let m; | ||
5 | match (colon_colon_required, p.nth(0), p.nth(1)) { | ||
6 | (_, COLONCOLON, L_ANGLE) => { | ||
7 | m = p.start(); | ||
8 | p.bump(); | ||
9 | p.bump(); | ||
10 | } | ||
11 | (false, L_ANGLE, _) => { | ||
12 | m = p.start(); | ||
13 | p.bump(); | ||
14 | } | ||
15 | _ => return, | ||
16 | }; | ||
17 | |||
18 | while !p.at(EOF) && !p.at(R_ANGLE) { | ||
19 | type_arg(p); | ||
20 | if !p.at(R_ANGLE) && !p.expect(COMMA) { | ||
21 | break; | ||
22 | } | ||
23 | } | ||
24 | p.expect(R_ANGLE); | ||
25 | m.complete(p, TYPE_ARG_LIST); | ||
26 | } | ||
27 | |||
28 | // test type_arg | ||
29 | // type A = B<'static, i32, Item=u64> | ||
30 | fn type_arg(p: &mut Parser) { | ||
31 | let m = p.start(); | ||
32 | match p.current() { | ||
33 | LIFETIME => { | ||
34 | p.bump(); | ||
35 | m.complete(p, LIFETIME_ARG); | ||
36 | } | ||
37 | IDENT if p.nth(1) == EQ => { | ||
38 | name_ref(p); | ||
39 | p.bump(); | ||
40 | types::type_(p); | ||
41 | m.complete(p, ASSOC_TYPE_ARG); | ||
42 | } | ||
43 | _ => { | ||
44 | types::type_(p); | ||
45 | m.complete(p, TYPE_ARG); | ||
46 | } | ||
47 | } | ||
48 | } | ||