Add dot binary op expression parsing

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-05-06 18:02:13 -04:00
parent d238610f33
commit 10e37e2707

View File

@@ -171,6 +171,12 @@ impl<'t> Parser<'t> {
bin_expr!( bin_expr!(
next_bin_mul_expr, next_bin_mul_expr,
&[TokenKind::FSlash, TokenKind::Splat], &[TokenKind::FSlash, TokenKind::Splat],
next_dot_expr
);
// .
bin_expr!(
next_dot_expr,
&[TokenKind::Dot],
next_un_expr 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] #[test]