diff options
author | Aleksey Kladov <[email protected]> | 2018-09-02 23:51:46 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-09-02 23:51:46 +0100 |
commit | 23303cd0f8298c2d7b082fcb04919454c1c306ab (patch) | |
tree | 12c22fd573fb86f7718a68ec1d74eb62e401b2f6 /crates/libsyntax2/src | |
parent | 83e2ab434cf20313c9248fbbe7e90f65f27d31ce (diff) |
match scope
Diffstat (limited to 'crates/libsyntax2/src')
-rw-r--r-- | crates/libsyntax2/src/ast/generated.rs | 26 | ||||
-rw-r--r-- | crates/libsyntax2/src/grammar.ron | 16 |
2 files changed, 36 insertions, 6 deletions
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> { | |||
842 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 842 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
843 | } | 843 | } |
844 | 844 | ||
845 | impl<'a> MatchArm<'a> {} | 845 | impl<'a> MatchArm<'a> { |
846 | pub fn pats(self) -> impl Iterator<Item = Pat<'a>> + 'a { | ||
847 | super::children(self) | ||
848 | } | ||
849 | pub fn guard(self) -> Option<MatchGuard<'a>> { | ||
850 | super::child_opt(self) | ||
851 | } | ||
852 | pub fn expr(self) -> Option<Expr<'a>> { | ||
853 | super::child_opt(self) | ||
854 | } | ||
855 | } | ||
846 | 856 | ||
847 | // MatchArmList | 857 | // MatchArmList |
848 | #[derive(Debug, Clone, Copy)] | 858 | #[derive(Debug, Clone, Copy)] |
@@ -860,7 +870,11 @@ impl<'a> AstNode<'a> for MatchArmList<'a> { | |||
860 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 870 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
861 | } | 871 | } |
862 | 872 | ||
863 | impl<'a> MatchArmList<'a> {} | 873 | impl<'a> MatchArmList<'a> { |
874 | pub fn arms(self) -> impl Iterator<Item = MatchArm<'a>> + 'a { | ||
875 | super::children(self) | ||
876 | } | ||
877 | } | ||
864 | 878 | ||
865 | // MatchExpr | 879 | // MatchExpr |
866 | #[derive(Debug, Clone, Copy)] | 880 | #[derive(Debug, Clone, Copy)] |
@@ -878,7 +892,13 @@ impl<'a> AstNode<'a> for MatchExpr<'a> { | |||
878 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 892 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
879 | } | 893 | } |
880 | 894 | ||
881 | impl<'a> MatchExpr<'a> {} | 895 | impl<'a> MatchExpr<'a> {pub fn expr(self) -> Option<Expr<'a>> { |
896 | super::child_opt(self) | ||
897 | } | ||
898 | pub fn match_arm_list(self) -> Option<MatchArmList<'a>> { | ||
899 | super::child_opt(self) | ||
900 | } | ||
901 | } | ||
882 | 902 | ||
883 | // MatchGuard | 903 | // MatchGuard |
884 | #[derive(Debug, Clone, Copy)] | 904 | #[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( | |||
370 | options: [ "Block" ] | 370 | options: [ "Block" ] |
371 | ), | 371 | ), |
372 | "ReturnExpr": (), | 372 | "ReturnExpr": (), |
373 | "MatchExpr": (), | 373 | "MatchExpr": ( |
374 | "MatchArmList": (), | 374 | options: [ "Expr", "MatchArmList" ], |
375 | "MatchArm": (), | 375 | ), |
376 | "MatchArmList": ( | ||
377 | collections: [ ["arms", "MatchArm"] ], | ||
378 | ), | ||
379 | "MatchArm": ( | ||
380 | options: [ | ||
381 | [ "guard", "MatchGuard" ], | ||
382 | "Expr", | ||
383 | ], | ||
384 | collections: [ [ "pats", "Pat" ] ] | ||
385 | ), | ||
376 | "MatchGuard": (), | 386 | "MatchGuard": (), |
377 | "StructLit": (), | 387 | "StructLit": (), |
378 | "NamedFieldList": (), | 388 | "NamedFieldList": (), |