aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src/grammar
diff options
context:
space:
mode:
authorDmitry <[email protected]>2020-08-09 14:35:51 +0100
committerDmitry <[email protected]>2020-08-09 14:39:32 +0100
commit8068302fefc75440b823f4bf1731a5f347d7c767 (patch)
tree251b967182e79bc82a58c2fb208c688f6152df1f /crates/ra_parser/src/grammar
parent1a43a0f63e0008787225abb6fb2baef97b6a39e0 (diff)
parent8a57afe5a4bfab40072a83f7dc4ca560bf860919 (diff)
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'crates/ra_parser/src/grammar')
-rw-r--r--crates/ra_parser/src/grammar/expressions.rs6
-rw-r--r--crates/ra_parser/src/grammar/expressions/atom.rs2
-rw-r--r--crates/ra_parser/src/grammar/items.rs18
-rw-r--r--crates/ra_parser/src/grammar/items/adt.rs18
-rw-r--r--crates/ra_parser/src/grammar/items/consts.rs4
-rw-r--r--crates/ra_parser/src/grammar/items/traits.rs4
-rw-r--r--crates/ra_parser/src/grammar/items/use_item.rs2
-rw-r--r--crates/ra_parser/src/grammar/patterns.rs12
-rw-r--r--crates/ra_parser/src/grammar/type_args.rs4
-rw-r--r--crates/ra_parser/src/grammar/type_params.rs2
-rw-r--r--crates/ra_parser/src/grammar/types.rs8
11 files changed, 43 insertions, 37 deletions
diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs
index 6e72eea66..e1c25a838 100644
--- a/crates/ra_parser/src/grammar/expressions.rs
+++ b/crates/ra_parser/src/grammar/expressions.rs
@@ -587,7 +587,7 @@ fn path_expr(p: &mut Parser, r: Restrictions) -> (CompletedMarker, BlockLike) {
587 match p.current() { 587 match p.current() {
588 T!['{'] if !r.forbid_structs => { 588 T!['{'] if !r.forbid_structs => {
589 record_field_list(p); 589 record_field_list(p);
590 (m.complete(p, RECORD_LIT), BlockLike::NotBlock) 590 (m.complete(p, RECORD_EXPR), BlockLike::NotBlock)
591 } 591 }
592 T![!] if !p.at(T![!=]) => { 592 T![!] if !p.at(T![!=]) => {
593 let block_like = items::macro_call_after_excl(p); 593 let block_like = items::macro_call_after_excl(p);
@@ -627,7 +627,7 @@ pub(crate) fn record_field_list(p: &mut Parser) {
627 p.expect(T![:]); 627 p.expect(T![:]);
628 } 628 }
629 expr(p); 629 expr(p);
630 m.complete(p, RECORD_FIELD); 630 m.complete(p, RECORD_EXPR_FIELD);
631 } 631 }
632 T![.] if p.at(T![..]) => { 632 T![.] if p.at(T![..]) => {
633 m.abandon(p); 633 m.abandon(p);
@@ -648,5 +648,5 @@ pub(crate) fn record_field_list(p: &mut Parser) {
648 } 648 }
649 } 649 }
650 p.expect(T!['}']); 650 p.expect(T!['}']);
651 m.complete(p, RECORD_FIELD_LIST); 651 m.complete(p, RECORD_EXPR_FIELD_LIST);
652} 652}
diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs
index 706a2f796..0b01d3bc6 100644
--- a/crates/ra_parser/src/grammar/expressions/atom.rs
+++ b/crates/ra_parser/src/grammar/expressions/atom.rs
@@ -250,7 +250,7 @@ fn lambda_expr(p: &mut Parser) -> CompletedMarker {
250 p.error("expected expression"); 250 p.error("expected expression");
251 } 251 }
252 } 252 }
253 m.complete(p, LAMBDA_EXPR) 253 m.complete(p, CLOSURE_EXPR)
254} 254}
255 255
256// test if_expr 256// test if_expr
diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/ra_parser/src/grammar/items.rs
index 97642bc24..cca524cea 100644
--- a/crates/ra_parser/src/grammar/items.rs
+++ b/crates/ra_parser/src/grammar/items.rs
@@ -180,7 +180,7 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
180 // unsafe const fn bar() {} 180 // unsafe const fn bar() {}
181 T![fn] => { 181 T![fn] => {
182 fn_def(p); 182 fn_def(p);
183 m.complete(p, FN_DEF); 183 m.complete(p, FN);
184 } 184 }
185 185
186 // test unsafe_trait 186 // test unsafe_trait
@@ -193,7 +193,7 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
193 // unsafe auto trait T {} 193 // unsafe auto trait T {}
194 T![trait] => { 194 T![trait] => {
195 traits::trait_def(p); 195 traits::trait_def(p);
196 m.complete(p, TRAIT_DEF); 196 m.complete(p, TRAIT);
197 } 197 }
198 198
199 // test unsafe_impl 199 // test unsafe_impl
@@ -221,7 +221,7 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
221 // unsafe default impl Foo {} 221 // unsafe default impl Foo {}
222 T![impl] => { 222 T![impl] => {
223 traits::impl_def(p); 223 traits::impl_def(p);
224 m.complete(p, IMPL_DEF); 224 m.complete(p, IMPL);
225 } 225 }
226 226
227 // test existential_type 227 // test existential_type
@@ -304,10 +304,16 @@ fn extern_crate_item(p: &mut Parser, m: Marker) {
304 p.bump(T![extern]); 304 p.bump(T![extern]);
305 assert!(p.at(T![crate])); 305 assert!(p.at(T![crate]));
306 p.bump(T![crate]); 306 p.bump(T![crate]);
307 name_ref(p); 307
308 if p.at(T![self]) {
309 p.bump(T![self]);
310 } else {
311 name_ref(p);
312 }
313
308 opt_alias(p); 314 opt_alias(p);
309 p.expect(T![;]); 315 p.expect(T![;]);
310 m.complete(p, EXTERN_CRATE_ITEM); 316 m.complete(p, EXTERN_CRATE);
311} 317}
312 318
313pub(crate) fn extern_item_list(p: &mut Parser) { 319pub(crate) fn extern_item_list(p: &mut Parser) {
@@ -374,7 +380,7 @@ fn type_def(p: &mut Parser, m: Marker) {
374 types::type_(p); 380 types::type_(p);
375 } 381 }
376 p.expect(T![;]); 382 p.expect(T![;]);
377 m.complete(p, TYPE_ALIAS_DEF); 383 m.complete(p, TYPE_ALIAS);
378} 384}
379 385
380pub(crate) fn mod_item(p: &mut Parser, m: Marker) { 386pub(crate) fn mod_item(p: &mut Parser, m: Marker) {
diff --git a/crates/ra_parser/src/grammar/items/adt.rs b/crates/ra_parser/src/grammar/items/adt.rs
index 74b9f514b..addfb59d4 100644
--- a/crates/ra_parser/src/grammar/items/adt.rs
+++ b/crates/ra_parser/src/grammar/items/adt.rs
@@ -5,13 +5,13 @@ use super::*;
5pub(super) fn struct_def(p: &mut Parser, m: Marker) { 5pub(super) fn struct_def(p: &mut Parser, m: Marker) {
6 assert!(p.at(T![struct])); 6 assert!(p.at(T![struct]));
7 p.bump(T![struct]); 7 p.bump(T![struct]);
8 struct_or_union(p, m, T![struct], STRUCT_DEF); 8 struct_or_union(p, m, T![struct], STRUCT);
9} 9}
10 10
11pub(super) fn union_def(p: &mut Parser, m: Marker) { 11pub(super) fn union_def(p: &mut Parser, m: Marker) {
12 assert!(p.at_contextual_kw("union")); 12 assert!(p.at_contextual_kw("union"));
13 p.bump_remap(T![union]); 13 p.bump_remap(T![union]);
14 struct_or_union(p, m, T![union], UNION_DEF); 14 struct_or_union(p, m, T![union], UNION);
15} 15}
16 16
17fn struct_or_union(p: &mut Parser, m: Marker, kw: SyntaxKind, def: SyntaxKind) { 17fn struct_or_union(p: &mut Parser, m: Marker, kw: SyntaxKind, def: SyntaxKind) {
@@ -64,7 +64,7 @@ pub(super) fn enum_def(p: &mut Parser, m: Marker) {
64 } else { 64 } else {
65 p.error("expected `{`") 65 p.error("expected `{`")
66 } 66 }
67 m.complete(p, ENUM_DEF); 67 m.complete(p, ENUM);
68} 68}
69 69
70pub(crate) fn enum_variant_list(p: &mut Parser) { 70pub(crate) fn enum_variant_list(p: &mut Parser) {
@@ -91,7 +91,7 @@ pub(crate) fn enum_variant_list(p: &mut Parser) {
91 if p.eat(T![=]) { 91 if p.eat(T![=]) {
92 expressions::expr(p); 92 expressions::expr(p);
93 } 93 }
94 var.complete(p, ENUM_VARIANT); 94 var.complete(p, VARIANT);
95 } else { 95 } else {
96 var.abandon(p); 96 var.abandon(p);
97 p.err_and_bump("expected enum variant"); 97 p.err_and_bump("expected enum variant");
@@ -101,7 +101,7 @@ pub(crate) fn enum_variant_list(p: &mut Parser) {
101 } 101 }
102 } 102 }
103 p.expect(T!['}']); 103 p.expect(T!['}']);
104 m.complete(p, ENUM_VARIANT_LIST); 104 m.complete(p, VARIANT_LIST);
105} 105}
106 106
107pub(crate) fn record_field_def_list(p: &mut Parser) { 107pub(crate) fn record_field_def_list(p: &mut Parser) {
@@ -119,7 +119,7 @@ pub(crate) fn record_field_def_list(p: &mut Parser) {
119 } 119 }
120 } 120 }
121 p.expect(T!['}']); 121 p.expect(T!['}']);
122 m.complete(p, RECORD_FIELD_DEF_LIST); 122 m.complete(p, RECORD_FIELD_LIST);
123 123
124 fn record_field_def(p: &mut Parser) { 124 fn record_field_def(p: &mut Parser) {
125 let m = p.start(); 125 let m = p.start();
@@ -134,7 +134,7 @@ pub(crate) fn record_field_def_list(p: &mut Parser) {
134 name(p); 134 name(p);
135 p.expect(T![:]); 135 p.expect(T![:]);
136 types::type_(p); 136 types::type_(p);
137 m.complete(p, RECORD_FIELD_DEF); 137 m.complete(p, RECORD_FIELD);
138 } else { 138 } else {
139 m.abandon(p); 139 m.abandon(p);
140 p.err_and_bump("expected field declaration"); 140 p.err_and_bump("expected field declaration");
@@ -167,12 +167,12 @@ fn tuple_field_def_list(p: &mut Parser) {
167 break; 167 break;
168 } 168 }
169 types::type_(p); 169 types::type_(p);
170 m.complete(p, TUPLE_FIELD_DEF); 170 m.complete(p, TUPLE_FIELD);
171 171
172 if !p.at(T![')']) { 172 if !p.at(T![')']) {
173 p.expect(T![,]); 173 p.expect(T![,]);
174 } 174 }
175 } 175 }
176 p.expect(T![')']); 176 p.expect(T![')']);
177 m.complete(p, TUPLE_FIELD_DEF_LIST); 177 m.complete(p, TUPLE_FIELD_LIST);
178} 178}
diff --git a/crates/ra_parser/src/grammar/items/consts.rs b/crates/ra_parser/src/grammar/items/consts.rs
index 742a7e056..35ad766dc 100644
--- a/crates/ra_parser/src/grammar/items/consts.rs
+++ b/crates/ra_parser/src/grammar/items/consts.rs
@@ -3,11 +3,11 @@
3use super::*; 3use super::*;
4 4
5pub(super) fn static_def(p: &mut Parser, m: Marker) { 5pub(super) fn static_def(p: &mut Parser, m: Marker) {
6 const_or_static(p, m, T![static], STATIC_DEF) 6 const_or_static(p, m, T![static], STATIC)
7} 7}
8 8
9pub(super) fn const_def(p: &mut Parser, m: Marker) { 9pub(super) fn const_def(p: &mut Parser, m: Marker) {
10 const_or_static(p, m, T![const], CONST_DEF) 10 const_or_static(p, m, T![const], CONST)
11} 11}
12 12
13fn const_or_static(p: &mut Parser, m: Marker, kw: SyntaxKind, def: SyntaxKind) { 13fn const_or_static(p: &mut Parser, m: Marker, kw: SyntaxKind, def: SyntaxKind) {
diff --git a/crates/ra_parser/src/grammar/items/traits.rs b/crates/ra_parser/src/grammar/items/traits.rs
index c819e33be..ef9c8ff5b 100644
--- a/crates/ra_parser/src/grammar/items/traits.rs
+++ b/crates/ra_parser/src/grammar/items/traits.rs
@@ -50,7 +50,7 @@ pub(crate) fn trait_item_list(p: &mut Parser) {
50 item_or_macro(p, true, ItemFlavor::Trait); 50 item_or_macro(p, true, ItemFlavor::Trait);
51 } 51 }
52 p.expect(T!['}']); 52 p.expect(T!['}']);
53 m.complete(p, ITEM_LIST); 53 m.complete(p, ASSOC_ITEM_LIST);
54} 54}
55 55
56// test impl_def 56// test impl_def
@@ -107,7 +107,7 @@ pub(crate) fn impl_item_list(p: &mut Parser) {
107 item_or_macro(p, true, ItemFlavor::Mod); 107 item_or_macro(p, true, ItemFlavor::Mod);
108 } 108 }
109 p.expect(T!['}']); 109 p.expect(T!['}']);
110 m.complete(p, ITEM_LIST); 110 m.complete(p, ASSOC_ITEM_LIST);
111} 111}
112 112
113// test impl_type_params 113// test impl_type_params
diff --git a/crates/ra_parser/src/grammar/items/use_item.rs b/crates/ra_parser/src/grammar/items/use_item.rs
index 3a0c7a31a..8e836a77e 100644
--- a/crates/ra_parser/src/grammar/items/use_item.rs
+++ b/crates/ra_parser/src/grammar/items/use_item.rs
@@ -7,7 +7,7 @@ pub(super) fn use_item(p: &mut Parser, m: Marker) {
7 p.bump(T![use]); 7 p.bump(T![use]);
8 use_tree(p, true); 8 use_tree(p, true);
9 p.expect(T![;]); 9 p.expect(T![;]);
10 m.complete(p, USE_ITEM); 10 m.complete(p, USE);
11} 11}
12 12
13/// Parse a use 'tree', such as `some::path` in `use some::path;` 13/// Parse a use 'tree', such as `some::path` in `use some::path;`
diff --git a/crates/ra_parser/src/grammar/patterns.rs b/crates/ra_parser/src/grammar/patterns.rs
index 427c0eb49..716bdc978 100644
--- a/crates/ra_parser/src/grammar/patterns.rs
+++ b/crates/ra_parser/src/grammar/patterns.rs
@@ -192,7 +192,7 @@ fn record_field_pat_list(p: &mut Parser) {
192 p.bump(T!['{']); 192 p.bump(T!['{']);
193 while !p.at(EOF) && !p.at(T!['}']) { 193 while !p.at(EOF) && !p.at(T!['}']) {
194 match p.current() { 194 match p.current() {
195 // A trailing `..` is *not* treated as a DOT_DOT_PAT. 195 // A trailing `..` is *not* treated as a REST_PAT.
196 T![.] if p.at(T![..]) => p.bump(T![..]), 196 T![.] if p.at(T![..]) => p.bump(T![..]),
197 T!['{'] => error_block(p, "expected ident"), 197 T!['{'] => error_block(p, "expected ident"),
198 198
@@ -217,7 +217,7 @@ fn record_field_pat_list(p: &mut Parser) {
217 bind_pat(p, false); 217 bind_pat(p, false);
218 } 218 }
219 } 219 }
220 m.complete(p, RECORD_FIELD_PAT); 220 m.complete(p, RECORD_PAT_FIELD);
221 } 221 }
222 } 222 }
223 if !p.at(T!['}']) { 223 if !p.at(T!['}']) {
@@ -225,7 +225,7 @@ fn record_field_pat_list(p: &mut Parser) {
225 } 225 }
226 } 226 }
227 p.expect(T!['}']); 227 p.expect(T!['}']);
228 m.complete(p, RECORD_FIELD_PAT_LIST); 228 m.complete(p, RECORD_PAT_FIELD_LIST);
229} 229}
230 230
231// test placeholder_pat 231// test placeholder_pat
@@ -234,7 +234,7 @@ fn placeholder_pat(p: &mut Parser) -> CompletedMarker {
234 assert!(p.at(T![_])); 234 assert!(p.at(T![_]));
235 let m = p.start(); 235 let m = p.start();
236 p.bump(T![_]); 236 p.bump(T![_]);
237 m.complete(p, PLACEHOLDER_PAT) 237 m.complete(p, WILDCARD_PAT)
238} 238}
239 239
240// test dot_dot_pat 240// test dot_dot_pat
@@ -267,7 +267,7 @@ fn dot_dot_pat(p: &mut Parser) -> CompletedMarker {
267 assert!(p.at(T![..])); 267 assert!(p.at(T![..]));
268 let m = p.start(); 268 let m = p.start();
269 p.bump(T![..]); 269 p.bump(T![..]);
270 m.complete(p, DOT_DOT_PAT) 270 m.complete(p, REST_PAT)
271} 271}
272 272
273// test ref_pat 273// test ref_pat
@@ -361,7 +361,7 @@ fn bind_pat(p: &mut Parser, with_at: bool) -> CompletedMarker {
361 if with_at && p.eat(T![@]) { 361 if with_at && p.eat(T![@]) {
362 pattern_single(p); 362 pattern_single(p);
363 } 363 }
364 m.complete(p, BIND_PAT) 364 m.complete(p, IDENT_PAT)
365} 365}
366 366
367// test box_pat 367// test box_pat
diff --git a/crates/ra_parser/src/grammar/type_args.rs b/crates/ra_parser/src/grammar/type_args.rs
index 2d61f9d80..aef7cd6fb 100644
--- a/crates/ra_parser/src/grammar/type_args.rs
+++ b/crates/ra_parser/src/grammar/type_args.rs
@@ -22,7 +22,7 @@ pub(super) fn opt_type_arg_list(p: &mut Parser, colon_colon_required: bool) {
22 } 22 }
23 } 23 }
24 p.expect(T![>]); 24 p.expect(T![>]);
25 m.complete(p, TYPE_ARG_LIST); 25 m.complete(p, GENERIC_ARG_LIST);
26} 26}
27 27
28// test type_arg 28// test type_arg
@@ -52,7 +52,7 @@ fn type_arg(p: &mut Parser) {
52 m.complete(p, CONST_ARG); 52 m.complete(p, CONST_ARG);
53 } 53 }
54 k if k.is_literal() => { 54 k if k.is_literal() => {
55 p.bump(k); 55 expressions::literal(p);
56 m.complete(p, CONST_ARG); 56 m.complete(p, CONST_ARG);
57 } 57 }
58 _ => { 58 _ => {
diff --git a/crates/ra_parser/src/grammar/type_params.rs b/crates/ra_parser/src/grammar/type_params.rs
index d1330d4b9..90dabb4c0 100644
--- a/crates/ra_parser/src/grammar/type_params.rs
+++ b/crates/ra_parser/src/grammar/type_params.rs
@@ -36,7 +36,7 @@ fn type_param_list(p: &mut Parser) {
36 } 36 }
37 } 37 }
38 p.expect(T![>]); 38 p.expect(T![>]);
39 m.complete(p, TYPE_PARAM_LIST); 39 m.complete(p, GENERIC_PARAM_LIST);
40} 40}
41 41
42fn lifetime_param(p: &mut Parser, m: Marker) { 42fn lifetime_param(p: &mut Parser, m: Marker) {
diff --git a/crates/ra_parser/src/grammar/types.rs b/crates/ra_parser/src/grammar/types.rs
index 9e8e3bd97..0aa173a52 100644
--- a/crates/ra_parser/src/grammar/types.rs
+++ b/crates/ra_parser/src/grammar/types.rs
@@ -117,7 +117,7 @@ fn pointer_type(p: &mut Parser) {
117 }; 117 };
118 118
119 type_no_bounds(p); 119 type_no_bounds(p);
120 m.complete(p, POINTER_TYPE); 120 m.complete(p, PTR_TYPE);
121} 121}
122 122
123fn array_or_slice_type(p: &mut Parser) { 123fn array_or_slice_type(p: &mut Parser) {
@@ -163,7 +163,7 @@ fn reference_type(p: &mut Parser) {
163 p.eat(LIFETIME); 163 p.eat(LIFETIME);
164 p.eat(T![mut]); 164 p.eat(T![mut]);
165 type_no_bounds(p); 165 type_no_bounds(p);
166 m.complete(p, REFERENCE_TYPE); 166 m.complete(p, REF_TYPE);
167} 167}
168 168
169// test placeholder_type 169// test placeholder_type
@@ -172,7 +172,7 @@ fn placeholder_type(p: &mut Parser) {
172 assert!(p.at(T![_])); 172 assert!(p.at(T![_]));
173 let m = p.start(); 173 let m = p.start();
174 p.bump(T![_]); 174 p.bump(T![_]);
175 m.complete(p, PLACEHOLDER_TYPE); 175 m.complete(p, INFER_TYPE);
176} 176}
177 177
178// test fn_pointer_type 178// test fn_pointer_type
@@ -201,7 +201,7 @@ fn fn_pointer_type(p: &mut Parser) {
201 // test fn_pointer_type_with_ret 201 // test fn_pointer_type_with_ret
202 // type F = fn() -> (); 202 // type F = fn() -> ();
203 opt_fn_ret_type(p); 203 opt_fn_ret_type(p);
204 m.complete(p, FN_POINTER_TYPE); 204 m.complete(p, FN_PTR_TYPE);
205} 205}
206 206
207pub(super) fn for_binder(p: &mut Parser) { 207pub(super) fn for_binder(p: &mut Parser) {