diff options
author | Aleksey Kladov <[email protected]> | 2018-07-31 21:13:08 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-07-31 21:13:08 +0100 |
commit | d82a21ab202b2f5e8c96847802d806735ec74ad3 (patch) | |
tree | aea23d0bb9760a6104f5994a73b37c869cbaf4bb | |
parent | 1af8eb9c08f974a1b3beecfebadeb03144ef337d (diff) |
lambda expressions
-rw-r--r-- | src/grammar.ron | 3 | ||||
-rw-r--r-- | src/parser/grammar/expressions.rs | 77 | ||||
-rw-r--r-- | src/parser/grammar/items/mod.rs | 63 | ||||
-rw-r--r-- | src/parser/grammar/mod.rs | 65 | ||||
-rw-r--r-- | src/parser/grammar/params.rs | 71 | ||||
-rw-r--r-- | src/parser/grammar/types.rs | 2 | ||||
-rw-r--r-- | src/syntax_kinds/generated.rs | 6 | ||||
-rw-r--r-- | tests/data/parser/inline/0063_lambda_expr.rs | 6 | ||||
-rw-r--r-- | tests/data/parser/inline/0063_lambda_expr.txt | 91 | ||||
-rw-r--r-- | tests/data/parser/inline/0064_param_list.rs (renamed from tests/data/parser/inline/0033_fn_value_parameters.rs) | 0 | ||||
-rw-r--r-- | tests/data/parser/inline/0064_param_list.txt (renamed from tests/data/parser/inline/0033_fn_value_parameters.txt) | 0 |
11 files changed, 261 insertions, 123 deletions
diff --git a/src/grammar.ron b/src/grammar.ron index df7b4083b..24f11f63e 100644 --- a/src/grammar.ron +++ b/src/grammar.ron | |||
@@ -131,6 +131,7 @@ Grammar( | |||
131 | "FIELD_EXPR", | 131 | "FIELD_EXPR", |
132 | "REF_EXPR", | 132 | "REF_EXPR", |
133 | "DEREF_EXPR", | 133 | "DEREF_EXPR", |
134 | "LAMBDA_EXPR", | ||
134 | "STRUCT_LIT", | 135 | "STRUCT_LIT", |
135 | "STRUCT_LIT_FIELD", | 136 | "STRUCT_LIT_FIELD", |
136 | 137 | ||
@@ -150,7 +151,6 @@ Grammar( | |||
150 | "ABI", | 151 | "ABI", |
151 | "NAME", | 152 | "NAME", |
152 | "NAME_REF", | 153 | "NAME_REF", |
153 | "VALUE_PARAMETER", | ||
154 | "BLOCK", | 154 | "BLOCK", |
155 | 155 | ||
156 | "LET_STMT", | 156 | "LET_STMT", |
@@ -165,6 +165,7 @@ Grammar( | |||
165 | "ASSOC_TYPE_ARG", | 165 | "ASSOC_TYPE_ARG", |
166 | 166 | ||
167 | "PARAM_LIST", | 167 | "PARAM_LIST", |
168 | "VALUE_PARAMETER", | ||
168 | "SELF_PARAM", | 169 | "SELF_PARAM", |
169 | "ARG_LIST", | 170 | "ARG_LIST", |
170 | ] | 171 | ] |
diff --git a/src/parser/grammar/expressions.rs b/src/parser/grammar/expressions.rs index ef3a0f76c..09b351f31 100644 --- a/src/parser/grammar/expressions.rs +++ b/src/parser/grammar/expressions.rs | |||
@@ -44,6 +44,63 @@ pub(super) fn expr(p: &mut Parser) { | |||
44 | } | 44 | } |
45 | } | 45 | } |
46 | 46 | ||
47 | // test block | ||
48 | // fn a() {} | ||
49 | // fn b() { let _ = 1; } | ||
50 | // fn c() { 1; 2; } | ||
51 | // fn d() { 1; 2 } | ||
52 | pub(super) fn block(p: &mut Parser) { | ||
53 | if !p.at(L_CURLY) { | ||
54 | p.error("expected block"); | ||
55 | } | ||
56 | let m = p.start(); | ||
57 | p.bump(); | ||
58 | while !p.at(EOF) && !p.at(R_CURLY) { | ||
59 | match p.current() { | ||
60 | LET_KW => let_stmt(p), | ||
61 | c => { | ||
62 | // test block_items | ||
63 | // fn a() { fn b() {} } | ||
64 | if items::ITEM_FIRST.contains(c) { | ||
65 | items::item(p) | ||
66 | } else { | ||
67 | let expr_stmt = p.start(); | ||
68 | expressions::expr(p); | ||
69 | if p.eat(SEMI) { | ||
70 | expr_stmt.complete(p, EXPR_STMT); | ||
71 | } else { | ||
72 | expr_stmt.abandon(p); | ||
73 | } | ||
74 | } | ||
75 | } | ||
76 | } | ||
77 | } | ||
78 | p.expect(R_CURLY); | ||
79 | m.complete(p, BLOCK); | ||
80 | } | ||
81 | |||
82 | // test let_stmt; | ||
83 | // fn foo() { | ||
84 | // let a; | ||
85 | // let b: i32; | ||
86 | // let c = 92; | ||
87 | // let d: i32 = 92; | ||
88 | // } | ||
89 | fn let_stmt(p: &mut Parser) { | ||
90 | assert!(p.at(LET_KW)); | ||
91 | let m = p.start(); | ||
92 | p.bump(); | ||
93 | patterns::pattern(p); | ||
94 | if p.at(COLON) { | ||
95 | types::ascription(p); | ||
96 | } | ||
97 | if p.eat(EQ) { | ||
98 | expressions::expr(p); | ||
99 | } | ||
100 | p.expect(SEMI); | ||
101 | m.complete(p, LET_STMT); | ||
102 | } | ||
103 | |||
47 | fn prefix_expr(p: &mut Parser) -> Option<CompletedMarker> { | 104 | fn prefix_expr(p: &mut Parser) -> Option<CompletedMarker> { |
48 | match p.current() { | 105 | match p.current() { |
49 | AMPERSAND => Some(ref_expr(p)), | 106 | AMPERSAND => Some(ref_expr(p)), |
@@ -89,6 +146,7 @@ fn atom_expr(p: &mut Parser) -> Option<CompletedMarker> { | |||
89 | 146 | ||
90 | match p.current() { | 147 | match p.current() { |
91 | L_PAREN => Some(tuple_expr(p)), | 148 | L_PAREN => Some(tuple_expr(p)), |
149 | PIPE => Some(lambda_expr(p)), | ||
92 | _ => { | 150 | _ => { |
93 | p.err_and_bump("expected expression"); | 151 | p.err_and_bump("expected expression"); |
94 | None | 152 | None |
@@ -104,6 +162,25 @@ fn tuple_expr(p: &mut Parser) -> CompletedMarker { | |||
104 | m.complete(p, TUPLE_EXPR) | 162 | m.complete(p, TUPLE_EXPR) |
105 | } | 163 | } |
106 | 164 | ||
165 | // test lambda_expr | ||
166 | // fn foo() { | ||
167 | // || (); | ||
168 | // || -> i32 { 92 }; | ||
169 | // |x| x; | ||
170 | // |x: i32,| x; | ||
171 | // } | ||
172 | fn lambda_expr(p: &mut Parser) -> CompletedMarker { | ||
173 | assert!(p.at(PIPE)); | ||
174 | let m = p.start(); | ||
175 | params::list_opt_types(p); | ||
176 | if fn_ret_type(p) { | ||
177 | block(p); | ||
178 | } else { | ||
179 | expr(p) | ||
180 | } | ||
181 | m.complete(p, LAMBDA_EXPR) | ||
182 | } | ||
183 | |||
107 | // test call_expr | 184 | // test call_expr |
108 | // fn foo() { | 185 | // fn foo() { |
109 | // let _ = f(); | 186 | // let _ = f(); |
diff --git a/src/parser/grammar/items/mod.rs b/src/parser/grammar/items/mod.rs index d1da1ecb4..8c2704be5 100644 --- a/src/parser/grammar/items/mod.rs +++ b/src/parser/grammar/items/mod.rs | |||
@@ -15,7 +15,7 @@ pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) { | |||
15 | pub(super) const ITEM_FIRST: TokenSet = | 15 | pub(super) const ITEM_FIRST: TokenSet = |
16 | token_set![EXTERN_KW, MOD_KW, USE_KW, STRUCT_KW, ENUM_KW, FN_KW, PUB_KW, POUND]; | 16 | token_set![EXTERN_KW, MOD_KW, USE_KW, STRUCT_KW, ENUM_KW, FN_KW, PUB_KW, POUND]; |
17 | 17 | ||
18 | fn item(p: &mut Parser) { | 18 | pub(super) fn item(p: &mut Parser) { |
19 | let item = p.start(); | 19 | let item = p.start(); |
20 | attributes::outer_attributes(p); | 20 | attributes::outer_attributes(p); |
21 | visibility(p); | 21 | visibility(p); |
@@ -239,7 +239,7 @@ fn fn_item(p: &mut Parser) { | |||
239 | type_params::list(p); | 239 | type_params::list(p); |
240 | 240 | ||
241 | if p.at(L_PAREN) { | 241 | if p.at(L_PAREN) { |
242 | fn_value_parameters(p); | 242 | params::list(p); |
243 | } else { | 243 | } else { |
244 | p.error("expected function arguments"); | 244 | p.error("expected function arguments"); |
245 | } | 245 | } |
@@ -252,64 +252,7 @@ fn fn_item(p: &mut Parser) { | |||
252 | // fn foo<T>() where T: Copy {} | 252 | // fn foo<T>() where T: Copy {} |
253 | type_params::where_clause(p); | 253 | type_params::where_clause(p); |
254 | 254 | ||
255 | block(p); | 255 | expressions::block(p); |
256 | |||
257 | // test block | ||
258 | // fn a() {} | ||
259 | // fn b() { let _ = 1; } | ||
260 | // fn c() { 1; 2; } | ||
261 | // fn d() { 1; 2 } | ||
262 | fn block(p: &mut Parser) { | ||
263 | if !p.at(L_CURLY) { | ||
264 | p.error("expected block"); | ||
265 | } | ||
266 | let m = p.start(); | ||
267 | p.bump(); | ||
268 | while !p.at(EOF) && !p.at(R_CURLY) { | ||
269 | match p.current() { | ||
270 | LET_KW => let_stmt(p), | ||
271 | c => { | ||
272 | // test block_items | ||
273 | // fn a() { fn b() {} } | ||
274 | if ITEM_FIRST.contains(c) { | ||
275 | item(p) | ||
276 | } else { | ||
277 | let expr_stmt = p.start(); | ||
278 | expressions::expr(p); | ||
279 | if p.eat(SEMI) { | ||
280 | expr_stmt.complete(p, EXPR_STMT); | ||
281 | } else { | ||
282 | expr_stmt.abandon(p); | ||
283 | } | ||
284 | } | ||
285 | } | ||
286 | } | ||
287 | } | ||
288 | p.expect(R_CURLY); | ||
289 | m.complete(p, BLOCK); | ||
290 | } | ||
291 | |||
292 | // test let_stmt; | ||
293 | // fn foo() { | ||
294 | // let a; | ||
295 | // let b: i32; | ||
296 | // let c = 92; | ||
297 | // let d: i32 = 92; | ||
298 | // } | ||
299 | fn let_stmt(p: &mut Parser) { | ||
300 | assert!(p.at(LET_KW)); | ||
301 | let m = p.start(); | ||
302 | p.bump(); | ||
303 | patterns::pattern(p); | ||
304 | if p.at(COLON) { | ||
305 | types::ascription(p); | ||
306 | } | ||
307 | if p.eat(EQ) { | ||
308 | expressions::expr(p); | ||
309 | } | ||
310 | p.expect(SEMI); | ||
311 | m.complete(p, LET_STMT); | ||
312 | } | ||
313 | } | 256 | } |
314 | 257 | ||
315 | // test type_item | 258 | // test type_item |
diff --git a/src/parser/grammar/mod.rs b/src/parser/grammar/mod.rs index 69942e7f1..d4f9b80cf 100644 --- a/src/parser/grammar/mod.rs +++ b/src/parser/grammar/mod.rs | |||
@@ -26,8 +26,9 @@ mod expressions; | |||
26 | mod items; | 26 | mod items; |
27 | mod paths; | 27 | mod paths; |
28 | mod patterns; | 28 | mod patterns; |
29 | mod type_args; | 29 | mod params; |
30 | mod type_params; | 30 | mod type_params; |
31 | mod type_args; | ||
31 | mod types; | 32 | mod types; |
32 | 33 | ||
33 | use { | 34 | use { |
@@ -95,67 +96,13 @@ fn abi(p: &mut Parser) { | |||
95 | abi.complete(p, ABI); | 96 | abi.complete(p, ABI); |
96 | } | 97 | } |
97 | 98 | ||
98 | // test fn_value_parameters | 99 | fn fn_ret_type(p: &mut Parser) -> bool { |
99 | // fn a() {} | ||
100 | // fn b(x: i32) {} | ||
101 | // fn c(x: i32, ) {} | ||
102 | // fn d(x: i32, y: ()) {} | ||
103 | fn fn_value_parameters(p: &mut Parser) { | ||
104 | assert!(p.at(L_PAREN)); | ||
105 | let m = p.start(); | ||
106 | p.bump(); | ||
107 | self_param(p); | ||
108 | while !p.at(EOF) && !p.at(R_PAREN) { | ||
109 | value_parameter(p); | ||
110 | if !p.at(R_PAREN) { | ||
111 | p.expect(COMMA); | ||
112 | } | ||
113 | } | ||
114 | p.expect(R_PAREN); | ||
115 | m.complete(p, PARAM_LIST); | ||
116 | |||
117 | fn value_parameter(p: &mut Parser) { | ||
118 | let m = p.start(); | ||
119 | patterns::pattern(p); | ||
120 | p.expect(COLON); | ||
121 | types::type_(p); | ||
122 | m.complete(p, VALUE_PARAMETER); | ||
123 | } | ||
124 | |||
125 | // test self_param | ||
126 | // impl S { | ||
127 | // fn a(self) {} | ||
128 | // fn b(&self,) {} | ||
129 | // fn c(&'a self,) {} | ||
130 | // fn d(&'a mut self, x: i32) {} | ||
131 | // } | ||
132 | fn self_param(p: &mut Parser) { | ||
133 | let la1 = p.nth(1); | ||
134 | let la2 = p.nth(2); | ||
135 | let la3 = p.nth(3); | ||
136 | let n_toks = match (p.current(), la1, la2, la3) { | ||
137 | (SELF_KW, _, _, _) => 1, | ||
138 | (AMPERSAND, SELF_KW, _, _) => 2, | ||
139 | (AMPERSAND, MUT_KW, SELF_KW, _) => 3, | ||
140 | (AMPERSAND, LIFETIME, SELF_KW, _) => 3, | ||
141 | (AMPERSAND, LIFETIME, MUT_KW, SELF_KW) => 4, | ||
142 | _ => return, | ||
143 | }; | ||
144 | let m = p.start(); | ||
145 | for _ in 0..n_toks { | ||
146 | p.bump(); | ||
147 | } | ||
148 | m.complete(p, SELF_PARAM); | ||
149 | if !p.at(R_PAREN) { | ||
150 | p.expect(COMMA); | ||
151 | } | ||
152 | } | ||
153 | } | ||
154 | |||
155 | fn fn_ret_type(p: &mut Parser) { | ||
156 | if p.at(THIN_ARROW) { | 100 | if p.at(THIN_ARROW) { |
157 | p.bump(); | 101 | p.bump(); |
158 | types::type_(p); | 102 | types::type_(p); |
103 | true | ||
104 | } else { | ||
105 | false | ||
159 | } | 106 | } |
160 | } | 107 | } |
161 | 108 | ||
diff --git a/src/parser/grammar/params.rs b/src/parser/grammar/params.rs new file mode 100644 index 000000000..1ef2cea88 --- /dev/null +++ b/src/parser/grammar/params.rs | |||
@@ -0,0 +1,71 @@ | |||
1 | use super::*; | ||
2 | |||
3 | // test param_list | ||
4 | // fn a() {} | ||
5 | // fn b(x: i32) {} | ||
6 | // fn c(x: i32, ) {} | ||
7 | // fn d(x: i32, y: ()) {} | ||
8 | pub(super) fn list(p: &mut Parser) { | ||
9 | list_(p, true) | ||
10 | } | ||
11 | |||
12 | pub(super) fn list_opt_types(p: &mut Parser) { | ||
13 | list_(p, false) | ||
14 | } | ||
15 | |||
16 | fn list_(p: &mut Parser, require_types: bool) { | ||
17 | assert!(p.at(if require_types { L_PAREN } else { PIPE })); | ||
18 | let m = p.start(); | ||
19 | p.bump(); | ||
20 | if require_types { | ||
21 | self_param(p); | ||
22 | } | ||
23 | let terminator = if require_types { R_PAREN } else { PIPE }; | ||
24 | while !p.at(EOF) && !p.at(terminator) { | ||
25 | value_parameter(p, require_types); | ||
26 | if !p.at(terminator) { | ||
27 | p.expect(COMMA); | ||
28 | } | ||
29 | } | ||
30 | p.expect(terminator); | ||
31 | m.complete(p, PARAM_LIST); | ||
32 | } | ||
33 | |||
34 | fn value_parameter(p: &mut Parser, require_type: bool) { | ||
35 | let m = p.start(); | ||
36 | patterns::pattern(p); | ||
37 | if p.at(COLON) || require_type { | ||
38 | types::ascription(p) | ||
39 | } | ||
40 | m.complete(p, VALUE_PARAMETER); | ||
41 | } | ||
42 | |||
43 | // test self_param | ||
44 | // impl S { | ||
45 | // fn a(self) {} | ||
46 | // fn b(&self,) {} | ||
47 | // fn c(&'a self,) {} | ||
48 | // fn d(&'a mut self, x: i32) {} | ||
49 | // } | ||
50 | fn self_param(p: &mut Parser) { | ||
51 | let la1 = p.nth(1); | ||
52 | let la2 = p.nth(2); | ||
53 | let la3 = p.nth(3); | ||
54 | let n_toks = match (p.current(), la1, la2, la3) { | ||
55 | (SELF_KW, _, _, _) => 1, | ||
56 | (AMPERSAND, SELF_KW, _, _) => 2, | ||
57 | (AMPERSAND, MUT_KW, SELF_KW, _) => 3, | ||
58 | (AMPERSAND, LIFETIME, SELF_KW, _) => 3, | ||
59 | (AMPERSAND, LIFETIME, MUT_KW, SELF_KW) => 4, | ||
60 | _ => return, | ||
61 | }; | ||
62 | let m = p.start(); | ||
63 | for _ in 0..n_toks { | ||
64 | p.bump(); | ||
65 | } | ||
66 | m.complete(p, SELF_PARAM); | ||
67 | if !p.at(R_PAREN) { | ||
68 | p.expect(COMMA); | ||
69 | } | ||
70 | } | ||
71 | |||
diff --git a/src/parser/grammar/types.rs b/src/parser/grammar/types.rs index 31871ceec..6535f6872 100644 --- a/src/parser/grammar/types.rs +++ b/src/parser/grammar/types.rs | |||
@@ -166,7 +166,7 @@ fn fn_pointer_type(p: &mut Parser) { | |||
166 | return; | 166 | return; |
167 | } | 167 | } |
168 | 168 | ||
169 | fn_value_parameters(p); | 169 | params::list(p); |
170 | // test fn_pointer_type_with_ret | 170 | // test fn_pointer_type_with_ret |
171 | // type F = fn() -> (); | 171 | // type F = fn() -> (); |
172 | fn_ret_type(p); | 172 | fn_ret_type(p); |
diff --git a/src/syntax_kinds/generated.rs b/src/syntax_kinds/generated.rs index 156d42db4..93a3250a4 100644 --- a/src/syntax_kinds/generated.rs +++ b/src/syntax_kinds/generated.rs | |||
@@ -122,6 +122,7 @@ pub enum SyntaxKind { | |||
122 | FIELD_EXPR, | 122 | FIELD_EXPR, |
123 | REF_EXPR, | 123 | REF_EXPR, |
124 | DEREF_EXPR, | 124 | DEREF_EXPR, |
125 | LAMBDA_EXPR, | ||
125 | STRUCT_LIT, | 126 | STRUCT_LIT, |
126 | STRUCT_LIT_FIELD, | 127 | STRUCT_LIT_FIELD, |
127 | EXTERN_BLOCK, | 128 | EXTERN_BLOCK, |
@@ -140,7 +141,6 @@ pub enum SyntaxKind { | |||
140 | ABI, | 141 | ABI, |
141 | NAME, | 142 | NAME, |
142 | NAME_REF, | 143 | NAME_REF, |
143 | VALUE_PARAMETER, | ||
144 | BLOCK, | 144 | BLOCK, |
145 | LET_STMT, | 145 | LET_STMT, |
146 | EXPR_STMT, | 146 | EXPR_STMT, |
@@ -152,6 +152,7 @@ pub enum SyntaxKind { | |||
152 | TYPE_ARG, | 152 | TYPE_ARG, |
153 | ASSOC_TYPE_ARG, | 153 | ASSOC_TYPE_ARG, |
154 | PARAM_LIST, | 154 | PARAM_LIST, |
155 | VALUE_PARAMETER, | ||
155 | SELF_PARAM, | 156 | SELF_PARAM, |
156 | ARG_LIST, | 157 | ARG_LIST, |
157 | // Technical SyntaxKinds: they appear temporally during parsing, | 158 | // Technical SyntaxKinds: they appear temporally during parsing, |
@@ -283,6 +284,7 @@ impl SyntaxKind { | |||
283 | FIELD_EXPR => &SyntaxInfo { name: "FIELD_EXPR" }, | 284 | FIELD_EXPR => &SyntaxInfo { name: "FIELD_EXPR" }, |
284 | REF_EXPR => &SyntaxInfo { name: "REF_EXPR" }, | 285 | REF_EXPR => &SyntaxInfo { name: "REF_EXPR" }, |
285 | DEREF_EXPR => &SyntaxInfo { name: "DEREF_EXPR" }, | 286 | DEREF_EXPR => &SyntaxInfo { name: "DEREF_EXPR" }, |
287 | LAMBDA_EXPR => &SyntaxInfo { name: "LAMBDA_EXPR" }, | ||
286 | STRUCT_LIT => &SyntaxInfo { name: "STRUCT_LIT" }, | 288 | STRUCT_LIT => &SyntaxInfo { name: "STRUCT_LIT" }, |
287 | STRUCT_LIT_FIELD => &SyntaxInfo { name: "STRUCT_LIT_FIELD" }, | 289 | STRUCT_LIT_FIELD => &SyntaxInfo { name: "STRUCT_LIT_FIELD" }, |
288 | EXTERN_BLOCK => &SyntaxInfo { name: "EXTERN_BLOCK" }, | 290 | EXTERN_BLOCK => &SyntaxInfo { name: "EXTERN_BLOCK" }, |
@@ -301,7 +303,6 @@ impl SyntaxKind { | |||
301 | ABI => &SyntaxInfo { name: "ABI" }, | 303 | ABI => &SyntaxInfo { name: "ABI" }, |
302 | NAME => &SyntaxInfo { name: "NAME" }, | 304 | NAME => &SyntaxInfo { name: "NAME" }, |
303 | NAME_REF => &SyntaxInfo { name: "NAME_REF" }, | 305 | NAME_REF => &SyntaxInfo { name: "NAME_REF" }, |
304 | VALUE_PARAMETER => &SyntaxInfo { name: "VALUE_PARAMETER" }, | ||
305 | BLOCK => &SyntaxInfo { name: "BLOCK" }, | 306 | BLOCK => &SyntaxInfo { name: "BLOCK" }, |
306 | LET_STMT => &SyntaxInfo { name: "LET_STMT" }, | 307 | LET_STMT => &SyntaxInfo { name: "LET_STMT" }, |
307 | EXPR_STMT => &SyntaxInfo { name: "EXPR_STMT" }, | 308 | EXPR_STMT => &SyntaxInfo { name: "EXPR_STMT" }, |
@@ -313,6 +314,7 @@ impl SyntaxKind { | |||
313 | TYPE_ARG => &SyntaxInfo { name: "TYPE_ARG" }, | 314 | TYPE_ARG => &SyntaxInfo { name: "TYPE_ARG" }, |
314 | ASSOC_TYPE_ARG => &SyntaxInfo { name: "ASSOC_TYPE_ARG" }, | 315 | ASSOC_TYPE_ARG => &SyntaxInfo { name: "ASSOC_TYPE_ARG" }, |
315 | PARAM_LIST => &SyntaxInfo { name: "PARAM_LIST" }, | 316 | PARAM_LIST => &SyntaxInfo { name: "PARAM_LIST" }, |
317 | VALUE_PARAMETER => &SyntaxInfo { name: "VALUE_PARAMETER" }, | ||
316 | SELF_PARAM => &SyntaxInfo { name: "SELF_PARAM" }, | 318 | SELF_PARAM => &SyntaxInfo { name: "SELF_PARAM" }, |
317 | ARG_LIST => &SyntaxInfo { name: "ARG_LIST" }, | 319 | ARG_LIST => &SyntaxInfo { name: "ARG_LIST" }, |
318 | TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" }, | 320 | TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" }, |
diff --git a/tests/data/parser/inline/0063_lambda_expr.rs b/tests/data/parser/inline/0063_lambda_expr.rs new file mode 100644 index 000000000..3c30a9209 --- /dev/null +++ b/tests/data/parser/inline/0063_lambda_expr.rs | |||
@@ -0,0 +1,6 @@ | |||
1 | fn foo() { | ||
2 | || (); | ||
3 | || -> i32 { 92 }; | ||
4 | |x| x; | ||
5 | |x: i32,| x; | ||
6 | } | ||
diff --git a/tests/data/parser/inline/0063_lambda_expr.txt b/tests/data/parser/inline/0063_lambda_expr.txt new file mode 100644 index 000000000..b1edffc14 --- /dev/null +++ b/tests/data/parser/inline/0063_lambda_expr.txt | |||
@@ -0,0 +1,91 @@ | |||
1 | FILE@[0; 74) | ||
2 | FN_ITEM@[0; 74) | ||
3 | FN_KW@[0; 2) | ||
4 | NAME@[2; 6) | ||
5 | WHITESPACE@[2; 3) | ||
6 | IDENT@[3; 6) "foo" | ||
7 | PARAM_LIST@[6; 9) | ||
8 | L_PAREN@[6; 7) | ||
9 | R_PAREN@[7; 8) | ||
10 | WHITESPACE@[8; 9) | ||
11 | BLOCK@[9; 74) | ||
12 | L_CURLY@[9; 10) | ||
13 | EXPR_STMT@[10; 26) | ||
14 | LAMBDA_EXPR@[10; 20) | ||
15 | PARAM_LIST@[10; 18) | ||
16 | WHITESPACE@[10; 15) | ||
17 | PIPE@[15; 16) | ||
18 | PIPE@[16; 17) | ||
19 | WHITESPACE@[17; 18) | ||
20 | TUPLE_EXPR@[18; 20) | ||
21 | L_PAREN@[18; 19) | ||
22 | R_PAREN@[19; 20) | ||
23 | SEMI@[20; 21) | ||
24 | WHITESPACE@[21; 26) | ||
25 | EXPR_STMT@[26; 48) | ||
26 | LAMBDA_EXPR@[26; 42) | ||
27 | PARAM_LIST@[26; 29) | ||
28 | PIPE@[26; 27) | ||
29 | PIPE@[27; 28) | ||
30 | WHITESPACE@[28; 29) | ||
31 | THIN_ARROW@[29; 31) | ||
32 | PATH_TYPE@[31; 36) | ||
33 | PATH@[31; 36) | ||
34 | PATH_SEGMENT@[31; 36) | ||
35 | NAME_REF@[31; 36) | ||
36 | WHITESPACE@[31; 32) | ||
37 | IDENT@[32; 35) "i32" | ||
38 | WHITESPACE@[35; 36) | ||
39 | BLOCK@[36; 42) | ||
40 | L_CURLY@[36; 37) | ||
41 | LITERAL@[37; 41) | ||
42 | WHITESPACE@[37; 38) | ||
43 | INT_NUMBER@[38; 40) | ||
44 | WHITESPACE@[40; 41) | ||
45 | R_CURLY@[41; 42) | ||
46 | SEMI@[42; 43) | ||
47 | WHITESPACE@[43; 48) | ||
48 | EXPR_STMT@[48; 59) | ||
49 | LAMBDA_EXPR@[48; 53) | ||
50 | PARAM_LIST@[48; 52) | ||
51 | PIPE@[48; 49) | ||
52 | VALUE_PARAMETER@[49; 50) | ||
53 | BIND_PAT@[49; 50) | ||
54 | NAME@[49; 50) | ||
55 | IDENT@[49; 50) "x" | ||
56 | PIPE@[50; 51) | ||
57 | WHITESPACE@[51; 52) | ||
58 | PATH_EXPR@[52; 53) | ||
59 | PATH@[52; 53) | ||
60 | PATH_SEGMENT@[52; 53) | ||
61 | NAME_REF@[52; 53) | ||
62 | IDENT@[52; 53) "x" | ||
63 | SEMI@[53; 54) | ||
64 | WHITESPACE@[54; 59) | ||
65 | EXPR_STMT@[59; 72) | ||
66 | LAMBDA_EXPR@[59; 70) | ||
67 | PARAM_LIST@[59; 69) | ||
68 | PIPE@[59; 60) | ||
69 | VALUE_PARAMETER@[60; 66) | ||
70 | BIND_PAT@[60; 61) | ||
71 | NAME@[60; 61) | ||
72 | IDENT@[60; 61) "x" | ||
73 | COLON@[61; 62) | ||
74 | PATH_TYPE@[62; 66) | ||
75 | PATH@[62; 66) | ||
76 | PATH_SEGMENT@[62; 66) | ||
77 | NAME_REF@[62; 66) | ||
78 | WHITESPACE@[62; 63) | ||
79 | IDENT@[63; 66) "i32" | ||
80 | COMMA@[66; 67) | ||
81 | PIPE@[67; 68) | ||
82 | WHITESPACE@[68; 69) | ||
83 | PATH_EXPR@[69; 70) | ||
84 | PATH@[69; 70) | ||
85 | PATH_SEGMENT@[69; 70) | ||
86 | NAME_REF@[69; 70) | ||
87 | IDENT@[69; 70) "x" | ||
88 | SEMI@[70; 71) | ||
89 | WHITESPACE@[71; 72) | ||
90 | R_CURLY@[72; 73) | ||
91 | WHITESPACE@[73; 74) | ||
diff --git a/tests/data/parser/inline/0033_fn_value_parameters.rs b/tests/data/parser/inline/0064_param_list.rs index 9d55bedbb..9d55bedbb 100644 --- a/tests/data/parser/inline/0033_fn_value_parameters.rs +++ b/tests/data/parser/inline/0064_param_list.rs | |||
diff --git a/tests/data/parser/inline/0033_fn_value_parameters.txt b/tests/data/parser/inline/0064_param_list.txt index 96e03d71a..96e03d71a 100644 --- a/tests/data/parser/inline/0033_fn_value_parameters.txt +++ b/tests/data/parser/inline/0064_param_list.txt | |||