diff options
author | Aleksey Kladov <[email protected]> | 2018-01-28 15:53:53 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-01-28 18:18:24 +0000 |
commit | 8ca02acb5a574c312dcb3842904b99b282d45883 (patch) | |
tree | d1707c94eda435c95408f73ec530aa5ac2386920 /src/parser/event_parser/grammar/items/mod.rs | |
parent | 7e55b2693f17afdae91c492c6f79c9ba4020d893 (diff) |
Generic params in structs
Diffstat (limited to 'src/parser/event_parser/grammar/items/mod.rs')
-rw-r--r-- | src/parser/event_parser/grammar/items/mod.rs | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/src/parser/event_parser/grammar/items/mod.rs b/src/parser/event_parser/grammar/items/mod.rs index 867776415..f10fb230b 100644 --- a/src/parser/event_parser/grammar/items/mod.rs +++ b/src/parser/event_parser/grammar/items/mod.rs | |||
@@ -59,7 +59,49 @@ fn item(p: &mut Parser) { | |||
59 | item.complete(p, item_kind); | 59 | item.complete(p, item_kind); |
60 | } | 60 | } |
61 | 61 | ||
62 | fn generic_parameters(_: &mut Parser) {} | 62 | fn type_param_list(p: &mut Parser) { |
63 | if !p.at(L_ANGLE) { | ||
64 | return; | ||
65 | } | ||
66 | let m = p.start(); | ||
67 | p.bump(); | ||
68 | |||
69 | while !p.at(EOF) && !p.at(R_ANGLE) { | ||
70 | match p.current() { | ||
71 | LIFETIME => lifetime_param(p), | ||
72 | IDENT => type_param(p), | ||
73 | _ => p.err_and_bump("expected type parameter"), | ||
74 | } | ||
75 | if !p.at(R_ANGLE) && !p.expect(COMMA) { | ||
76 | break; | ||
77 | } | ||
78 | } | ||
79 | p.expect(R_ANGLE); | ||
80 | m.complete(p, TYPE_PARAM_LIST); | ||
81 | |||
82 | fn lifetime_param(p: &mut Parser) { | ||
83 | assert!(p.at(LIFETIME)); | ||
84 | let m = p.start(); | ||
85 | p.bump(); | ||
86 | if p.eat(COLON) { | ||
87 | while p.at(LIFETIME) { | ||
88 | p.bump(); | ||
89 | if !p.eat(PLUS) { | ||
90 | break; | ||
91 | } | ||
92 | } | ||
93 | } | ||
94 | m.complete(p, LIFETIME_PARAM); | ||
95 | } | ||
96 | |||
97 | fn type_param(p: &mut Parser) { | ||
98 | assert!(p.at(IDENT)); | ||
99 | let m = p.start(); | ||
100 | p.bump(); | ||
101 | m.complete(p, TYPE_PARAM); | ||
102 | //TODO: bounds | ||
103 | } | ||
104 | } | ||
63 | 105 | ||
64 | fn where_clause(_: &mut Parser) {} | 106 | fn where_clause(_: &mut Parser) {} |
65 | 107 | ||