aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/grammar/expressions/mod.rs31
-rw-r--r--src/yellow/red.rs1
-rw-r--r--tests/data/parser/inline/0051_method_call_expr.rs2
-rw-r--r--tests/data/parser/inline/0051_method_call_expr.txt48
4 files changed, 48 insertions, 34 deletions
diff --git a/src/grammar/expressions/mod.rs b/src/grammar/expressions/mod.rs
index baff0da52..4421a444c 100644
--- a/src/grammar/expressions/mod.rs
+++ b/src/grammar/expressions/mod.rs
@@ -35,7 +35,7 @@ struct Restrictions {
35 35
36enum Op { 36enum Op {
37 Simple, 37 Simple,
38 Composite(SyntaxKind, u8) 38 Composite(SyntaxKind, u8),
39} 39}
40 40
41// test expr_binding_power 41// test expr_binding_power
@@ -52,16 +52,16 @@ enum Op {
52// } 52// }
53fn current_op(p: &Parser) -> (u8, Op) { 53fn current_op(p: &Parser) -> (u8, Op) {
54 if p.at_compound2(L_ANGLE, EQ) { 54 if p.at_compound2(L_ANGLE, EQ) {
55 return (2, Op::Composite(LTEQ, 2)) 55 return (2, Op::Composite(LTEQ, 2));
56 } 56 }
57 if p.at_compound2(R_ANGLE, EQ) { 57 if p.at_compound2(R_ANGLE, EQ) {
58 return (2, Op::Composite(GTEQ, 2)) 58 return (2, Op::Composite(GTEQ, 2));
59 } 59 }
60 if p.at_compound2(PLUS, EQ) { 60 if p.at_compound2(PLUS, EQ) {
61 return (1, Op::Composite(PLUSEQ, 2)) 61 return (1, Op::Composite(PLUSEQ, 2));
62 } 62 }
63 if p.at_compound2(MINUS, EQ) { 63 if p.at_compound2(MINUS, EQ) {
64 return (1, Op::Composite(MINUSEQ, 2)) 64 return (1, Op::Composite(MINUSEQ, 2));
65 } 65 }
66 66
67 let bp = match p.current() { 67 let bp = match p.current() {
@@ -90,7 +90,7 @@ fn expr_bp(p: &mut Parser, r: Restrictions, bp: u8) {
90 Op::Simple => p.bump(), 90 Op::Simple => p.bump(),
91 Op::Composite(kind, n) => { 91 Op::Composite(kind, n) => {
92 p.bump_compound(kind, n); 92 p.bump_compound(kind, n);
93 }, 93 }
94 } 94 }
95 lhs = bin_expr(p, r, lhs, op_bp); 95 lhs = bin_expr(p, r, lhs, op_bp);
96 } 96 }
@@ -115,8 +115,7 @@ fn unary_expr(p: &mut Parser, r: Restrictions) -> Option<CompletedMarker> {
115 p.bump(); 115 p.bump();
116 p.eat(MUT_KW); 116 p.eat(MUT_KW);
117 REF_EXPR 117 REF_EXPR
118 118 }
119 },
120 // test deref_expr 119 // test deref_expr
121 // fn foo() { 120 // fn foo() {
122 // **&1; 121 // **&1;
@@ -125,7 +124,7 @@ fn unary_expr(p: &mut Parser, r: Restrictions) -> Option<CompletedMarker> {
125 m = p.start(); 124 m = p.start();
126 p.bump(); 125 p.bump();
127 DEREF_EXPR 126 DEREF_EXPR
128 }, 127 }
129 // test not_expr 128 // test not_expr
130 // fn foo() { 129 // fn foo() {
131 // !!true; 130 // !!true;
@@ -134,10 +133,10 @@ fn unary_expr(p: &mut Parser, r: Restrictions) -> Option<CompletedMarker> {
134 m = p.start(); 133 m = p.start();
135 p.bump(); 134 p.bump();
136 NOT_EXPR 135 NOT_EXPR
137 }, 136 }
138 _ => { 137 _ => {
139 let lhs = atom::atom_expr(p, r)?; 138 let lhs = atom::atom_expr(p, r)?;
140 return Some(postfix_expr(p, lhs)) 139 return Some(postfix_expr(p, lhs));
141 } 140 }
142 }; 141 };
143 unary_expr(p, r); 142 unary_expr(p, r);
@@ -148,7 +147,7 @@ fn postfix_expr(p: &mut Parser, mut lhs: CompletedMarker) -> CompletedMarker {
148 loop { 147 loop {
149 lhs = match p.current() { 148 lhs = match p.current() {
150 L_PAREN => call_expr(p, lhs), 149 L_PAREN => call_expr(p, lhs),
151 DOT if p.nth(1) == IDENT => if p.nth(2) == L_PAREN { 150 DOT if p.nth(1) == IDENT => if p.nth(2) == L_PAREN || p.nth(2) == COLONCOLON {
152 method_call_expr(p, lhs) 151 method_call_expr(p, lhs)
153 } else { 152 } else {
154 field_expr(p, lhs) 153 field_expr(p, lhs)
@@ -176,13 +175,17 @@ fn call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
176// test method_call_expr 175// test method_call_expr
177// fn foo() { 176// fn foo() {
178// x.foo(); 177// x.foo();
179// y.bar(1, 2,); 178// y.bar::<T>(1, 2,);
180// } 179// }
181fn method_call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { 180fn method_call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
182 assert!(p.at(DOT) && p.nth(1) == IDENT && p.nth(2) == L_PAREN); 181 assert!(
182 p.at(DOT) && p.nth(1) == IDENT
183 && (p.nth(2) == L_PAREN || p.nth(2) == COLONCOLON)
184 );
183 let m = lhs.precede(p); 185 let m = lhs.precede(p);
184 p.bump(); 186 p.bump();
185 name_ref(p); 187 name_ref(p);
188 type_args::type_arg_list(p, true);
186 arg_list(p); 189 arg_list(p);
187 m.complete(p, METHOD_CALL_EXPR) 190 m.complete(p, METHOD_CALL_EXPR)
188} 191}
diff --git a/src/yellow/red.rs b/src/yellow/red.rs
index e124fc76e..91c4cd77f 100644
--- a/src/yellow/red.rs
+++ b/src/yellow/red.rs
@@ -1,4 +1,5 @@
1use std::ptr; 1use std::ptr;
2
2use parking_lot::RwLock; 3use parking_lot::RwLock;
3use {yellow::GreenNode, TextUnit}; 4use {yellow::GreenNode, TextUnit};
4 5
diff --git a/tests/data/parser/inline/0051_method_call_expr.rs b/tests/data/parser/inline/0051_method_call_expr.rs
index 236d94e88..1a3aa35ae 100644
--- a/tests/data/parser/inline/0051_method_call_expr.rs
+++ b/tests/data/parser/inline/0051_method_call_expr.rs
@@ -1,4 +1,4 @@
1fn foo() { 1fn foo() {
2 x.foo(); 2 x.foo();
3 y.bar(1, 2,); 3 y.bar::<T>(1, 2,);
4} 4}
diff --git a/tests/data/parser/inline/0051_method_call_expr.txt b/tests/data/parser/inline/0051_method_call_expr.txt
index bf3705878..598056c88 100644
--- a/tests/data/parser/inline/0051_method_call_expr.txt
+++ b/tests/data/parser/inline/0051_method_call_expr.txt
@@ -1,5 +1,5 @@
1FILE@[0; 44) 1FILE@[0; 49)
2 FN_ITEM@[0; 44) 2 FN_ITEM@[0; 49)
3 FN_KW@[0; 2) 3 FN_KW@[0; 2)
4 NAME@[2; 6) 4 NAME@[2; 6)
5 WHITESPACE@[2; 3) 5 WHITESPACE@[2; 3)
@@ -8,7 +8,7 @@ FILE@[0; 44)
8 L_PAREN@[6; 7) 8 L_PAREN@[6; 7)
9 R_PAREN@[7; 8) 9 R_PAREN@[7; 8)
10 WHITESPACE@[8; 9) 10 WHITESPACE@[8; 9)
11 BLOCK_EXPR@[9; 44) 11 BLOCK_EXPR@[9; 49)
12 L_CURLY@[9; 10) 12 L_CURLY@[9; 10)
13 EXPR_STMT@[10; 28) 13 EXPR_STMT@[10; 28)
14 METHOD_CALL_EXPR@[10; 22) 14 METHOD_CALL_EXPR@[10; 22)
@@ -26,8 +26,8 @@ FILE@[0; 44)
26 R_PAREN@[21; 22) 26 R_PAREN@[21; 22)
27 SEMI@[22; 23) 27 SEMI@[22; 23)
28 WHITESPACE@[23; 28) 28 WHITESPACE@[23; 28)
29 EXPR_STMT@[28; 42) 29 EXPR_STMT@[28; 47)
30 METHOD_CALL_EXPR@[28; 40) 30 METHOD_CALL_EXPR@[28; 45)
31 PATH_EXPR@[28; 29) 31 PATH_EXPR@[28; 29)
32 PATH@[28; 29) 32 PATH@[28; 29)
33 PATH_SEGMENT@[28; 29) 33 PATH_SEGMENT@[28; 29)
@@ -36,17 +36,27 @@ FILE@[0; 44)
36 DOT@[29; 30) 36 DOT@[29; 30)
37 NAME_REF@[30; 33) 37 NAME_REF@[30; 33)
38 IDENT@[30; 33) "bar" 38 IDENT@[30; 33) "bar"
39 ARG_LIST@[33; 40) 39 TYPE_ARG_LIST@[33; 38)
40 L_PAREN@[33; 34) 40 COLONCOLON@[33; 35)
41 LITERAL@[34; 35) 41 L_ANGLE@[35; 36)
42 INT_NUMBER@[34; 35) "1" 42 TYPE_ARG@[36; 37)
43 COMMA@[35; 36) 43 PATH_TYPE@[36; 37)
44 LITERAL@[36; 38) 44 PATH@[36; 37)
45 WHITESPACE@[36; 37) 45 PATH_SEGMENT@[36; 37)
46 INT_NUMBER@[37; 38) "2" 46 NAME_REF@[36; 37)
47 COMMA@[38; 39) 47 IDENT@[36; 37) "T"
48 R_PAREN@[39; 40) 48 R_ANGLE@[37; 38)
49 SEMI@[40; 41) 49 ARG_LIST@[38; 45)
50 WHITESPACE@[41; 42) 50 L_PAREN@[38; 39)
51 R_CURLY@[42; 43) 51 LITERAL@[39; 40)
52 WHITESPACE@[43; 44) 52 INT_NUMBER@[39; 40) "1"
53 COMMA@[40; 41)
54 LITERAL@[41; 43)
55 WHITESPACE@[41; 42)
56 INT_NUMBER@[42; 43) "2"
57 COMMA@[43; 44)
58 R_PAREN@[44; 45)
59 SEMI@[45; 46)
60 WHITESPACE@[46; 47)
61 R_CURLY@[47; 48)
62 WHITESPACE@[48; 49)