diff options
-rw-r--r-- | src/grammar/expressions.rs | 11 | ||||
-rw-r--r-- | tests/data/parser/inline/0051_method_call_expr.txt | 6 | ||||
-rw-r--r-- | tests/data/parser/inline/0052_field_expr.txt | 6 |
3 files changed, 16 insertions, 7 deletions
diff --git a/src/grammar/expressions.rs b/src/grammar/expressions.rs index 06f9105c6..00a0ec953 100644 --- a/src/grammar/expressions.rs +++ b/src/grammar/expressions.rs | |||
@@ -39,6 +39,7 @@ pub(super) fn expr(p: &mut Parser) { | |||
39 | } else { | 39 | } else { |
40 | field_expr(p, lhs) | 40 | field_expr(p, lhs) |
41 | }, | 41 | }, |
42 | DOT if p.nth(1) == INT_NUMBER => field_expr(p, lhs), | ||
42 | _ => break, | 43 | _ => break, |
43 | } | 44 | } |
44 | } | 45 | } |
@@ -202,7 +203,7 @@ fn method_call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { | |||
202 | assert!(p.at(DOT) && p.nth(1) == IDENT && p.nth(2) == L_PAREN); | 203 | assert!(p.at(DOT) && p.nth(1) == IDENT && p.nth(2) == L_PAREN); |
203 | let m = lhs.precede(p); | 204 | let m = lhs.precede(p); |
204 | p.bump(); | 205 | p.bump(); |
205 | p.bump(); | 206 | name_ref(p); |
206 | arg_list(p); | 207 | arg_list(p); |
207 | m.complete(p, METHOD_CALL_EXPR) | 208 | m.complete(p, METHOD_CALL_EXPR) |
208 | } | 209 | } |
@@ -212,10 +213,14 @@ fn method_call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { | |||
212 | // x.foo.bar; | 213 | // x.foo.bar; |
213 | // } | 214 | // } |
214 | fn field_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { | 215 | fn field_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { |
215 | assert!(p.at(DOT) && p.nth(1) == IDENT); | 216 | assert!(p.at(DOT) && (p.nth(1) == IDENT || p.nth(1) == INT_NUMBER)); |
216 | let m = lhs.precede(p); | 217 | let m = lhs.precede(p); |
217 | p.bump(); | 218 | p.bump(); |
218 | p.bump(); | 219 | if p.at(IDENT) { |
220 | name_ref(p) | ||
221 | } else { | ||
222 | p.bump() | ||
223 | } | ||
219 | m.complete(p, FIELD_EXPR) | 224 | m.complete(p, FIELD_EXPR) |
220 | } | 225 | } |
221 | 226 | ||
diff --git a/tests/data/parser/inline/0051_method_call_expr.txt b/tests/data/parser/inline/0051_method_call_expr.txt index 69e13bd2a..5345e5fbd 100644 --- a/tests/data/parser/inline/0051_method_call_expr.txt +++ b/tests/data/parser/inline/0051_method_call_expr.txt | |||
@@ -19,7 +19,8 @@ FILE@[0; 44) | |||
19 | WHITESPACE@[10; 15) | 19 | WHITESPACE@[10; 15) |
20 | IDENT@[15; 16) "x" | 20 | IDENT@[15; 16) "x" |
21 | DOT@[16; 17) | 21 | DOT@[16; 17) |
22 | IDENT@[17; 20) "foo" | 22 | NAME_REF@[17; 20) |
23 | IDENT@[17; 20) "foo" | ||
23 | ARG_LIST@[20; 22) | 24 | ARG_LIST@[20; 22) |
24 | L_PAREN@[20; 21) | 25 | L_PAREN@[20; 21) |
25 | R_PAREN@[21; 22) | 26 | R_PAREN@[21; 22) |
@@ -33,7 +34,8 @@ FILE@[0; 44) | |||
33 | NAME_REF@[28; 29) | 34 | NAME_REF@[28; 29) |
34 | IDENT@[28; 29) "y" | 35 | IDENT@[28; 29) "y" |
35 | DOT@[29; 30) | 36 | DOT@[29; 30) |
36 | IDENT@[30; 33) "bar" | 37 | NAME_REF@[30; 33) |
38 | IDENT@[30; 33) "bar" | ||
37 | ARG_LIST@[33; 40) | 39 | ARG_LIST@[33; 40) |
38 | L_PAREN@[33; 34) | 40 | L_PAREN@[33; 34) |
39 | LITERAL@[34; 35) | 41 | LITERAL@[34; 35) |
diff --git a/tests/data/parser/inline/0052_field_expr.txt b/tests/data/parser/inline/0052_field_expr.txt index 0ef2c5836..78ea3a1f4 100644 --- a/tests/data/parser/inline/0052_field_expr.txt +++ b/tests/data/parser/inline/0052_field_expr.txt | |||
@@ -20,9 +20,11 @@ FILE@[0; 28) | |||
20 | WHITESPACE@[10; 15) | 20 | WHITESPACE@[10; 15) |
21 | IDENT@[15; 16) "x" | 21 | IDENT@[15; 16) "x" |
22 | DOT@[16; 17) | 22 | DOT@[16; 17) |
23 | IDENT@[17; 20) "foo" | 23 | NAME_REF@[17; 20) |
24 | IDENT@[17; 20) "foo" | ||
24 | DOT@[20; 21) | 25 | DOT@[20; 21) |
25 | IDENT@[21; 24) "bar" | 26 | NAME_REF@[21; 24) |
27 | IDENT@[21; 24) "bar" | ||
26 | SEMI@[24; 25) | 28 | SEMI@[24; 25) |
27 | WHITESPACE@[25; 26) | 29 | WHITESPACE@[25; 26) |
28 | R_CURLY@[26; 27) | 30 | R_CURLY@[26; 27) |