aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/parser/event_parser/grammar/items/mod.rs44
-rw-r--r--src/parser/event_parser/grammar/items/structs.rs2
-rw-r--r--src/syntax_kinds.rs6
3 files changed, 50 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
62fn generic_parameters(_: &mut Parser) {} 62fn 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
64fn where_clause(_: &mut Parser) {} 106fn 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);
diff --git a/src/syntax_kinds.rs b/src/syntax_kinds.rs
index 23a0881b7..b6c281cd5 100644
--- a/src/syntax_kinds.rs
+++ b/src/syntax_kinds.rs
@@ -90,6 +90,9 @@ pub enum SyntaxKind {
90 LITERAL, 90 LITERAL,
91 ALIAS, 91 ALIAS,
92 VISIBILITY, 92 VISIBILITY,
93 TYPE_PARAM_LIST,
94 LIFETIME_PARAM,
95 TYPE_PARAM,
93 96
94 // Technical SyntaxKinds: they appear temporally during parsing, 97 // Technical SyntaxKinds: they appear temporally during parsing,
95 // but never end up in the final tree 98 // but never end up in the final tree
@@ -187,6 +190,9 @@ impl SyntaxKind {
187 LITERAL => &SyntaxInfo { name: "LITERAL" }, 190 LITERAL => &SyntaxInfo { name: "LITERAL" },
188 ALIAS => &SyntaxInfo { name: "ALIAS" }, 191 ALIAS => &SyntaxInfo { name: "ALIAS" },
189 VISIBILITY => &SyntaxInfo { name: "VISIBILITY" }, 192 VISIBILITY => &SyntaxInfo { name: "VISIBILITY" },
193 TYPE_PARAM_LIST => &SyntaxInfo { name: "TYPE_PARAM_LIST" },
194 LIFETIME_PARAM => &SyntaxInfo { name: "LIFETIME_PARAM" },
195 TYPE_PARAM => &SyntaxInfo { name: "TYPE_PARAM" },
190 196
191 TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" }, 197 TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" },
192 EOF => &SyntaxInfo { name: "EOF" }, 198 EOF => &SyntaxInfo { name: "EOF" },