diff options
author | Aleksey Kladov <[email protected]> | 2018-07-31 22:30:17 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-07-31 22:30:17 +0100 |
commit | b9189ed2db8cb1934e677a17fcc6282c66306df1 (patch) | |
tree | 1456403c6eac7820c6b6760ccc6900326aedc792 /src | |
parent | 2bbd4c510d2da5c78f566b28e90548102bb107dc (diff) |
move lambdas
Diffstat (limited to 'src')
-rw-r--r-- | src/grammar.ron | 1 | ||||
-rw-r--r-- | src/grammar/expressions.rs | 6 | ||||
-rw-r--r-- | src/syntax_kinds/generated.rs | 4 |
3 files changed, 9 insertions, 2 deletions
diff --git a/src/grammar.ron b/src/grammar.ron index 782771830..b4c121f4d 100644 --- a/src/grammar.ron +++ b/src/grammar.ron | |||
@@ -69,6 +69,7 @@ Grammar( | |||
69 | "type", | 69 | "type", |
70 | "ref", | 70 | "ref", |
71 | "let", | 71 | "let", |
72 | "move", | ||
72 | ], | 73 | ], |
73 | contextual_keywords: [ | 74 | contextual_keywords: [ |
74 | "auto", | 75 | "auto", |
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 | // } |
189 | fn lambda_expr(p: &mut Parser) -> CompletedMarker { | 190 | fn 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); |
diff --git a/src/syntax_kinds/generated.rs b/src/syntax_kinds/generated.rs index 746316ed5..435be781c 100644 --- a/src/syntax_kinds/generated.rs +++ b/src/syntax_kinds/generated.rs | |||
@@ -70,6 +70,7 @@ pub enum SyntaxKind { | |||
70 | TYPE_KW, | 70 | TYPE_KW, |
71 | REF_KW, | 71 | REF_KW, |
72 | LET_KW, | 72 | LET_KW, |
73 | MOVE_KW, | ||
73 | AUTO_KW, | 74 | AUTO_KW, |
74 | DEFAULT_KW, | 75 | DEFAULT_KW, |
75 | UNION_KW, | 76 | UNION_KW, |
@@ -235,6 +236,7 @@ impl SyntaxKind { | |||
235 | TYPE_KW => &SyntaxInfo { name: "TYPE_KW" }, | 236 | TYPE_KW => &SyntaxInfo { name: "TYPE_KW" }, |
236 | REF_KW => &SyntaxInfo { name: "REF_KW" }, | 237 | REF_KW => &SyntaxInfo { name: "REF_KW" }, |
237 | LET_KW => &SyntaxInfo { name: "LET_KW" }, | 238 | LET_KW => &SyntaxInfo { name: "LET_KW" }, |
239 | MOVE_KW => &SyntaxInfo { name: "MOVE_KW" }, | ||
238 | AUTO_KW => &SyntaxInfo { name: "AUTO_KW" }, | 240 | AUTO_KW => &SyntaxInfo { name: "AUTO_KW" }, |
239 | DEFAULT_KW => &SyntaxInfo { name: "DEFAULT_KW" }, | 241 | DEFAULT_KW => &SyntaxInfo { name: "DEFAULT_KW" }, |
240 | UNION_KW => &SyntaxInfo { name: "UNION_KW" }, | 242 | UNION_KW => &SyntaxInfo { name: "UNION_KW" }, |
@@ -359,6 +361,7 @@ impl SyntaxKind { | |||
359 | "type" => TYPE_KW, | 361 | "type" => TYPE_KW, |
360 | "ref" => REF_KW, | 362 | "ref" => REF_KW, |
361 | "let" => LET_KW, | 363 | "let" => LET_KW, |
364 | "move" => MOVE_KW, | ||
362 | _ => return None, | 365 | _ => return None, |
363 | }; | 366 | }; |
364 | Some(kw) | 367 | Some(kw) |
@@ -461,6 +464,7 @@ impl SyntaxKind { | |||
461 | TYPE_KW => "type", | 464 | TYPE_KW => "type", |
462 | REF_KW => "ref", | 465 | REF_KW => "ref", |
463 | LET_KW => "let", | 466 | LET_KW => "let", |
467 | MOVE_KW => "move", | ||
464 | AUTO_KW => "auto", | 468 | AUTO_KW => "auto", |
465 | DEFAULT_KW => "default", | 469 | DEFAULT_KW => "default", |
466 | UNION_KW => "union", | 470 | UNION_KW => "union", |