From b9189ed2db8cb1934e677a17fcc6282c66306df1 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 1 Aug 2018 00:30:17 +0300 Subject: move lambdas --- src/grammar.ron | 1 + src/grammar/expressions.rs | 6 ++++-- src/syntax_kinds/generated.rs | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src') 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( "type", "ref", "let", + "move", ], contextual_keywords: [ "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 { let done = match p.current() { L_PAREN => tuple_expr(p), PIPE => lambda_expr(p), + MOVE_KW if p.nth(1) == PIPE => lambda_expr(p), IF_KW => if_expr(p), _ => { p.err_and_bump("expected expression"); @@ -184,11 +185,12 @@ fn tuple_expr(p: &mut Parser) -> CompletedMarker { // || (); // || -> i32 { 92 }; // |x| x; -// |x: i32,| x; +// move |x: i32,| x; // } fn lambda_expr(p: &mut Parser) -> CompletedMarker { - assert!(p.at(PIPE)); + assert!(p.at(PIPE) || (p.at(MOVE_KW) && p.nth(1) == PIPE)); let m = p.start(); + p.eat(MOVE_KW); params::param_list_opt_types(p); if fn_ret_type(p) { 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 { TYPE_KW, REF_KW, LET_KW, + MOVE_KW, AUTO_KW, DEFAULT_KW, UNION_KW, @@ -235,6 +236,7 @@ impl SyntaxKind { TYPE_KW => &SyntaxInfo { name: "TYPE_KW" }, REF_KW => &SyntaxInfo { name: "REF_KW" }, LET_KW => &SyntaxInfo { name: "LET_KW" }, + MOVE_KW => &SyntaxInfo { name: "MOVE_KW" }, AUTO_KW => &SyntaxInfo { name: "AUTO_KW" }, DEFAULT_KW => &SyntaxInfo { name: "DEFAULT_KW" }, UNION_KW => &SyntaxInfo { name: "UNION_KW" }, @@ -359,6 +361,7 @@ impl SyntaxKind { "type" => TYPE_KW, "ref" => REF_KW, "let" => LET_KW, + "move" => MOVE_KW, _ => return None, }; Some(kw) @@ -461,6 +464,7 @@ impl SyntaxKind { TYPE_KW => "type", REF_KW => "ref", LET_KW => "let", + MOVE_KW => "move", AUTO_KW => "auto", DEFAULT_KW => "default", UNION_KW => "union", -- cgit v1.2.3