diff options
Diffstat (limited to 'src/grammar')
-rw-r--r-- | src/grammar/expressions.rs | 11 |
1 files changed, 8 insertions, 3 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 | ||