diff options
Diffstat (limited to 'crates/ra_syntax')
7 files changed, 317 insertions, 73 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 435135f92..8d640642d 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs | |||
@@ -1759,8 +1759,8 @@ impl AstNode for MatchArm { | |||
1759 | } | 1759 | } |
1760 | impl ast::AttrsOwner for MatchArm {} | 1760 | impl ast::AttrsOwner for MatchArm {} |
1761 | impl MatchArm { | 1761 | impl MatchArm { |
1762 | pub fn pats(&self) -> AstChildren<Pat> { | 1762 | pub fn pat(&self) -> Option<Pat> { |
1763 | AstChildren::new(&self.syntax) | 1763 | AstChildren::new(&self.syntax).next() |
1764 | } | 1764 | } |
1765 | pub fn guard(&self) -> Option<MatchGuard> { | 1765 | pub fn guard(&self) -> Option<MatchGuard> { |
1766 | AstChildren::new(&self.syntax).next() | 1766 | AstChildren::new(&self.syntax).next() |
@@ -1887,6 +1887,60 @@ impl RecordField { | |||
1887 | } | 1887 | } |
1888 | } | 1888 | } |
1889 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1889 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1890 | pub struct OrPat { | ||
1891 | pub(crate) syntax: SyntaxNode, | ||
1892 | } | ||
1893 | impl AstNode for OrPat { | ||
1894 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1895 | match kind { | ||
1896 | OR_PAT => true, | ||
1897 | _ => false, | ||
1898 | } | ||
1899 | } | ||
1900 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1901 | if Self::can_cast(syntax.kind()) { | ||
1902 | Some(Self { syntax }) | ||
1903 | } else { | ||
1904 | None | ||
1905 | } | ||
1906 | } | ||
1907 | fn syntax(&self) -> &SyntaxNode { | ||
1908 | &self.syntax | ||
1909 | } | ||
1910 | } | ||
1911 | impl OrPat { | ||
1912 | pub fn pats(&self) -> AstChildren<Pat> { | ||
1913 | AstChildren::new(&self.syntax) | ||
1914 | } | ||
1915 | } | ||
1916 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1917 | pub struct ParenPat { | ||
1918 | pub(crate) syntax: SyntaxNode, | ||
1919 | } | ||
1920 | impl AstNode for ParenPat { | ||
1921 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1922 | match kind { | ||
1923 | PAREN_PAT => true, | ||
1924 | _ => false, | ||
1925 | } | ||
1926 | } | ||
1927 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1928 | if Self::can_cast(syntax.kind()) { | ||
1929 | Some(Self { syntax }) | ||
1930 | } else { | ||
1931 | None | ||
1932 | } | ||
1933 | } | ||
1934 | fn syntax(&self) -> &SyntaxNode { | ||
1935 | &self.syntax | ||
1936 | } | ||
1937 | } | ||
1938 | impl ParenPat { | ||
1939 | pub fn pat(&self) -> Option<Pat> { | ||
1940 | AstChildren::new(&self.syntax).next() | ||
1941 | } | ||
1942 | } | ||
1943 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1890 | pub struct RefPat { | 1944 | pub struct RefPat { |
1891 | pub(crate) syntax: SyntaxNode, | 1945 | pub(crate) syntax: SyntaxNode, |
1892 | } | 1946 | } |
@@ -3900,6 +3954,8 @@ impl AstNode for Expr { | |||
3900 | } | 3954 | } |
3901 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 3955 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
3902 | pub enum Pat { | 3956 | pub enum Pat { |
3957 | OrPat(OrPat), | ||
3958 | ParenPat(ParenPat), | ||
3903 | RefPat(RefPat), | 3959 | RefPat(RefPat), |
3904 | BoxPat(BoxPat), | 3960 | BoxPat(BoxPat), |
3905 | BindPat(BindPat), | 3961 | BindPat(BindPat), |
@@ -3913,6 +3969,16 @@ pub enum Pat { | |||
3913 | RangePat(RangePat), | 3969 | RangePat(RangePat), |
3914 | LiteralPat(LiteralPat), | 3970 | LiteralPat(LiteralPat), |
3915 | } | 3971 | } |
3972 | impl From<OrPat> for Pat { | ||
3973 | fn from(node: OrPat) -> Pat { | ||
3974 | Pat::OrPat(node) | ||
3975 | } | ||
3976 | } | ||
3977 | impl From<ParenPat> for Pat { | ||
3978 | fn from(node: ParenPat) -> Pat { | ||
3979 | Pat::ParenPat(node) | ||
3980 | } | ||
3981 | } | ||
3916 | impl From<RefPat> for Pat { | 3982 | impl From<RefPat> for Pat { |
3917 | fn from(node: RefPat) -> Pat { | 3983 | fn from(node: RefPat) -> Pat { |
3918 | Pat::RefPat(node) | 3984 | Pat::RefPat(node) |
@@ -3976,15 +4042,16 @@ impl From<LiteralPat> for Pat { | |||
3976 | impl AstNode for Pat { | 4042 | impl AstNode for Pat { |
3977 | fn can_cast(kind: SyntaxKind) -> bool { | 4043 | fn can_cast(kind: SyntaxKind) -> bool { |
3978 | match kind { | 4044 | match kind { |
3979 | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT | PATH_PAT | 4045 | OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT |
3980 | | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT | LITERAL_PAT => { | 4046 | | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT |
3981 | true | 4047 | | LITERAL_PAT => true, |
3982 | } | ||
3983 | _ => false, | 4048 | _ => false, |
3984 | } | 4049 | } |
3985 | } | 4050 | } |
3986 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 4051 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
3987 | let res = match syntax.kind() { | 4052 | let res = match syntax.kind() { |
4053 | OR_PAT => Pat::OrPat(OrPat { syntax }), | ||
4054 | PAREN_PAT => Pat::ParenPat(ParenPat { syntax }), | ||
3988 | REF_PAT => Pat::RefPat(RefPat { syntax }), | 4055 | REF_PAT => Pat::RefPat(RefPat { syntax }), |
3989 | BOX_PAT => Pat::BoxPat(BoxPat { syntax }), | 4056 | BOX_PAT => Pat::BoxPat(BoxPat { syntax }), |
3990 | BIND_PAT => Pat::BindPat(BindPat { syntax }), | 4057 | BIND_PAT => Pat::BindPat(BindPat { syntax }), |
@@ -4003,6 +4070,8 @@ impl AstNode for Pat { | |||
4003 | } | 4070 | } |
4004 | fn syntax(&self) -> &SyntaxNode { | 4071 | fn syntax(&self) -> &SyntaxNode { |
4005 | match self { | 4072 | match self { |
4073 | Pat::OrPat(it) => &it.syntax, | ||
4074 | Pat::ParenPat(it) => &it.syntax, | ||
4006 | Pat::RefPat(it) => &it.syntax, | 4075 | Pat::RefPat(it) => &it.syntax, |
4007 | Pat::BoxPat(it) => &it.syntax, | 4076 | Pat::BoxPat(it) => &it.syntax, |
4008 | Pat::BindPat(it) => &it.syntax, | 4077 | Pat::BindPat(it) => &it.syntax, |
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0030_cond.txt b/crates/ra_syntax/test_data/parser/inline/ok/0030_cond.txt index 4028ca243..6fd49c7bc 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0030_cond.txt +++ b/crates/ra_syntax/test_data/parser/inline/ok/0030_cond.txt | |||
@@ -63,27 +63,28 @@ SOURCE_FILE@[0; 197) | |||
63 | CONDITION@[56; 84) | 63 | CONDITION@[56; 84) |
64 | LET_KW@[56; 59) "let" | 64 | LET_KW@[56; 59) "let" |
65 | WHITESPACE@[59; 60) " " | 65 | WHITESPACE@[59; 60) " " |
66 | TUPLE_STRUCT_PAT@[60; 67) | 66 | OR_PAT@[60; 77) |
67 | PATH@[60; 64) | 67 | TUPLE_STRUCT_PAT@[60; 67) |
68 | PATH_SEGMENT@[60; 64) | 68 | PATH@[60; 64) |
69 | NAME_REF@[60; 64) | 69 | PATH_SEGMENT@[60; 64) |
70 | IDENT@[60; 64) "Some" | 70 | NAME_REF@[60; 64) |
71 | L_PAREN@[64; 65) "(" | 71 | IDENT@[60; 64) "Some" |
72 | PLACEHOLDER_PAT@[65; 66) | 72 | L_PAREN@[64; 65) "(" |
73 | UNDERSCORE@[65; 66) "_" | 73 | PLACEHOLDER_PAT@[65; 66) |
74 | R_PAREN@[66; 67) ")" | 74 | UNDERSCORE@[65; 66) "_" |
75 | WHITESPACE@[67; 68) " " | 75 | R_PAREN@[66; 67) ")" |
76 | PIPE@[68; 69) "|" | 76 | WHITESPACE@[67; 68) " " |
77 | WHITESPACE@[69; 70) " " | 77 | PIPE@[68; 69) "|" |
78 | TUPLE_STRUCT_PAT@[70; 77) | 78 | WHITESPACE@[69; 70) " " |
79 | PATH@[70; 74) | 79 | TUPLE_STRUCT_PAT@[70; 77) |
80 | PATH_SEGMENT@[70; 74) | 80 | PATH@[70; 74) |
81 | NAME_REF@[70; 74) | 81 | PATH_SEGMENT@[70; 74) |
82 | IDENT@[70; 74) "Some" | 82 | NAME_REF@[70; 74) |
83 | L_PAREN@[74; 75) "(" | 83 | IDENT@[70; 74) "Some" |
84 | PLACEHOLDER_PAT@[75; 76) | 84 | L_PAREN@[74; 75) "(" |
85 | UNDERSCORE@[75; 76) "_" | 85 | PLACEHOLDER_PAT@[75; 76) |
86 | R_PAREN@[76; 77) ")" | 86 | UNDERSCORE@[75; 76) "_" |
87 | R_PAREN@[76; 77) ")" | ||
87 | WHITESPACE@[77; 78) " " | 88 | WHITESPACE@[77; 78) " " |
88 | EQ@[78; 79) "=" | 89 | EQ@[78; 79) "=" |
89 | WHITESPACE@[79; 80) " " | 90 | WHITESPACE@[79; 80) " " |
@@ -137,27 +138,28 @@ SOURCE_FILE@[0; 197) | |||
137 | CONDITION@[129; 157) | 138 | CONDITION@[129; 157) |
138 | LET_KW@[129; 132) "let" | 139 | LET_KW@[129; 132) "let" |
139 | WHITESPACE@[132; 133) " " | 140 | WHITESPACE@[132; 133) " " |
140 | TUPLE_STRUCT_PAT@[133; 140) | 141 | OR_PAT@[133; 150) |
141 | PATH@[133; 137) | 142 | TUPLE_STRUCT_PAT@[133; 140) |
142 | PATH_SEGMENT@[133; 137) | 143 | PATH@[133; 137) |
143 | NAME_REF@[133; 137) | 144 | PATH_SEGMENT@[133; 137) |
144 | IDENT@[133; 137) "Some" | 145 | NAME_REF@[133; 137) |
145 | L_PAREN@[137; 138) "(" | 146 | IDENT@[133; 137) "Some" |
146 | PLACEHOLDER_PAT@[138; 139) | 147 | L_PAREN@[137; 138) "(" |
147 | UNDERSCORE@[138; 139) "_" | 148 | PLACEHOLDER_PAT@[138; 139) |
148 | R_PAREN@[139; 140) ")" | 149 | UNDERSCORE@[138; 139) "_" |
149 | WHITESPACE@[140; 141) " " | 150 | R_PAREN@[139; 140) ")" |
150 | PIPE@[141; 142) "|" | 151 | WHITESPACE@[140; 141) " " |
151 | WHITESPACE@[142; 143) " " | 152 | PIPE@[141; 142) "|" |
152 | TUPLE_STRUCT_PAT@[143; 150) | 153 | WHITESPACE@[142; 143) " " |
153 | PATH@[143; 147) | 154 | TUPLE_STRUCT_PAT@[143; 150) |
154 | PATH_SEGMENT@[143; 147) | 155 | PATH@[143; 147) |
155 | NAME_REF@[143; 147) | 156 | PATH_SEGMENT@[143; 147) |
156 | IDENT@[143; 147) "Some" | 157 | NAME_REF@[143; 147) |
157 | L_PAREN@[147; 148) "(" | 158 | IDENT@[143; 147) "Some" |
158 | PLACEHOLDER_PAT@[148; 149) | 159 | L_PAREN@[147; 148) "(" |
159 | UNDERSCORE@[148; 149) "_" | 160 | PLACEHOLDER_PAT@[148; 149) |
160 | R_PAREN@[149; 150) ")" | 161 | UNDERSCORE@[148; 149) "_" |
162 | R_PAREN@[149; 150) ")" | ||
161 | WHITESPACE@[150; 151) " " | 163 | WHITESPACE@[150; 151) " " |
162 | EQ@[151; 152) "=" | 164 | EQ@[151; 152) "=" |
163 | WHITESPACE@[152; 153) " " | 165 | WHITESPACE@[152; 153) " " |
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0066_match_arm.txt b/crates/ra_syntax/test_data/parser/inline/ok/0066_match_arm.txt index 87272917b..2f07af4e1 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0066_match_arm.txt +++ b/crates/ra_syntax/test_data/parser/inline/ok/0066_match_arm.txt | |||
@@ -74,15 +74,16 @@ SOURCE_FILE@[0; 167) | |||
74 | COMMA@[83; 84) "," | 74 | COMMA@[83; 84) "," |
75 | WHITESPACE@[84; 93) "\n " | 75 | WHITESPACE@[84; 93) "\n " |
76 | MATCH_ARM@[93; 109) | 76 | MATCH_ARM@[93; 109) |
77 | BIND_PAT@[93; 94) | 77 | OR_PAT@[93; 98) |
78 | NAME@[93; 94) | 78 | BIND_PAT@[93; 94) |
79 | IDENT@[93; 94) "X" | 79 | NAME@[93; 94) |
80 | WHITESPACE@[94; 95) " " | 80 | IDENT@[93; 94) "X" |
81 | PIPE@[95; 96) "|" | 81 | WHITESPACE@[94; 95) " " |
82 | WHITESPACE@[96; 97) " " | 82 | PIPE@[95; 96) "|" |
83 | BIND_PAT@[97; 98) | 83 | WHITESPACE@[96; 97) " " |
84 | NAME@[97; 98) | 84 | BIND_PAT@[97; 98) |
85 | IDENT@[97; 98) "Y" | 85 | NAME@[97; 98) |
86 | IDENT@[97; 98) "Y" | ||
86 | WHITESPACE@[98; 99) " " | 87 | WHITESPACE@[98; 99) " " |
87 | MATCH_GUARD@[99; 103) | 88 | MATCH_GUARD@[99; 103) |
88 | IF_KW@[99; 101) "if" | 89 | IF_KW@[99; 101) "if" |
@@ -103,15 +104,16 @@ SOURCE_FILE@[0; 167) | |||
103 | MATCH_ARM@[119; 137) | 104 | MATCH_ARM@[119; 137) |
104 | PIPE@[119; 120) "|" | 105 | PIPE@[119; 120) "|" |
105 | WHITESPACE@[120; 121) " " | 106 | WHITESPACE@[120; 121) " " |
106 | BIND_PAT@[121; 122) | 107 | OR_PAT@[121; 126) |
107 | NAME@[121; 122) | 108 | BIND_PAT@[121; 122) |
108 | IDENT@[121; 122) "X" | 109 | NAME@[121; 122) |
109 | WHITESPACE@[122; 123) " " | 110 | IDENT@[121; 122) "X" |
110 | PIPE@[123; 124) "|" | 111 | WHITESPACE@[122; 123) " " |
111 | WHITESPACE@[124; 125) " " | 112 | PIPE@[123; 124) "|" |
112 | BIND_PAT@[125; 126) | 113 | WHITESPACE@[124; 125) " " |
113 | NAME@[125; 126) | 114 | BIND_PAT@[125; 126) |
114 | IDENT@[125; 126) "Y" | 115 | NAME@[125; 126) |
116 | IDENT@[125; 126) "Y" | ||
115 | WHITESPACE@[126; 127) " " | 117 | WHITESPACE@[126; 127) " " |
116 | MATCH_GUARD@[127; 131) | 118 | MATCH_GUARD@[127; 131) |
117 | IF_KW@[127; 129) "if" | 119 | IF_KW@[127; 129) "if" |
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.rs b/crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.rs index f785acd36..ba719879d 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.rs +++ b/crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.rs | |||
@@ -1,3 +1,6 @@ | |||
1 | fn main() { | 1 | fn main() { |
2 | let (a, b, ..) = (); | 2 | let (a, b, ..) = (); |
3 | let (a,) = (); | ||
4 | let (..) = (); | ||
5 | let () = (); | ||
3 | } | 6 | } |
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.txt b/crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.txt index 674dec493..4680c267e 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.txt +++ b/crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.txt | |||
@@ -1,5 +1,5 @@ | |||
1 | SOURCE_FILE@[0; 39) | 1 | SOURCE_FILE@[0; 94) |
2 | FN_DEF@[0; 38) | 2 | FN_DEF@[0; 93) |
3 | FN_KW@[0; 2) "fn" | 3 | FN_KW@[0; 2) "fn" |
4 | WHITESPACE@[2; 3) " " | 4 | WHITESPACE@[2; 3) " " |
5 | NAME@[3; 7) | 5 | NAME@[3; 7) |
@@ -8,8 +8,8 @@ SOURCE_FILE@[0; 39) | |||
8 | L_PAREN@[7; 8) "(" | 8 | L_PAREN@[7; 8) "(" |
9 | R_PAREN@[8; 9) ")" | 9 | R_PAREN@[8; 9) ")" |
10 | WHITESPACE@[9; 10) " " | 10 | WHITESPACE@[9; 10) " " |
11 | BLOCK_EXPR@[10; 38) | 11 | BLOCK_EXPR@[10; 93) |
12 | BLOCK@[10; 38) | 12 | BLOCK@[10; 93) |
13 | L_CURLY@[10; 11) "{" | 13 | L_CURLY@[10; 11) "{" |
14 | WHITESPACE@[11; 16) "\n " | 14 | WHITESPACE@[11; 16) "\n " |
15 | LET_STMT@[16; 36) | 15 | LET_STMT@[16; 36) |
@@ -37,6 +37,54 @@ SOURCE_FILE@[0; 39) | |||
37 | L_PAREN@[33; 34) "(" | 37 | L_PAREN@[33; 34) "(" |
38 | R_PAREN@[34; 35) ")" | 38 | R_PAREN@[34; 35) ")" |
39 | SEMI@[35; 36) ";" | 39 | SEMI@[35; 36) ";" |
40 | WHITESPACE@[36; 37) "\n" | 40 | WHITESPACE@[36; 41) "\n " |
41 | R_CURLY@[37; 38) "}" | 41 | LET_STMT@[41; 55) |
42 | WHITESPACE@[38; 39) "\n" | 42 | LET_KW@[41; 44) "let" |
43 | WHITESPACE@[44; 45) " " | ||
44 | TUPLE_PAT@[45; 49) | ||
45 | L_PAREN@[45; 46) "(" | ||
46 | BIND_PAT@[46; 47) | ||
47 | NAME@[46; 47) | ||
48 | IDENT@[46; 47) "a" | ||
49 | COMMA@[47; 48) "," | ||
50 | R_PAREN@[48; 49) ")" | ||
51 | WHITESPACE@[49; 50) " " | ||
52 | EQ@[50; 51) "=" | ||
53 | WHITESPACE@[51; 52) " " | ||
54 | TUPLE_EXPR@[52; 54) | ||
55 | L_PAREN@[52; 53) "(" | ||
56 | R_PAREN@[53; 54) ")" | ||
57 | SEMI@[54; 55) ";" | ||
58 | WHITESPACE@[55; 60) "\n " | ||
59 | LET_STMT@[60; 74) | ||
60 | LET_KW@[60; 63) "let" | ||
61 | WHITESPACE@[63; 64) " " | ||
62 | TUPLE_PAT@[64; 68) | ||
63 | L_PAREN@[64; 65) "(" | ||
64 | DOT_DOT_PAT@[65; 67) | ||
65 | DOTDOT@[65; 67) ".." | ||
66 | R_PAREN@[67; 68) ")" | ||
67 | WHITESPACE@[68; 69) " " | ||
68 | EQ@[69; 70) "=" | ||
69 | WHITESPACE@[70; 71) " " | ||
70 | TUPLE_EXPR@[71; 73) | ||
71 | L_PAREN@[71; 72) "(" | ||
72 | R_PAREN@[72; 73) ")" | ||
73 | SEMI@[73; 74) ";" | ||
74 | WHITESPACE@[74; 79) "\n " | ||
75 | LET_STMT@[79; 91) | ||
76 | LET_KW@[79; 82) "let" | ||
77 | WHITESPACE@[82; 83) " " | ||
78 | TUPLE_PAT@[83; 85) | ||
79 | L_PAREN@[83; 84) "(" | ||
80 | R_PAREN@[84; 85) ")" | ||
81 | WHITESPACE@[85; 86) " " | ||
82 | EQ@[86; 87) "=" | ||
83 | WHITESPACE@[87; 88) " " | ||
84 | TUPLE_EXPR@[88; 90) | ||
85 | L_PAREN@[88; 89) "(" | ||
86 | R_PAREN@[89; 90) ")" | ||
87 | SEMI@[90; 91) ";" | ||
88 | WHITESPACE@[91; 92) "\n" | ||
89 | R_CURLY@[92; 93) "}" | ||
90 | WHITESPACE@[93; 94) "\n" | ||
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0156_or_pattern.rs b/crates/ra_syntax/test_data/parser/inline/ok/0156_or_pattern.rs new file mode 100644 index 000000000..a26316605 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0156_or_pattern.rs | |||
@@ -0,0 +1,8 @@ | |||
1 | fn main() { | ||
2 | match () { | ||
3 | (_ | _) => (), | ||
4 | &(_ | _) => (), | ||
5 | (_ | _,) => (), | ||
6 | [_ | _,] => (), | ||
7 | } | ||
8 | } | ||
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0156_or_pattern.txt b/crates/ra_syntax/test_data/parser/inline/ok/0156_or_pattern.txt new file mode 100644 index 000000000..3a196d3c0 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0156_or_pattern.txt | |||
@@ -0,0 +1,112 @@ | |||
1 | SOURCE_FILE@[0; 130) | ||
2 | FN_DEF@[0; 129) | ||
3 | FN_KW@[0; 2) "fn" | ||
4 | WHITESPACE@[2; 3) " " | ||
5 | NAME@[3; 7) | ||
6 | IDENT@[3; 7) "main" | ||
7 | PARAM_LIST@[7; 9) | ||
8 | L_PAREN@[7; 8) "(" | ||
9 | R_PAREN@[8; 9) ")" | ||
10 | WHITESPACE@[9; 10) " " | ||
11 | BLOCK_EXPR@[10; 129) | ||
12 | BLOCK@[10; 129) | ||
13 | L_CURLY@[10; 11) "{" | ||
14 | WHITESPACE@[11; 16) "\n " | ||
15 | MATCH_EXPR@[16; 127) | ||
16 | MATCH_KW@[16; 21) "match" | ||
17 | WHITESPACE@[21; 22) " " | ||
18 | TUPLE_EXPR@[22; 24) | ||
19 | L_PAREN@[22; 23) "(" | ||
20 | R_PAREN@[23; 24) ")" | ||
21 | WHITESPACE@[24; 25) " " | ||
22 | MATCH_ARM_LIST@[25; 127) | ||
23 | L_CURLY@[25; 26) "{" | ||
24 | WHITESPACE@[26; 35) "\n " | ||
25 | MATCH_ARM@[35; 48) | ||
26 | PAREN_PAT@[35; 42) | ||
27 | L_PAREN@[35; 36) "(" | ||
28 | OR_PAT@[36; 41) | ||
29 | PLACEHOLDER_PAT@[36; 37) | ||
30 | UNDERSCORE@[36; 37) "_" | ||
31 | WHITESPACE@[37; 38) " " | ||
32 | PIPE@[38; 39) "|" | ||
33 | WHITESPACE@[39; 40) " " | ||
34 | PLACEHOLDER_PAT@[40; 41) | ||
35 | UNDERSCORE@[40; 41) "_" | ||
36 | R_PAREN@[41; 42) ")" | ||
37 | WHITESPACE@[42; 43) " " | ||
38 | FAT_ARROW@[43; 45) "=>" | ||
39 | WHITESPACE@[45; 46) " " | ||
40 | TUPLE_EXPR@[46; 48) | ||
41 | L_PAREN@[46; 47) "(" | ||
42 | R_PAREN@[47; 48) ")" | ||
43 | COMMA@[48; 49) "," | ||
44 | WHITESPACE@[49; 58) "\n " | ||
45 | MATCH_ARM@[58; 72) | ||
46 | REF_PAT@[58; 66) | ||
47 | AMP@[58; 59) "&" | ||
48 | PAREN_PAT@[59; 66) | ||
49 | L_PAREN@[59; 60) "(" | ||
50 | OR_PAT@[60; 65) | ||
51 | PLACEHOLDER_PAT@[60; 61) | ||
52 | UNDERSCORE@[60; 61) "_" | ||
53 | WHITESPACE@[61; 62) " " | ||
54 | PIPE@[62; 63) "|" | ||
55 | WHITESPACE@[63; 64) " " | ||
56 | PLACEHOLDER_PAT@[64; 65) | ||
57 | UNDERSCORE@[64; 65) "_" | ||
58 | R_PAREN@[65; 66) ")" | ||
59 | WHITESPACE@[66; 67) " " | ||
60 | FAT_ARROW@[67; 69) "=>" | ||
61 | WHITESPACE@[69; 70) " " | ||
62 | TUPLE_EXPR@[70; 72) | ||
63 | L_PAREN@[70; 71) "(" | ||
64 | R_PAREN@[71; 72) ")" | ||
65 | COMMA@[72; 73) "," | ||
66 | WHITESPACE@[73; 82) "\n " | ||
67 | MATCH_ARM@[82; 96) | ||
68 | TUPLE_PAT@[82; 90) | ||
69 | L_PAREN@[82; 83) "(" | ||
70 | OR_PAT@[83; 88) | ||
71 | PLACEHOLDER_PAT@[83; 84) | ||
72 | UNDERSCORE@[83; 84) "_" | ||
73 | WHITESPACE@[84; 85) " " | ||
74 | PIPE@[85; 86) "|" | ||
75 | WHITESPACE@[86; 87) " " | ||
76 | PLACEHOLDER_PAT@[87; 88) | ||
77 | UNDERSCORE@[87; 88) "_" | ||
78 | COMMA@[88; 89) "," | ||
79 | R_PAREN@[89; 90) ")" | ||
80 | WHITESPACE@[90; 91) " " | ||
81 | FAT_ARROW@[91; 93) "=>" | ||
82 | WHITESPACE@[93; 94) " " | ||
83 | TUPLE_EXPR@[94; 96) | ||
84 | L_PAREN@[94; 95) "(" | ||
85 | R_PAREN@[95; 96) ")" | ||
86 | COMMA@[96; 97) "," | ||
87 | WHITESPACE@[97; 106) "\n " | ||
88 | MATCH_ARM@[106; 120) | ||
89 | SLICE_PAT@[106; 114) | ||
90 | L_BRACK@[106; 107) "[" | ||
91 | OR_PAT@[107; 112) | ||
92 | PLACEHOLDER_PAT@[107; 108) | ||
93 | UNDERSCORE@[107; 108) "_" | ||
94 | WHITESPACE@[108; 109) " " | ||
95 | PIPE@[109; 110) "|" | ||
96 | WHITESPACE@[110; 111) " " | ||
97 | PLACEHOLDER_PAT@[111; 112) | ||
98 | UNDERSCORE@[111; 112) "_" | ||
99 | COMMA@[112; 113) "," | ||
100 | R_BRACK@[113; 114) "]" | ||
101 | WHITESPACE@[114; 115) " " | ||
102 | FAT_ARROW@[115; 117) "=>" | ||
103 | WHITESPACE@[117; 118) " " | ||
104 | TUPLE_EXPR@[118; 120) | ||
105 | L_PAREN@[118; 119) "(" | ||
106 | R_PAREN@[119; 120) ")" | ||
107 | COMMA@[120; 121) "," | ||
108 | WHITESPACE@[121; 126) "\n " | ||
109 | R_CURLY@[126; 127) "}" | ||
110 | WHITESPACE@[127; 128) "\n" | ||
111 | R_CURLY@[128; 129) "}" | ||
112 | WHITESPACE@[129; 130) "\n" | ||