From 633aace41108b74fe6c93c5ab04272067db033f9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Jul 2020 17:08:58 +0200 Subject: Rename LambdaExpr -> ClosureExpr --- xtask/src/ast_src.rs | 2 +- xtask/src/codegen/gen_syntax.rs | 14 +++++++++++++- xtask/src/codegen/rust.ungram | 16 ++++++++-------- 3 files changed, 22 insertions(+), 10 deletions(-) (limited to 'xtask/src') diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs index 38b60b2a5..427406249 100644 --- a/xtask/src/ast_src.rs +++ b/xtask/src/ast_src.rs @@ -144,7 +144,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc { "ARRAY_EXPR", "PAREN_EXPR", "PATH_EXPR", - "LAMBDA_EXPR", + "CLOSURE_EXPR", "IF_EXPR", "WHILE_EXPR", "CONDITION", diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs index 90f746e96..059538696 100644 --- a/xtask/src/codegen/gen_syntax.rs +++ b/xtask/src/codegen/gen_syntax.rs @@ -579,7 +579,19 @@ fn lower_rule(acc: &mut Vec, grammar: &Grammar, label: Option<&String>, r } Rule::Labeled { label: l, rule } => { assert!(label.is_none()); - if l == "op" { + let manually_implemented = matches!( + l.as_str(), + "lhs" + | "rhs" + | "then_branch" + | "else_branch" + | "start" + | "end" + | "op" + | "index" + | "base" + ); + if manually_implemented { return; } lower_rule(acc, grammar, Some(l), rule); diff --git a/xtask/src/codegen/rust.ungram b/xtask/src/codegen/rust.ungram index 93195befe..aef07cb1e 100644 --- a/xtask/src/codegen/rust.ungram +++ b/xtask/src/codegen/rust.ungram @@ -222,7 +222,7 @@ Expr = | IfExpr | IndexExpr | Label -| LambdaExpr +| ClosureExpr | Literal | LoopExpr | MacroCall @@ -266,14 +266,14 @@ PrefixExpr = BinExpr = Attr* - Expr + lhs:Expr op:( '||' | '&&' | '==' | '!=' | '<=' | '>=' | '<' | '>' | '+' | '*' | '-' | '/' | '%' | '<<' | '>>' | '^' | '|' | '&' | '=' | '+=' | '/=' | '*=' | '%=' | '>>=' | '<<=' | '-=' | '|=' | '&=' | '^=' ) - Expr + rhs:Expr CastExpr = Attr* Expr 'as' Type @@ -288,7 +288,7 @@ ArrayExpr = ) ']' IndexExpr = - Attr* Expr '[' Expr ']' + Attr* base:Expr '[' index:Expr ']' TupleExpr = Attr* '(' Attr* (Expr (',' Expr)* ','?)? ')' @@ -318,13 +318,13 @@ MethodCallExpr = FieldExpr = Attr* Expr '.' NameRef -LambdaExpr = +ClosureExpr = Attr* 'static'? 'async'? 'move'? ParamList RetType? body:Expr IfExpr = - Attr* 'if' Condition BlockExpr - ('else' (IfExpr | BlockExpr))? + Attr* 'if' Condition then_branch:BlockExpr + ('else' else_branch:(IfExpr | BlockExpr))? Condition = 'let' Pat '=' Expr @@ -352,7 +352,7 @@ ContinueExpr = Attr* 'continue' 'lifetime'? RangeExpr = - Attr* Expr? op:('..' | '..=') Expr? + Attr* start:Expr? op:('..' | '..=') end:Expr? MatchExpr = Attr* 'match' Expr MatchArmList -- cgit v1.2.3