aboutsummaryrefslogtreecommitdiff
path: root/src/grammar/expressions
diff options
context:
space:
mode:
Diffstat (limited to 'src/grammar/expressions')
-rw-r--r--src/grammar/expressions/mod.rs14
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// }
180fn 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();