aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-02-10 09:53:07 +0000
committerAleksey Kladov <[email protected]>2018-02-10 09:53:07 +0000
commitdd6e5371ebddeaeecb3d1e2d3d6c8b3c9050bb05 (patch)
tree6e68e8242bbc181e5a846754466d4109783b6a2f
parent2ef16a4121ad497e7fb290445ffe644b6b8ceae6 (diff)
G: where clause
-rw-r--r--grammar.ron1
-rw-r--r--src/parser/grammar/type_params.rs2
-rw-r--r--src/syntax_kinds.rs2
-rw-r--r--tests/data/parser/inline/0016_type_item_where_clause.txt17
4 files changed, 14 insertions, 8 deletions
diff --git a/grammar.ron b/grammar.ron
index 8e265323b..c38bf654d 100644
--- a/grammar.ron
+++ b/grammar.ron
@@ -114,6 +114,7 @@ Grammar(
114 "ALIAS", 114 "ALIAS",
115 "VISIBILITY", 115 "VISIBILITY",
116 "TYPE_PARAM_LIST", 116 "TYPE_PARAM_LIST",
117 "WHERE_CLAUSE",
117 "LIFETIME_PARAM", 118 "LIFETIME_PARAM",
118 "TYPE_PARAM", 119 "TYPE_PARAM",
119 "ABI", 120 "ABI",
diff --git a/src/parser/grammar/type_params.rs b/src/parser/grammar/type_params.rs
index 73c3cf8b8..8f62a471c 100644
--- a/src/parser/grammar/type_params.rs
+++ b/src/parser/grammar/type_params.rs
@@ -70,9 +70,11 @@ pub(super) fn list(p: &mut Parser) {
70 70
71pub(super) fn where_clause(p: &mut Parser) { 71pub(super) fn where_clause(p: &mut Parser) {
72 if p.at(WHERE_KW) { 72 if p.at(WHERE_KW) {
73 let m = p.start();
73 p.bump(); 74 p.bump();
74 p.expect(IDENT); 75 p.expect(IDENT);
75 p.expect(COLON); 76 p.expect(COLON);
76 p.expect(IDENT); 77 p.expect(IDENT);
78 m.complete(p, WHERE_CLAUSE);
77 } 79 }
78} 80}
diff --git a/src/syntax_kinds.rs b/src/syntax_kinds.rs
index 501b940bb..dc287f0f4 100644
--- a/src/syntax_kinds.rs
+++ b/src/syntax_kinds.rs
@@ -112,6 +112,7 @@ pub enum SyntaxKind {
112 ALIAS, 112 ALIAS,
113 VISIBILITY, 113 VISIBILITY,
114 TYPE_PARAM_LIST, 114 TYPE_PARAM_LIST,
115 WHERE_CLAUSE,
115 LIFETIME_PARAM, 116 LIFETIME_PARAM,
116 TYPE_PARAM, 117 TYPE_PARAM,
117 ABI, 118 ABI,
@@ -234,6 +235,7 @@ impl SyntaxKind {
234 ALIAS => &SyntaxInfo { name: "ALIAS" }, 235 ALIAS => &SyntaxInfo { name: "ALIAS" },
235 VISIBILITY => &SyntaxInfo { name: "VISIBILITY" }, 236 VISIBILITY => &SyntaxInfo { name: "VISIBILITY" },
236 TYPE_PARAM_LIST => &SyntaxInfo { name: "TYPE_PARAM_LIST" }, 237 TYPE_PARAM_LIST => &SyntaxInfo { name: "TYPE_PARAM_LIST" },
238 WHERE_CLAUSE => &SyntaxInfo { name: "WHERE_CLAUSE" },
237 LIFETIME_PARAM => &SyntaxInfo { name: "LIFETIME_PARAM" }, 239 LIFETIME_PARAM => &SyntaxInfo { name: "LIFETIME_PARAM" },
238 TYPE_PARAM => &SyntaxInfo { name: "TYPE_PARAM" }, 240 TYPE_PARAM => &SyntaxInfo { name: "TYPE_PARAM" },
239 ABI => &SyntaxInfo { name: "ABI" }, 241 ABI => &SyntaxInfo { name: "ABI" },
diff --git a/tests/data/parser/inline/0016_type_item_where_clause.txt b/tests/data/parser/inline/0016_type_item_where_clause.txt
index 28fcc7c0a..ddd335870 100644
--- a/tests/data/parser/inline/0016_type_item_where_clause.txt
+++ b/tests/data/parser/inline/0016_type_item_where_clause.txt
@@ -3,14 +3,15 @@ FILE@[0; 31)
3 TYPE_KW@[0; 4) 3 TYPE_KW@[0; 4)
4 WHITESPACE@[4; 5) 4 WHITESPACE@[4; 5)
5 IDENT@[5; 8) "Foo" 5 IDENT@[5; 8) "Foo"
6 WHITESPACE@[8; 9) 6 WHERE_CLAUSE@[8; 25)
7 WHERE_KW@[9; 14) 7 WHITESPACE@[8; 9)
8 WHITESPACE@[14; 15) 8 WHERE_KW@[9; 14)
9 IDENT@[15; 18) "Foo" 9 WHITESPACE@[14; 15)
10 COLON@[18; 19) 10 IDENT@[15; 18) "Foo"
11 WHITESPACE@[19; 20) 11 COLON@[18; 19)
12 IDENT@[20; 24) "Copy" 12 WHITESPACE@[19; 20)
13 WHITESPACE@[24; 25) 13 IDENT@[20; 24) "Copy"
14 WHITESPACE@[24; 25)
14 EQ@[25; 26) 15 EQ@[25; 26)
15 WHITESPACE@[26; 27) 16 WHITESPACE@[26; 27)
16 L_PAREN@[27; 28) 17 L_PAREN@[27; 28)