aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-02-02 18:32:51 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-02-02 18:32:51 +0000
commit3c6ccfe6474cf15e7c59c8b6c01d8a1b3604ba02 (patch)
tree9c0b788009666087bdaa4072f0a466ff7cc93caf /src
parent94caa9d3a2c645df5c0f2d332bc001831119484d (diff)
parent7a02097b717c6f7055a92c52dca65c374b06f057 (diff)
Merge #32
32: G: type_parameter_list r=matklad a=matklad
Diffstat (limited to 'src')
-rw-r--r--src/parser/event_parser/grammar/items/mod.rs26
-rw-r--r--src/parser/event_parser/grammar/paths.rs12
-rw-r--r--src/syntax_kinds.rs15
3 files changed, 50 insertions, 3 deletions
diff --git a/src/parser/event_parser/grammar/items/mod.rs b/src/parser/event_parser/grammar/items/mod.rs
index 0a50fffc1..4d8783735 100644
--- a/src/parser/event_parser/grammar/items/mod.rs
+++ b/src/parser/event_parser/grammar/items/mod.rs
@@ -103,8 +103,32 @@ fn type_param_list(p: &mut Parser) {
103 assert!(p.at(IDENT)); 103 assert!(p.at(IDENT));
104 let m = p.start(); 104 let m = p.start();
105 p.bump(); 105 p.bump();
106 if p.eat(COLON) {
107 loop {
108 let has_paren = p.eat(L_PAREN);
109 p.eat(QUESTION);
110 if p.at(FOR_KW) {
111 //TODO
112 }
113 if p.at(LIFETIME) {
114 p.bump();
115 } else if paths::is_path_start(p) {
116 paths::type_path(p);
117 } else {
118 break;
119 }
120 if has_paren {
121 p.expect(R_PAREN);
122 }
123 if !p.eat(PLUS) {
124 break;
125 }
126 }
127 }
128 if p.at(EQ) {
129 types::type_ref(p)
130 }
106 m.complete(p, TYPE_PARAM); 131 m.complete(p, TYPE_PARAM);
107 //TODO: bounds
108 } 132 }
109} 133}
110 134
diff --git a/src/parser/event_parser/grammar/paths.rs b/src/parser/event_parser/grammar/paths.rs
index a254ab05e..4c0d2c8b4 100644
--- a/src/parser/event_parser/grammar/paths.rs
+++ b/src/parser/event_parser/grammar/paths.rs
@@ -1,10 +1,18 @@
1use super::*; 1use super::*;
2 2
3pub(crate) fn is_path_start(p: &Parser) -> bool { 3pub(super) fn is_path_start(p: &Parser) -> bool {
4 AnyOf(&[IDENT, SELF_KW, SUPER_KW, COLONCOLON]).is_ahead(p) 4 AnyOf(&[IDENT, SELF_KW, SUPER_KW, COLONCOLON]).is_ahead(p)
5} 5}
6 6
7pub(crate) fn use_path(p: &mut Parser) { 7pub(super) fn use_path(p: &mut Parser) {
8 path(p)
9}
10
11pub(super) fn type_path(p: &mut Parser) {
12 path(p)
13}
14
15fn path(p: &mut Parser) {
8 if !is_path_start(p) { 16 if !is_path_start(p) {
9 return; 17 return;
10 } 18 }
diff --git a/src/syntax_kinds.rs b/src/syntax_kinds.rs
index 519326f48..cd4c753a9 100644
--- a/src/syntax_kinds.rs
+++ b/src/syntax_kinds.rs
@@ -23,6 +23,11 @@ pub enum SyntaxKind {
23 SUPER_KW, 23 SUPER_KW,
24 IN_KW, 24 IN_KW,
25 WHERE_KW, 25 WHERE_KW,
26 FOR_KW,
27 LOOP_KW,
28 WHILE_KW,
29 IF_KW,
30 MATCH_KW,
26 ERROR, 31 ERROR,
27 IDENT, 32 IDENT,
28 UNDERSCORE, 33 UNDERSCORE,
@@ -125,6 +130,11 @@ impl SyntaxKind {
125 SUPER_KW => &SyntaxInfo { name: "SUPER_KW" }, 130 SUPER_KW => &SyntaxInfo { name: "SUPER_KW" },
126 IN_KW => &SyntaxInfo { name: "IN_KW" }, 131 IN_KW => &SyntaxInfo { name: "IN_KW" },
127 WHERE_KW => &SyntaxInfo { name: "WHERE_KW" }, 132 WHERE_KW => &SyntaxInfo { name: "WHERE_KW" },
133 FOR_KW => &SyntaxInfo { name: "FOR_KW" },
134 LOOP_KW => &SyntaxInfo { name: "LOOP_KW" },
135 WHILE_KW => &SyntaxInfo { name: "WHILE_KW" },
136 IF_KW => &SyntaxInfo { name: "IF_KW" },
137 MATCH_KW => &SyntaxInfo { name: "MATCH_KW" },
128 ERROR => &SyntaxInfo { name: "ERROR" }, 138 ERROR => &SyntaxInfo { name: "ERROR" },
129 IDENT => &SyntaxInfo { name: "IDENT" }, 139 IDENT => &SyntaxInfo { name: "IDENT" },
130 UNDERSCORE => &SyntaxInfo { name: "UNDERSCORE" }, 140 UNDERSCORE => &SyntaxInfo { name: "UNDERSCORE" },
@@ -223,6 +233,11 @@ pub(crate) fn ident_to_keyword(ident: &str) -> Option<SyntaxKind> {
223 "super" => Some(SUPER_KW), 233 "super" => Some(SUPER_KW),
224 "in" => Some(IN_KW), 234 "in" => Some(IN_KW),
225 "where" => Some(WHERE_KW), 235 "where" => Some(WHERE_KW),
236 "for" => Some(FOR_KW),
237 "loop" => Some(LOOP_KW),
238 "while" => Some(WHILE_KW),
239 "if" => Some(IF_KW),
240 "match" => Some(MATCH_KW),
226 _ => None, 241 _ => None,
227 } 242 }
228} 243}