aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/algo/walk.rs1
-rw-r--r--src/grammar/expressions/mod.rs14
2 files changed, 9 insertions, 6 deletions
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<Item = SyntaxNodeR
6 WalkEvent::Exit(_) => None, 6 WalkEvent::Exit(_) => None,
7 }) 7 })
8} 8}
9
9#[derive(Debug, Copy, Clone)] 10#[derive(Debug, Copy, Clone)]
10pub enum WalkEvent<'a> { 11pub enum WalkEvent<'a> {
11 Enter(SyntaxNodeRef<'a>), 12 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 {
35 35
36// test expr_binding_power 36// test expr_binding_power
37// fn foo() { 37// fn foo() {
38// 1 + 2 * 3 == 1 * 2 + 3 38// 1 + 2 * 3 == 1 * 2 + 3;
39// *x = 1 + 1;
39// } 40// }
40fn bp_of(op: SyntaxKind) -> u8 { 41fn bp_of(op: SyntaxKind) -> u8 {
41 match op { 42 match op {
42 EQEQ | NEQ => 1, 43 EQ => 1,
43 MINUS | PLUS => 2, 44 EQEQ | NEQ => 2,
44 STAR | SLASH => 3, 45 MINUS | PLUS => 3,
46 STAR | SLASH => 4,
45 _ => 0 47 _ => 0
46 } 48 }
47} 49}
@@ -106,7 +108,7 @@ fn unary_expr(p: &mut Parser, r: Restrictions) -> Option<CompletedMarker> {
106 return Some(postfix_expr(p, lhs)) 108 return Some(postfix_expr(p, lhs))
107 } 109 }
108 }; 110 };
109 expr(p); 111 unary_expr(p, r);
110 Some(m.complete(p, kind)) 112 Some(m.complete(p, kind))
111} 113}
112 114
@@ -247,7 +249,7 @@ fn struct_lit(p: &mut Parser) {
247 249
248fn bin_expr(p: &mut Parser, r: Restrictions, lhs: CompletedMarker, bp: u8) -> CompletedMarker { 250fn bin_expr(p: &mut Parser, r: Restrictions, lhs: CompletedMarker, bp: u8) -> CompletedMarker {
249 assert!(match p.current() { 251 assert!(match p.current() {
250 MINUS | PLUS | STAR | SLASH | EQEQ | NEQ => true, 252 MINUS | PLUS | STAR | SLASH | EQEQ | NEQ | EQ => true,
251 _ => false, 253 _ => false,
252 }); 254 });
253 let m = lhs.precede(p); 255 let m = lhs.precede(p);