diff options
Diffstat (limited to 'src/parser/event_parser/grammar/items')
-rw-r--r-- | src/parser/event_parser/grammar/items/mod.rs | 44 | ||||
-rw-r--r-- | src/parser/event_parser/grammar/items/structs.rs | 2 |
2 files changed, 44 insertions, 2 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 | ||
diff --git a/src/parser/event_parser/grammar/items/structs.rs b/src/parser/event_parser/grammar/items/structs.rs index b31cf18df..0934f3d28 100644 --- a/src/parser/event_parser/grammar/items/structs.rs +++ b/src/parser/event_parser/grammar/items/structs.rs | |||
@@ -7,7 +7,7 @@ pub(super) fn struct_item(p: &mut Parser) { | |||
7 | if !p.expect(IDENT) { | 7 | if !p.expect(IDENT) { |
8 | return; | 8 | return; |
9 | } | 9 | } |
10 | generic_parameters(p); | 10 | type_param_list(p); |
11 | match p.current() { | 11 | match p.current() { |
12 | WHERE_KW => { | 12 | WHERE_KW => { |
13 | where_clause(p); | 13 | where_clause(p); |