aboutsummaryrefslogtreecommitdiff
path: root/src/grammar
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-04 15:17:20 +0100
committerAleksey Kladov <[email protected]>2018-08-04 15:17:20 +0100
commite4b84fbf36d04e54f68f914f724c8e804233d3aa (patch)
tree3e38d49ae28b0600c8c17de9488e7de77d8f9cec /src/grammar
parent82efdff34bf24680bef58eca399ec3f20748a96a (diff)
Assignment expression
Diffstat (limited to 'src/grammar')
-rw-r--r--src/grammar/expressions/mod.rs14
1 files changed, 8 insertions, 6 deletions
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);