Unnamed repository; edit this file 'description' to name the repository.
Merge rust-analyzer/ungrammar#45
45: Support if- and while-let chains r=matklad a=ChayimFriedman2
RFC 2497 https://github.com/rust-lang/rfcs/blob/master/text/2497-if-let-chains.md.
I'm not sure if this should be a major or minor version bump: it breaks users of rust.ungram but not general users of the crate.
Co-authored-by: Chayim Refael Friedman <[email protected]>
| -rw-r--r-- | lib/ungrammar/Cargo.toml | 2 | ||||
| -rw-r--r-- | lib/ungrammar/rust.ungram | 14 |
2 files changed, 8 insertions, 8 deletions
diff --git a/lib/ungrammar/Cargo.toml b/lib/ungrammar/Cargo.toml index 8e732c8dd9..bbfb0f5855 100644 --- a/lib/ungrammar/Cargo.toml +++ b/lib/ungrammar/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "ungrammar" description = "A DSL for describing concrete syntax trees" -version = "1.14.9" +version = "1.15.0" license = "MIT OR Apache-2.0" repository = "https://github.com/matklad/ungrammar" edition = "2018" diff --git a/lib/ungrammar/rust.ungram b/lib/ungrammar/rust.ungram index d2ef552ae9..7d7f184852 100644 --- a/lib/ungrammar/rust.ungram +++ b/lib/ungrammar/rust.ungram @@ -357,6 +357,7 @@ Expr = | TupleExpr | WhileExpr | YieldExpr +| LetExpr Literal = Attr* value:( @@ -448,13 +449,9 @@ ClosureExpr = body:Expr IfExpr = - Attr* 'if' Condition then_branch:BlockExpr + Attr* 'if' condition:Expr then_branch:BlockExpr ('else' else_branch:(IfExpr | BlockExpr))? -Condition = - 'let' Pat '=' Expr -| Expr - LoopExpr = Attr* Label? 'loop' loop_body:BlockExpr @@ -464,7 +461,7 @@ ForExpr = loop_body:BlockExpr WhileExpr = - Attr* Label? 'while' Condition + Attr* Label? 'while' condition:Expr loop_body:BlockExpr Label = @@ -492,7 +489,7 @@ MatchArm = Attr* Pat guard:MatchGuard? '=>' Expr ','? MatchGuard = - 'if' ('let' Pat '=')? Expr + 'if' condition:Expr ReturnExpr = Attr* 'return' Expr? @@ -500,6 +497,9 @@ ReturnExpr = YieldExpr = Attr* 'yield' Expr? +LetExpr = + Attr* 'let' Pat '=' Expr + AwaitExpr = Attr* Expr '.' 'await' |