From 23303cd0f8298c2d7b082fcb04919454c1c306ab Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 3 Sep 2018 01:51:46 +0300 Subject: match scope --- crates/libsyntax2/src/ast/generated.rs | 26 +++++++++++++++++++++++--- crates/libsyntax2/src/grammar.ron | 16 +++++++++++++--- 2 files changed, 36 insertions(+), 6 deletions(-) (limited to 'crates/libsyntax2') diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs index f21e49437..bdee635ae 100644 --- a/crates/libsyntax2/src/ast/generated.rs +++ b/crates/libsyntax2/src/ast/generated.rs @@ -842,7 +842,17 @@ impl<'a> AstNode<'a> for MatchArm<'a> { fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } -impl<'a> MatchArm<'a> {} +impl<'a> MatchArm<'a> { + pub fn pats(self) -> impl Iterator> + 'a { + super::children(self) + } +pub fn guard(self) -> Option> { + super::child_opt(self) + } +pub fn expr(self) -> Option> { + super::child_opt(self) + } +} // MatchArmList #[derive(Debug, Clone, Copy)] @@ -860,7 +870,11 @@ impl<'a> AstNode<'a> for MatchArmList<'a> { fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } -impl<'a> MatchArmList<'a> {} +impl<'a> MatchArmList<'a> { + pub fn arms(self) -> impl Iterator> + 'a { + super::children(self) + } +} // MatchExpr #[derive(Debug, Clone, Copy)] @@ -878,7 +892,13 @@ impl<'a> AstNode<'a> for MatchExpr<'a> { fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } -impl<'a> MatchExpr<'a> {} +impl<'a> MatchExpr<'a> {pub fn expr(self) -> Option> { + super::child_opt(self) + } +pub fn match_arm_list(self) -> Option> { + super::child_opt(self) + } +} // MatchGuard #[derive(Debug, Clone, Copy)] diff --git a/crates/libsyntax2/src/grammar.ron b/crates/libsyntax2/src/grammar.ron index fbe8397d8..798725f7e 100644 --- a/crates/libsyntax2/src/grammar.ron +++ b/crates/libsyntax2/src/grammar.ron @@ -370,9 +370,19 @@ Grammar( options: [ "Block" ] ), "ReturnExpr": (), - "MatchExpr": (), - "MatchArmList": (), - "MatchArm": (), + "MatchExpr": ( + options: [ "Expr", "MatchArmList" ], + ), + "MatchArmList": ( + collections: [ ["arms", "MatchArm"] ], + ), + "MatchArm": ( + options: [ + [ "guard", "MatchGuard" ], + "Expr", + ], + collections: [ [ "pats", "Pat" ] ] + ), "MatchGuard": (), "StructLit": (), "NamedFieldList": (), -- cgit v1.2.3