aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_parser/src')
-rw-r--r--crates/ra_parser/src/grammar.rs14
-rw-r--r--crates/ra_parser/src/grammar/expressions.rs10
-rw-r--r--crates/ra_parser/src/grammar/items.rs2
-rw-r--r--crates/ra_parser/src/grammar/paths.rs2
-rw-r--r--crates/ra_parser/src/grammar/type_args.rs4
5 files changed, 20 insertions, 12 deletions
diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs
index 2ee121ccd..beedac457 100644
--- a/crates/ra_parser/src/grammar.rs
+++ b/crates/ra_parser/src/grammar.rs
@@ -273,8 +273,8 @@ fn name(p: &mut Parser) {
273 name_r(p, TokenSet::empty()) 273 name_r(p, TokenSet::empty())
274} 274}
275 275
276fn name_ref(p: &mut Parser, allow_numeric_names: bool) { 276fn name_ref(p: &mut Parser) {
277 if p.at(IDENT) || (allow_numeric_names && p.at(INT_NUMBER)) { 277 if p.at(IDENT) {
278 let m = p.start(); 278 let m = p.start();
279 p.bump(); 279 p.bump();
280 m.complete(p, NAME_REF); 280 m.complete(p, NAME_REF);
@@ -287,6 +287,16 @@ fn name_ref(p: &mut Parser, allow_numeric_names: bool) {
287 } 287 }
288} 288}
289 289
290fn name_ref_or_index(p: &mut Parser) {
291 if p.at(IDENT) || p.at(INT_NUMBER) {
292 let m = p.start();
293 p.bump();
294 m.complete(p, NAME_REF);
295 } else {
296 p.err_and_bump("expected identifier");
297 }
298}
299
290fn error_block(p: &mut Parser, message: &str) { 300fn error_block(p: &mut Parser, message: &str) {
291 assert!(p.at(T!['{'])); 301 assert!(p.at(T!['{']));
292 let m = p.start(); 302 let m = p.start();
diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs
index 9f9e9cb0e..9fd3a235d 100644
--- a/crates/ra_parser/src/grammar/expressions.rs
+++ b/crates/ra_parser/src/grammar/expressions.rs
@@ -458,7 +458,7 @@ fn method_call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
458 assert!(p.at(T![.]) && p.nth(1) == IDENT && (p.nth(2) == T!['('] || p.nth(2) == T![::])); 458 assert!(p.at(T![.]) && p.nth(1) == IDENT && (p.nth(2) == T!['('] || p.nth(2) == T![::]));
459 let m = lhs.precede(p); 459 let m = lhs.precede(p);
460 p.bump(); 460 p.bump();
461 name_ref(p, false); 461 name_ref(p);
462 type_args::opt_type_arg_list(p, true); 462 type_args::opt_type_arg_list(p, true);
463 if p.at(T!['(']) { 463 if p.at(T!['(']) {
464 arg_list(p); 464 arg_list(p);
@@ -484,10 +484,8 @@ fn field_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
484 assert!(p.at(T![.])); 484 assert!(p.at(T![.]));
485 let m = lhs.precede(p); 485 let m = lhs.precede(p);
486 p.bump(); 486 p.bump();
487 if p.at(IDENT) { 487 if p.at(IDENT) || p.at(INT_NUMBER) {
488 name_ref(p, false) 488 name_ref_or_index(p)
489 } else if p.at(INT_NUMBER) {
490 p.bump();
491 } else if p.at(FLOAT_NUMBER) { 489 } else if p.at(FLOAT_NUMBER) {
492 // FIXME: How to recover and instead parse INT + T![.]? 490 // FIXME: How to recover and instead parse INT + T![.]?
493 p.bump(); 491 p.bump();
@@ -587,7 +585,7 @@ pub(crate) fn named_field_list(p: &mut Parser) {
587 IDENT | INT_NUMBER | T![#] => { 585 IDENT | INT_NUMBER | T![#] => {
588 let m = p.start(); 586 let m = p.start();
589 attributes::outer_attributes(p); 587 attributes::outer_attributes(p);
590 name_ref(p, true); 588 name_ref_or_index(p);
591 if p.eat(T![:]) { 589 if p.eat(T![:]) {
592 expr(p); 590 expr(p);
593 } 591 }
diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/ra_parser/src/grammar/items.rs
index b0081f396..543af7c4b 100644
--- a/crates/ra_parser/src/grammar/items.rs
+++ b/crates/ra_parser/src/grammar/items.rs
@@ -279,7 +279,7 @@ fn extern_crate_item(p: &mut Parser, m: Marker) {
279 p.bump(); 279 p.bump();
280 assert!(p.at(T![crate])); 280 assert!(p.at(T![crate]));
281 p.bump(); 281 p.bump();
282 name_ref(p, false); 282 name_ref(p);
283 opt_alias(p); 283 opt_alias(p);
284 p.expect(T![;]); 284 p.expect(T![;]);
285 m.complete(p, EXTERN_CRATE_ITEM); 285 m.complete(p, EXTERN_CRATE_ITEM);
diff --git a/crates/ra_parser/src/grammar/paths.rs b/crates/ra_parser/src/grammar/paths.rs
index 2c8f0f7e8..3537b0da1 100644
--- a/crates/ra_parser/src/grammar/paths.rs
+++ b/crates/ra_parser/src/grammar/paths.rs
@@ -71,7 +71,7 @@ fn path_segment(p: &mut Parser, mode: Mode, first: bool) {
71 } 71 }
72 match p.current() { 72 match p.current() {
73 IDENT => { 73 IDENT => {
74 name_ref(p, false); 74 name_ref(p);
75 opt_path_type_args(p, mode); 75 opt_path_type_args(p, mode);
76 } 76 }
77 // test crate_path 77 // test crate_path
diff --git a/crates/ra_parser/src/grammar/type_args.rs b/crates/ra_parser/src/grammar/type_args.rs
index f1d999dea..3db08b280 100644
--- a/crates/ra_parser/src/grammar/type_args.rs
+++ b/crates/ra_parser/src/grammar/type_args.rs
@@ -38,12 +38,12 @@ fn type_arg(p: &mut Parser) {
38 // test associated_type_bounds 38 // test associated_type_bounds
39 // fn print_all<T: Iterator<Item: Display>>(printables: T) {} 39 // fn print_all<T: Iterator<Item: Display>>(printables: T) {}
40 IDENT if p.nth(1) == T![:] => { 40 IDENT if p.nth(1) == T![:] => {
41 name_ref(p, false); 41 name_ref(p);
42 type_params::bounds(p); 42 type_params::bounds(p);
43 m.complete(p, ASSOC_TYPE_ARG); 43 m.complete(p, ASSOC_TYPE_ARG);
44 } 44 }
45 IDENT if p.nth(1) == T![=] => { 45 IDENT if p.nth(1) == T![=] => {
46 name_ref(p, false); 46 name_ref(p);
47 p.bump(); 47 p.bump();
48 types::type_(p); 48 types::type_(p);
49 m.complete(p, ASSOC_TYPE_ARG); 49 m.complete(p, ASSOC_TYPE_ARG);