diff options
author | Aleksey Kladov <[email protected]> | 2018-08-05 15:24:44 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-05 15:24:44 +0100 |
commit | 80fa861cd688c8e7c92e27feaf6623ecfaa4901e (patch) | |
tree | 5430bed65025d2d12d52a90c8c035d94a96b62d6 /src/grammar | |
parent | 8cf962f1f56717646af7f67642d2724cb27928d0 (diff) |
index expr
Diffstat (limited to 'src/grammar')
-rw-r--r-- | src/grammar/expressions/mod.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/grammar/expressions/mod.rs b/src/grammar/expressions/mod.rs index 4421a444c..7f3bc78f2 100644 --- a/src/grammar/expressions/mod.rs +++ b/src/grammar/expressions/mod.rs | |||
@@ -147,6 +147,7 @@ fn postfix_expr(p: &mut Parser, mut lhs: CompletedMarker) -> CompletedMarker { | |||
147 | loop { | 147 | loop { |
148 | lhs = match p.current() { | 148 | lhs = match p.current() { |
149 | L_PAREN => call_expr(p, lhs), | 149 | L_PAREN => call_expr(p, lhs), |
150 | L_BRACK => index_expr(p, lhs), | ||
150 | DOT if p.nth(1) == IDENT => if p.nth(2) == L_PAREN || p.nth(2) == COLONCOLON { | 151 | DOT if p.nth(1) == IDENT => if p.nth(2) == L_PAREN || p.nth(2) == COLONCOLON { |
151 | method_call_expr(p, lhs) | 152 | method_call_expr(p, lhs) |
152 | } else { | 153 | } else { |
@@ -172,6 +173,19 @@ fn call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { | |||
172 | m.complete(p, CALL_EXPR) | 173 | m.complete(p, CALL_EXPR) |
173 | } | 174 | } |
174 | 175 | ||
176 | // test index_expr | ||
177 | // fn foo() { | ||
178 | // x[1][2]; | ||
179 | // } | ||
180 | fn index_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { | ||
181 | assert!(p.at(L_BRACK)); | ||
182 | let m = lhs.precede(p); | ||
183 | p.bump(); | ||
184 | expr(p); | ||
185 | p.expect(R_BRACK); | ||
186 | m.complete(p, INDEX_EXPR) | ||
187 | } | ||
188 | |||
175 | // test method_call_expr | 189 | // test method_call_expr |
176 | // fn foo() { | 190 | // fn foo() { |
177 | // x.foo(); | 191 | // x.foo(); |