From 42e3a8ef77d75cdd0abf4f0729082a112beefb67 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 7 Aug 2018 15:21:15 +0300 Subject: infix range is range --- src/grammar/expressions/mod.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/grammar/expressions/mod.rs b/src/grammar/expressions/mod.rs index a94964c39..55e965ff4 100644 --- a/src/grammar/expressions/mod.rs +++ b/src/grammar/expressions/mod.rs @@ -92,17 +92,20 @@ fn expr_bp(p: &mut Parser, r: Restrictions, bp: u8) { }; loop { + let is_range = p.current() == DOTDOT; let (op_bp, op) = current_op(p); if op_bp < bp { break; } + let m = lhs.precede(p); match op { Op::Simple => p.bump(), Op::Composite(kind, n) => { p.bump_compound(kind, n); } } - lhs = bin_expr(p, r, lhs, op_bp + 1); + expr_bp(p, r, op_bp + 1); + lhs = m.complete(p, if is_range { RANGE_EXPR } else { BIN_EXPR }); } } @@ -330,9 +333,3 @@ fn struct_lit(p: &mut Parser) { } p.expect(R_CURLY); } - -fn bin_expr(p: &mut Parser, r: Restrictions, lhs: CompletedMarker, bp: u8) -> CompletedMarker { - let m = lhs.precede(p); - expr_bp(p, r, bp); - m.complete(p, BIN_EXPR) -} -- cgit v1.2.3