aboutsummaryrefslogtreecommitdiff
path: root/src/grammar
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-07-31 22:30:17 +0100
committerAleksey Kladov <[email protected]>2018-07-31 22:30:17 +0100
commitb9189ed2db8cb1934e677a17fcc6282c66306df1 (patch)
tree1456403c6eac7820c6b6760ccc6900326aedc792 /src/grammar
parent2bbd4c510d2da5c78f566b28e90548102bb107dc (diff)
move lambdas
Diffstat (limited to 'src/grammar')
-rw-r--r--src/grammar/expressions.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/grammar/expressions.rs b/src/grammar/expressions.rs
index c638e8b99..c0eb0e756 100644
--- a/src/grammar/expressions.rs
+++ b/src/grammar/expressions.rs
@@ -162,6 +162,7 @@ fn atom_expr(p: &mut Parser) -> Option<CompletedMarker> {
162 let done = match p.current() { 162 let done = match p.current() {
163 L_PAREN => tuple_expr(p), 163 L_PAREN => tuple_expr(p),
164 PIPE => lambda_expr(p), 164 PIPE => lambda_expr(p),
165 MOVE_KW if p.nth(1) == PIPE => lambda_expr(p),
165 IF_KW => if_expr(p), 166 IF_KW => if_expr(p),
166 _ => { 167 _ => {
167 p.err_and_bump("expected expression"); 168 p.err_and_bump("expected expression");
@@ -184,11 +185,12 @@ fn tuple_expr(p: &mut Parser) -> CompletedMarker {
184// || (); 185// || ();
185// || -> i32 { 92 }; 186// || -> i32 { 92 };
186// |x| x; 187// |x| x;
187// |x: i32,| x; 188// move |x: i32,| x;
188// } 189// }
189fn lambda_expr(p: &mut Parser) -> CompletedMarker { 190fn lambda_expr(p: &mut Parser) -> CompletedMarker {
190 assert!(p.at(PIPE)); 191 assert!(p.at(PIPE) || (p.at(MOVE_KW) && p.nth(1) == PIPE));
191 let m = p.start(); 192 let m = p.start();
193 p.eat(MOVE_KW);
192 params::param_list_opt_types(p); 194 params::param_list_opt_types(p);
193 if fn_ret_type(p) { 195 if fn_ret_type(p) {
194 block(p); 196 block(p);