From 10e37e27072ac76a4d49e9f4cdaadf19b7552809 Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Wed, 6 May 2020 18:02:13 -0400 Subject: [PATCH] Add dot binary op expression parsing Signed-off-by: Alek Ratzloff --- src/syn/parser.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/syn/parser.rs b/src/syn/parser.rs index 82d25ec..2a56a06 100644 --- a/src/syn/parser.rs +++ b/src/syn/parser.rs @@ -171,6 +171,12 @@ impl<'t> Parser<'t> { bin_expr!( next_bin_mul_expr, &[TokenKind::FSlash, TokenKind::Splat], + next_dot_expr + ); + // . + bin_expr!( + next_dot_expr, + &[TokenKind::Dot], next_un_expr ); @@ -845,6 +851,20 @@ mod test { ) ) ); + + test_parser!( + Parser::try_from("foo.bar().baz(qux)").unwrap(), + next_expr, + bin_expr( + base_expr(BaseExprKind::Ident), + BinOp::Dot, + bin_expr( + fun_call_expr(base_expr(BaseExprKind::Ident), vec![]), + BinOp::Dot, + fun_call_expr(base_expr(BaseExprKind::Ident), vec![base_expr(BaseExprKind::Ident)]), + ) + ) + ); } #[test]