From e4b84fbf36d04e54f68f914f724c8e804233d3aa Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 4 Aug 2018 17:17:20 +0300 Subject: Assignment expression --- src/algo/walk.rs | 1 + src/grammar/expressions/mod.rs | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/algo/walk.rs b/src/algo/walk.rs index ad0f2d8fb..a50ec2a09 100644 --- a/src/algo/walk.rs +++ b/src/algo/walk.rs @@ -6,6 +6,7 @@ pub fn preorder<'a>(root: SyntaxNodeRef<'a>) -> impl Iterator None, }) } + #[derive(Debug, Copy, Clone)] pub enum WalkEvent<'a> { Enter(SyntaxNodeRef<'a>), diff --git a/src/grammar/expressions/mod.rs b/src/grammar/expressions/mod.rs index cedbc235f..6831aef66 100644 --- a/src/grammar/expressions/mod.rs +++ b/src/grammar/expressions/mod.rs @@ -35,13 +35,15 @@ struct Restrictions { // test expr_binding_power // fn foo() { -// 1 + 2 * 3 == 1 * 2 + 3 +// 1 + 2 * 3 == 1 * 2 + 3; +// *x = 1 + 1; // } fn bp_of(op: SyntaxKind) -> u8 { match op { - EQEQ | NEQ => 1, - MINUS | PLUS => 2, - STAR | SLASH => 3, + EQ => 1, + EQEQ | NEQ => 2, + MINUS | PLUS => 3, + STAR | SLASH => 4, _ => 0 } } @@ -106,7 +108,7 @@ fn unary_expr(p: &mut Parser, r: Restrictions) -> Option { return Some(postfix_expr(p, lhs)) } }; - expr(p); + unary_expr(p, r); Some(m.complete(p, kind)) } @@ -247,7 +249,7 @@ fn struct_lit(p: &mut Parser) { fn bin_expr(p: &mut Parser, r: Restrictions, lhs: CompletedMarker, bp: u8) -> CompletedMarker { assert!(match p.current() { - MINUS | PLUS | STAR | SLASH | EQEQ | NEQ => true, + MINUS | PLUS | STAR | SLASH | EQEQ | NEQ | EQ => true, _ => false, }); let m = lhs.precede(p); -- cgit v1.2.3