aboutsummaryrefslogtreecommitdiff
path: root/src/parser
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-01-30 19:53:19 +0000
committerAleksey Kladov <[email protected]>2018-01-30 19:53:19 +0000
commit197a2e6fefd45627920cfb9bbca24b446e5a7c89 (patch)
tree04fbad2a682433c6b23ec0c09cccd0216a89e21f /src/parser
parent94caa9d3a2c645df5c0f2d332bc001831119484d (diff)
G: type_parameter_list
Diffstat (limited to 'src/parser')
-rw-r--r--src/parser/event_parser/grammar/items/mod.rs26
-rw-r--r--src/parser/event_parser/grammar/paths.rs13
2 files changed, 36 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..bf3c8aedd 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 }
@@ -24,6 +32,7 @@ pub(crate) fn use_path(p: &mut Parser) {
24 } 32 }
25} 33}
26 34
35
27fn path_segment(p: &mut Parser, first: bool) { 36fn path_segment(p: &mut Parser, first: bool) {
28 let segment = p.start(); 37 let segment = p.start();
29 if first { 38 if first {