diff options
Diffstat (limited to 'crates/parser')
-rw-r--r-- | crates/parser/src/grammar.rs | 12 | ||||
-rw-r--r-- | crates/parser/src/grammar/expressions/atom.rs | 28 | ||||
-rw-r--r-- | crates/parser/src/grammar/items.rs | 28 | ||||
-rw-r--r-- | crates/parser/src/grammar/items/traits.rs | 2 | ||||
-rw-r--r-- | crates/parser/src/grammar/items/use_item.rs | 2 | ||||
-rw-r--r-- | crates/parser/src/grammar/params.rs | 31 | ||||
-rw-r--r-- | crates/parser/src/grammar/paths.rs | 6 | ||||
-rw-r--r-- | crates/parser/src/grammar/patterns.rs | 2 | ||||
-rw-r--r-- | crates/parser/src/grammar/type_args.rs | 6 | ||||
-rw-r--r-- | crates/parser/src/grammar/type_params.rs | 4 | ||||
-rw-r--r-- | crates/parser/src/parser.rs | 16 | ||||
-rw-r--r-- | crates/parser/src/syntax_kind.rs | 3 | ||||
-rw-r--r-- | crates/parser/src/syntax_kind/generated.rs | 9 |
13 files changed, 107 insertions, 42 deletions
diff --git a/crates/parser/src/grammar.rs b/crates/parser/src/grammar.rs index bb9ffea8b..6913e9ec2 100644 --- a/crates/parser/src/grammar.rs +++ b/crates/parser/src/grammar.rs | |||
@@ -190,17 +190,25 @@ fn opt_visibility(p: &mut Parser) -> bool { | |||
190 | // test crate_visibility | 190 | // test crate_visibility |
191 | // pub(crate) struct S; | 191 | // pub(crate) struct S; |
192 | // pub(self) struct S; | 192 | // pub(self) struct S; |
193 | // pub(self) struct S; | 193 | // pub(super) struct S; |
194 | // pub(self) struct S; | ||
195 | 194 | ||
196 | // test pub_parens_typepath | 195 | // test pub_parens_typepath |
197 | // struct B(pub (super::A)); | 196 | // struct B(pub (super::A)); |
198 | // struct B(pub (crate::A,)); | 197 | // struct B(pub (crate::A,)); |
199 | T![crate] | T![self] | T![super] if p.nth(2) != T![:] => { | 198 | T![crate] | T![self] | T![super] if p.nth(2) != T![:] => { |
200 | p.bump_any(); | 199 | p.bump_any(); |
200 | let path_m = p.start(); | ||
201 | let path_segment_m = p.start(); | ||
202 | let name_ref_m = p.start(); | ||
201 | p.bump_any(); | 203 | p.bump_any(); |
204 | name_ref_m.complete(p, NAME_REF); | ||
205 | path_segment_m.complete(p, PATH_SEGMENT); | ||
206 | path_m.complete(p, PATH); | ||
202 | p.expect(T![')']); | 207 | p.expect(T![')']); |
203 | } | 208 | } |
209 | // test crate_visibility_in | ||
210 | // pub(in super::A) struct S; | ||
211 | // pub(in crate) struct S; | ||
204 | T![in] => { | 212 | T![in] => { |
205 | p.bump_any(); | 213 | p.bump_any(); |
206 | p.bump_any(); | 214 | p.bump_any(); |
diff --git a/crates/parser/src/grammar/expressions/atom.rs b/crates/parser/src/grammar/expressions/atom.rs index c7a3556a7..093a9890d 100644 --- a/crates/parser/src/grammar/expressions/atom.rs +++ b/crates/parser/src/grammar/expressions/atom.rs | |||
@@ -15,8 +15,16 @@ use super::*; | |||
15 | // let _ = b"e"; | 15 | // let _ = b"e"; |
16 | // let _ = br"f"; | 16 | // let _ = br"f"; |
17 | // } | 17 | // } |
18 | pub(crate) const LITERAL_FIRST: TokenSet = | 18 | pub(crate) const LITERAL_FIRST: TokenSet = TokenSet::new(&[ |
19 | TokenSet::new(&[TRUE_KW, FALSE_KW, INT_NUMBER, FLOAT_NUMBER, BYTE, CHAR, STRING, BYTE_STRING]); | 19 | T![true], |
20 | T![false], | ||
21 | INT_NUMBER, | ||
22 | FLOAT_NUMBER, | ||
23 | BYTE, | ||
24 | CHAR, | ||
25 | STRING, | ||
26 | BYTE_STRING, | ||
27 | ]); | ||
20 | 28 | ||
21 | pub(crate) fn literal(p: &mut Parser) -> Option<CompletedMarker> { | 29 | pub(crate) fn literal(p: &mut Parser) -> Option<CompletedMarker> { |
22 | if !p.at_ts(LITERAL_FIRST) { | 30 | if !p.at_ts(LITERAL_FIRST) { |
@@ -42,6 +50,7 @@ pub(super) const ATOM_EXPR_FIRST: TokenSet = | |||
42 | T![match], | 50 | T![match], |
43 | T![unsafe], | 51 | T![unsafe], |
44 | T![return], | 52 | T![return], |
53 | T![yield], | ||
45 | T![break], | 54 | T![break], |
46 | T![continue], | 55 | T![continue], |
47 | T![async], | 56 | T![async], |
@@ -134,6 +143,7 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar | |||
134 | block_expr_unchecked(p) | 143 | block_expr_unchecked(p) |
135 | } | 144 | } |
136 | T![return] => return_expr(p), | 145 | T![return] => return_expr(p), |
146 | T![yield] => yield_expr(p), | ||
137 | T![continue] => continue_expr(p), | 147 | T![continue] => continue_expr(p), |
138 | T![break] => break_expr(p, r), | 148 | T![break] => break_expr(p, r), |
139 | _ => { | 149 | _ => { |
@@ -500,6 +510,20 @@ fn return_expr(p: &mut Parser) -> CompletedMarker { | |||
500 | } | 510 | } |
501 | m.complete(p, RETURN_EXPR) | 511 | m.complete(p, RETURN_EXPR) |
502 | } | 512 | } |
513 | // test yield_expr | ||
514 | // fn foo() { | ||
515 | // yield; | ||
516 | // yield 1; | ||
517 | // } | ||
518 | fn yield_expr(p: &mut Parser) -> CompletedMarker { | ||
519 | assert!(p.at(T![yield])); | ||
520 | let m = p.start(); | ||
521 | p.bump(T![yield]); | ||
522 | if p.at_ts(EXPR_FIRST) { | ||
523 | expr(p); | ||
524 | } | ||
525 | m.complete(p, YIELD_EXPR) | ||
526 | } | ||
503 | 527 | ||
504 | // test continue_expr | 528 | // test continue_expr |
505 | // fn foo() { | 529 | // fn foo() { |
diff --git a/crates/parser/src/grammar/items.rs b/crates/parser/src/grammar/items.rs index cf4168d32..1d894e907 100644 --- a/crates/parser/src/grammar/items.rs +++ b/crates/parser/src/grammar/items.rs | |||
@@ -27,19 +27,19 @@ pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) { | |||
27 | } | 27 | } |
28 | 28 | ||
29 | pub(super) const ITEM_RECOVERY_SET: TokenSet = TokenSet::new(&[ | 29 | pub(super) const ITEM_RECOVERY_SET: TokenSet = TokenSet::new(&[ |
30 | FN_KW, | 30 | T![fn], |
31 | STRUCT_KW, | 31 | T![struct], |
32 | ENUM_KW, | 32 | T![enum], |
33 | IMPL_KW, | 33 | T![impl], |
34 | TRAIT_KW, | 34 | T![trait], |
35 | CONST_KW, | 35 | T![const], |
36 | STATIC_KW, | 36 | T![static], |
37 | LET_KW, | 37 | T![let], |
38 | MOD_KW, | 38 | T![mod], |
39 | PUB_KW, | 39 | T![pub], |
40 | CRATE_KW, | 40 | T![crate], |
41 | USE_KW, | 41 | T![use], |
42 | MACRO_KW, | 42 | T![macro], |
43 | T![;], | 43 | T![;], |
44 | ]); | 44 | ]); |
45 | 45 | ||
@@ -270,7 +270,9 @@ fn extern_crate(p: &mut Parser, m: Marker) { | |||
270 | p.bump(T![crate]); | 270 | p.bump(T![crate]); |
271 | 271 | ||
272 | if p.at(T![self]) { | 272 | if p.at(T![self]) { |
273 | let m = p.start(); | ||
273 | p.bump(T![self]); | 274 | p.bump(T![self]); |
275 | m.complete(p, NAME_REF); | ||
274 | } else { | 276 | } else { |
275 | name_ref(p); | 277 | name_ref(p); |
276 | } | 278 | } |
diff --git a/crates/parser/src/grammar/items/traits.rs b/crates/parser/src/grammar/items/traits.rs index ab9a12b4d..d076974ed 100644 --- a/crates/parser/src/grammar/items/traits.rs +++ b/crates/parser/src/grammar/items/traits.rs | |||
@@ -110,7 +110,7 @@ fn choose_type_params_over_qpath(p: &Parser) -> bool { | |||
110 | if !p.at(T![<]) { | 110 | if !p.at(T![<]) { |
111 | return false; | 111 | return false; |
112 | } | 112 | } |
113 | if p.nth(1) == T![#] || p.nth(1) == T![>] || p.nth(1) == CONST_KW { | 113 | if p.nth(1) == T![#] || p.nth(1) == T![>] || p.nth(1) == T![const] { |
114 | return true; | 114 | return true; |
115 | } | 115 | } |
116 | (p.nth(1) == LIFETIME_IDENT || p.nth(1) == IDENT) | 116 | (p.nth(1) == LIFETIME_IDENT || p.nth(1) == IDENT) |
diff --git a/crates/parser/src/grammar/items/use_item.rs b/crates/parser/src/grammar/items/use_item.rs index 20e6a13cf..5cb8b08e7 100644 --- a/crates/parser/src/grammar/items/use_item.rs +++ b/crates/parser/src/grammar/items/use_item.rs | |||
@@ -46,7 +46,7 @@ fn use_tree(p: &mut Parser, top_level: bool) { | |||
46 | // test use_tree_list | 46 | // test use_tree_list |
47 | // use {crate::path::from::root, or::path::from::crate_name}; // Rust 2018 (with a crate named `or`) | 47 | // use {crate::path::from::root, or::path::from::crate_name}; // Rust 2018 (with a crate named `or`) |
48 | // use {path::from::root}; // Rust 2015 | 48 | // use {path::from::root}; // Rust 2015 |
49 | // use ::{some::arbritrary::path}; // Rust 2015 | 49 | // use ::{some::arbitrary::path}; // Rust 2015 |
50 | // use ::{{{root::export}}}; // Nonsensical but perfectly legal nesting | 50 | // use ::{{{root::export}}}; // Nonsensical but perfectly legal nesting |
51 | T!['{'] => { | 51 | T!['{'] => { |
52 | use_tree_list(p); | 52 | use_tree_list(p); |
diff --git a/crates/parser/src/grammar/params.rs b/crates/parser/src/grammar/params.rs index 2d006a1d5..6a98d7368 100644 --- a/crates/parser/src/grammar/params.rs +++ b/crates/parser/src/grammar/params.rs | |||
@@ -156,7 +156,7 @@ fn variadic_param(p: &mut Parser) -> bool { | |||
156 | fn opt_self_param(p: &mut Parser, m: Marker) { | 156 | fn opt_self_param(p: &mut Parser, m: Marker) { |
157 | if p.at(T![self]) || p.at(T![mut]) && p.nth(1) == T![self] { | 157 | if p.at(T![self]) || p.at(T![mut]) && p.nth(1) == T![self] { |
158 | p.eat(T![mut]); | 158 | p.eat(T![mut]); |
159 | p.eat(T![self]); | 159 | self_as_name(p); |
160 | // test arb_self_types | 160 | // test arb_self_types |
161 | // impl S { | 161 | // impl S { |
162 | // fn a(self: &Self) {} | 162 | // fn a(self: &Self) {} |
@@ -169,24 +169,29 @@ fn opt_self_param(p: &mut Parser, m: Marker) { | |||
169 | let la1 = p.nth(1); | 169 | let la1 = p.nth(1); |
170 | let la2 = p.nth(2); | 170 | let la2 = p.nth(2); |
171 | let la3 = p.nth(3); | 171 | let la3 = p.nth(3); |
172 | let mut n_toks = match (p.current(), la1, la2, la3) { | 172 | if !matches!((p.current(), la1, la2, la3), |
173 | (T![&], T![self], _, _) => 2, | 173 | (T![&], T![self], _, _) |
174 | (T![&], T![mut], T![self], _) => 3, | 174 | | (T![&], T![mut], T![self], _) |
175 | (T![&], LIFETIME_IDENT, T![self], _) => 3, | 175 | | (T![&], LIFETIME_IDENT, T![self], _) |
176 | (T![&], LIFETIME_IDENT, T![mut], T![self]) => 4, | 176 | | (T![&], LIFETIME_IDENT, T![mut], T![self]) |
177 | _ => return m.abandon(p), | 177 | ) { |
178 | }; | 178 | return m.abandon(p); |
179 | p.bump_any(); | 179 | } |
180 | p.bump(T![&]); | ||
180 | if p.at(LIFETIME_IDENT) { | 181 | if p.at(LIFETIME_IDENT) { |
181 | lifetime(p); | 182 | lifetime(p); |
182 | n_toks -= 1; | ||
183 | } | ||
184 | for _ in 1..n_toks { | ||
185 | p.bump_any(); | ||
186 | } | 183 | } |
184 | p.eat(T![mut]); | ||
185 | self_as_name(p); | ||
187 | } | 186 | } |
188 | m.complete(p, SELF_PARAM); | 187 | m.complete(p, SELF_PARAM); |
189 | if !p.at(T![')']) { | 188 | if !p.at(T![')']) { |
190 | p.expect(T![,]); | 189 | p.expect(T![,]); |
191 | } | 190 | } |
192 | } | 191 | } |
192 | |||
193 | fn self_as_name(p: &mut Parser) { | ||
194 | let m = p.start(); | ||
195 | p.bump(T![self]); | ||
196 | m.complete(p, NAME); | ||
197 | } | ||
diff --git a/crates/parser/src/grammar/paths.rs b/crates/parser/src/grammar/paths.rs index 5d297e2d6..b10f48fe1 100644 --- a/crates/parser/src/grammar/paths.rs +++ b/crates/parser/src/grammar/paths.rs | |||
@@ -82,7 +82,11 @@ fn path_segment(p: &mut Parser, mode: Mode, first: bool) { | |||
82 | } | 82 | } |
83 | // test crate_path | 83 | // test crate_path |
84 | // use crate::foo; | 84 | // use crate::foo; |
85 | T![self] | T![super] | T![crate] => p.bump_any(), | 85 | T![self] | T![super] | T![crate] => { |
86 | let m = p.start(); | ||
87 | p.bump_any(); | ||
88 | m.complete(p, NAME_REF); | ||
89 | } | ||
86 | _ => { | 90 | _ => { |
87 | p.err_recover("expected identifier", items::ITEM_RECOVERY_SET); | 91 | p.err_recover("expected identifier", items::ITEM_RECOVERY_SET); |
88 | if empty { | 92 | if empty { |
diff --git a/crates/parser/src/grammar/patterns.rs b/crates/parser/src/grammar/patterns.rs index b53d5749f..da71498a8 100644 --- a/crates/parser/src/grammar/patterns.rs +++ b/crates/parser/src/grammar/patterns.rs | |||
@@ -83,7 +83,7 @@ fn pattern_single_r(p: &mut Parser, recovery_set: TokenSet) { | |||
83 | } | 83 | } |
84 | 84 | ||
85 | const PAT_RECOVERY_SET: TokenSet = | 85 | const PAT_RECOVERY_SET: TokenSet = |
86 | TokenSet::new(&[LET_KW, IF_KW, WHILE_KW, LOOP_KW, MATCH_KW, R_PAREN, COMMA]); | 86 | TokenSet::new(&[T![let], T![if], T![while], T![loop], T![match], T![')'], T![,]]); |
87 | 87 | ||
88 | fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option<CompletedMarker> { | 88 | fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option<CompletedMarker> { |
89 | let m = match p.nth(0) { | 89 | let m = match p.nth(0) { |
diff --git a/crates/parser/src/grammar/type_args.rs b/crates/parser/src/grammar/type_args.rs index a013c49b9..42cd426bd 100644 --- a/crates/parser/src/grammar/type_args.rs +++ b/crates/parser/src/grammar/type_args.rs | |||
@@ -26,7 +26,7 @@ pub(super) fn opt_generic_arg_list(p: &mut Parser, colon_colon_required: bool) { | |||
26 | } | 26 | } |
27 | 27 | ||
28 | // test type_arg | 28 | // test type_arg |
29 | // type A = B<'static, i32, 1, { 2 }, Item=u64>; | 29 | // type A = B<'static, i32, 1, { 2 }, Item=u64, true, false>; |
30 | fn generic_arg(p: &mut Parser) { | 30 | fn generic_arg(p: &mut Parser) { |
31 | let m = p.start(); | 31 | let m = p.start(); |
32 | match p.current() { | 32 | match p.current() { |
@@ -55,6 +55,10 @@ fn generic_arg(p: &mut Parser) { | |||
55 | expressions::literal(p); | 55 | expressions::literal(p); |
56 | m.complete(p, CONST_ARG); | 56 | m.complete(p, CONST_ARG); |
57 | } | 57 | } |
58 | T![true] | T![false] => { | ||
59 | expressions::literal(p); | ||
60 | m.complete(p, CONST_ARG); | ||
61 | } | ||
58 | _ => { | 62 | _ => { |
59 | types::type_(p); | 63 | types::type_(p); |
60 | m.complete(p, TYPE_ARG); | 64 | m.complete(p, TYPE_ARG); |
diff --git a/crates/parser/src/grammar/type_params.rs b/crates/parser/src/grammar/type_params.rs index 4aeccd193..3de5248da 100644 --- a/crates/parser/src/grammar/type_params.rs +++ b/crates/parser/src/grammar/type_params.rs | |||
@@ -25,7 +25,7 @@ fn generic_param_list(p: &mut Parser) { | |||
25 | match p.current() { | 25 | match p.current() { |
26 | LIFETIME_IDENT => lifetime_param(p, m), | 26 | LIFETIME_IDENT => lifetime_param(p, m), |
27 | IDENT => type_param(p, m), | 27 | IDENT => type_param(p, m), |
28 | CONST_KW => const_param(p, m), | 28 | T![const] => const_param(p, m), |
29 | _ => { | 29 | _ => { |
30 | m.abandon(p); | 30 | m.abandon(p); |
31 | p.err_and_bump("expected type parameter") | 31 | p.err_and_bump("expected type parameter") |
@@ -66,7 +66,7 @@ fn type_param(p: &mut Parser, m: Marker) { | |||
66 | // test const_param | 66 | // test const_param |
67 | // struct S<const N: u32>; | 67 | // struct S<const N: u32>; |
68 | fn const_param(p: &mut Parser, m: Marker) { | 68 | fn const_param(p: &mut Parser, m: Marker) { |
69 | assert!(p.at(CONST_KW)); | 69 | assert!(p.at(T![const])); |
70 | p.bump(T![const]); | 70 | p.bump(T![const]); |
71 | name(p); | 71 | name(p); |
72 | types::ascription(p); | 72 | types::ascription(p); |
diff --git a/crates/parser/src/parser.rs b/crates/parser/src/parser.rs index d2487acc3..81e26e009 100644 --- a/crates/parser/src/parser.rs +++ b/crates/parser/src/parser.rs | |||
@@ -7,7 +7,7 @@ use drop_bomb::DropBomb; | |||
7 | use crate::{ | 7 | use crate::{ |
8 | event::Event, | 8 | event::Event, |
9 | ParseError, | 9 | ParseError, |
10 | SyntaxKind::{self, EOF, ERROR, TOMBSTONE}, | 10 | SyntaxKind::{self, EOF, ERROR, L_DOLLAR, R_DOLLAR, TOMBSTONE}, |
11 | TokenSet, TokenSource, T, | 11 | TokenSet, TokenSource, T, |
12 | }; | 12 | }; |
13 | 13 | ||
@@ -215,13 +215,23 @@ impl<'t> Parser<'t> { | |||
215 | 215 | ||
216 | /// Create an error node and consume the next token. | 216 | /// Create an error node and consume the next token. |
217 | pub(crate) fn err_and_bump(&mut self, message: &str) { | 217 | pub(crate) fn err_and_bump(&mut self, message: &str) { |
218 | self.err_recover(message, TokenSet::EMPTY); | 218 | match self.current() { |
219 | L_DOLLAR | R_DOLLAR => { | ||
220 | let m = self.start(); | ||
221 | self.error(message); | ||
222 | self.bump_any(); | ||
223 | m.complete(self, ERROR); | ||
224 | } | ||
225 | _ => { | ||
226 | self.err_recover(message, TokenSet::EMPTY); | ||
227 | } | ||
228 | } | ||
219 | } | 229 | } |
220 | 230 | ||
221 | /// Create an error node and consume the next token. | 231 | /// Create an error node and consume the next token. |
222 | pub(crate) fn err_recover(&mut self, message: &str, recovery: TokenSet) { | 232 | pub(crate) fn err_recover(&mut self, message: &str, recovery: TokenSet) { |
223 | match self.current() { | 233 | match self.current() { |
224 | T!['{'] | T!['}'] => { | 234 | T!['{'] | T!['}'] | L_DOLLAR | R_DOLLAR => { |
225 | self.error(message); | 235 | self.error(message); |
226 | return; | 236 | return; |
227 | } | 237 | } |
diff --git a/crates/parser/src/syntax_kind.rs b/crates/parser/src/syntax_kind.rs index 63204436c..9ea0e4f9b 100644 --- a/crates/parser/src/syntax_kind.rs +++ b/crates/parser/src/syntax_kind.rs | |||
@@ -6,6 +6,7 @@ mod generated; | |||
6 | pub use self::generated::SyntaxKind; | 6 | pub use self::generated::SyntaxKind; |
7 | 7 | ||
8 | impl From<u16> for SyntaxKind { | 8 | impl From<u16> for SyntaxKind { |
9 | #[inline] | ||
9 | fn from(d: u16) -> SyntaxKind { | 10 | fn from(d: u16) -> SyntaxKind { |
10 | assert!(d <= (SyntaxKind::__LAST as u16)); | 11 | assert!(d <= (SyntaxKind::__LAST as u16)); |
11 | unsafe { std::mem::transmute::<u16, SyntaxKind>(d) } | 12 | unsafe { std::mem::transmute::<u16, SyntaxKind>(d) } |
@@ -13,12 +14,14 @@ impl From<u16> for SyntaxKind { | |||
13 | } | 14 | } |
14 | 15 | ||
15 | impl From<SyntaxKind> for u16 { | 16 | impl From<SyntaxKind> for u16 { |
17 | #[inline] | ||
16 | fn from(k: SyntaxKind) -> u16 { | 18 | fn from(k: SyntaxKind) -> u16 { |
17 | k as u16 | 19 | k as u16 |
18 | } | 20 | } |
19 | } | 21 | } |
20 | 22 | ||
21 | impl SyntaxKind { | 23 | impl SyntaxKind { |
24 | #[inline] | ||
22 | pub fn is_trivia(self) -> bool { | 25 | pub fn is_trivia(self) -> bool { |
23 | matches!(self, SyntaxKind::WHITESPACE | SyntaxKind::COMMENT) | 26 | matches!(self, SyntaxKind::WHITESPACE | SyntaxKind::COMMENT) |
24 | } | 27 | } |
diff --git a/crates/parser/src/syntax_kind/generated.rs b/crates/parser/src/syntax_kind/generated.rs index f69e71bdb..bcefd183a 100644 --- a/crates/parser/src/syntax_kind/generated.rs +++ b/crates/parser/src/syntax_kind/generated.rs | |||
@@ -101,6 +101,7 @@ pub enum SyntaxKind { | |||
101 | USE_KW, | 101 | USE_KW, |
102 | WHERE_KW, | 102 | WHERE_KW, |
103 | WHILE_KW, | 103 | WHILE_KW, |
104 | YIELD_KW, | ||
104 | AUTO_KW, | 105 | AUTO_KW, |
105 | DEFAULT_KW, | 106 | DEFAULT_KW, |
106 | EXISTENTIAL_KW, | 107 | EXISTENTIAL_KW, |
@@ -142,6 +143,7 @@ pub enum SyntaxKind { | |||
142 | MACRO_DEF, | 143 | MACRO_DEF, |
143 | PAREN_TYPE, | 144 | PAREN_TYPE, |
144 | TUPLE_TYPE, | 145 | TUPLE_TYPE, |
146 | MACRO_TYPE, | ||
145 | NEVER_TYPE, | 147 | NEVER_TYPE, |
146 | PATH_TYPE, | 148 | PATH_TYPE, |
147 | PTR_TYPE, | 149 | PTR_TYPE, |
@@ -186,6 +188,7 @@ pub enum SyntaxKind { | |||
186 | LABEL, | 188 | LABEL, |
187 | BLOCK_EXPR, | 189 | BLOCK_EXPR, |
188 | RETURN_EXPR, | 190 | RETURN_EXPR, |
191 | YIELD_EXPR, | ||
189 | MATCH_EXPR, | 192 | MATCH_EXPR, |
190 | MATCH_ARM_LIST, | 193 | MATCH_ARM_LIST, |
191 | MATCH_ARM, | 194 | MATCH_ARM, |
@@ -263,7 +266,8 @@ impl SyntaxKind { | |||
263 | | IMPL_KW | IN_KW | LET_KW | LOOP_KW | MACRO_KW | MATCH_KW | MOD_KW | MOVE_KW | 266 | | IMPL_KW | IN_KW | LET_KW | LOOP_KW | MACRO_KW | MATCH_KW | MOD_KW | MOVE_KW |
264 | | MUT_KW | PUB_KW | REF_KW | RETURN_KW | SELF_KW | STATIC_KW | STRUCT_KW | SUPER_KW | 267 | | MUT_KW | PUB_KW | REF_KW | RETURN_KW | SELF_KW | STATIC_KW | STRUCT_KW | SUPER_KW |
265 | | TRAIT_KW | TRUE_KW | TRY_KW | TYPE_KW | UNSAFE_KW | USE_KW | WHERE_KW | WHILE_KW | 268 | | TRAIT_KW | TRUE_KW | TRY_KW | TYPE_KW | UNSAFE_KW | USE_KW | WHERE_KW | WHILE_KW |
266 | | AUTO_KW | DEFAULT_KW | EXISTENTIAL_KW | UNION_KW | RAW_KW | MACRO_RULES_KW => true, | 269 | | YIELD_KW | AUTO_KW | DEFAULT_KW | EXISTENTIAL_KW | UNION_KW | RAW_KW |
270 | | MACRO_RULES_KW => true, | ||
267 | _ => false, | 271 | _ => false, |
268 | } | 272 | } |
269 | } | 273 | } |
@@ -326,6 +330,7 @@ impl SyntaxKind { | |||
326 | "use" => USE_KW, | 330 | "use" => USE_KW, |
327 | "where" => WHERE_KW, | 331 | "where" => WHERE_KW, |
328 | "while" => WHILE_KW, | 332 | "while" => WHILE_KW, |
333 | "yield" => YIELD_KW, | ||
329 | _ => return None, | 334 | _ => return None, |
330 | }; | 335 | }; |
331 | Some(kw) | 336 | Some(kw) |
@@ -366,4 +371,4 @@ impl SyntaxKind { | |||
366 | } | 371 | } |
367 | } | 372 | } |
368 | #[macro_export] | 373 | #[macro_export] |
369 | macro_rules ! T { [;] => { $ crate :: SyntaxKind :: SEMICOLON } ; [,] => { $ crate :: SyntaxKind :: COMMA } ; ['('] => { $ crate :: SyntaxKind :: L_PAREN } ; [')'] => { $ crate :: SyntaxKind :: R_PAREN } ; ['{'] => { $ crate :: SyntaxKind :: L_CURLY } ; ['}'] => { $ crate :: SyntaxKind :: R_CURLY } ; ['['] => { $ crate :: SyntaxKind :: L_BRACK } ; [']'] => { $ crate :: SyntaxKind :: R_BRACK } ; [<] => { $ crate :: SyntaxKind :: L_ANGLE } ; [>] => { $ crate :: SyntaxKind :: R_ANGLE } ; [@] => { $ crate :: SyntaxKind :: AT } ; [#] => { $ crate :: SyntaxKind :: POUND } ; [~] => { $ crate :: SyntaxKind :: TILDE } ; [?] => { $ crate :: SyntaxKind :: QUESTION } ; [$] => { $ crate :: SyntaxKind :: DOLLAR } ; [&] => { $ crate :: SyntaxKind :: AMP } ; [|] => { $ crate :: SyntaxKind :: PIPE } ; [+] => { $ crate :: SyntaxKind :: PLUS } ; [*] => { $ crate :: SyntaxKind :: STAR } ; [/] => { $ crate :: SyntaxKind :: SLASH } ; [^] => { $ crate :: SyntaxKind :: CARET } ; [%] => { $ crate :: SyntaxKind :: PERCENT } ; [_] => { $ crate :: SyntaxKind :: UNDERSCORE } ; [.] => { $ crate :: SyntaxKind :: DOT } ; [..] => { $ crate :: SyntaxKind :: DOT2 } ; [...] => { $ crate :: SyntaxKind :: DOT3 } ; [..=] => { $ crate :: SyntaxKind :: DOT2EQ } ; [:] => { $ crate :: SyntaxKind :: COLON } ; [::] => { $ crate :: SyntaxKind :: COLON2 } ; [=] => { $ crate :: SyntaxKind :: EQ } ; [==] => { $ crate :: SyntaxKind :: EQ2 } ; [=>] => { $ crate :: SyntaxKind :: FAT_ARROW } ; [!] => { $ crate :: SyntaxKind :: BANG } ; [!=] => { $ crate :: SyntaxKind :: NEQ } ; [-] => { $ crate :: SyntaxKind :: MINUS } ; [->] => { $ crate :: SyntaxKind :: THIN_ARROW } ; [<=] => { $ crate :: SyntaxKind :: LTEQ } ; [>=] => { $ crate :: SyntaxKind :: GTEQ } ; [+=] => { $ crate :: SyntaxKind :: PLUSEQ } ; [-=] => { $ crate :: SyntaxKind :: MINUSEQ } ; [|=] => { $ crate :: SyntaxKind :: PIPEEQ } ; [&=] => { $ crate :: SyntaxKind :: AMPEQ } ; [^=] => { $ crate :: SyntaxKind :: CARETEQ } ; [/=] => { $ crate :: SyntaxKind :: SLASHEQ } ; [*=] => { $ crate :: SyntaxKind :: STAREQ } ; [%=] => { $ crate :: SyntaxKind :: PERCENTEQ } ; [&&] => { $ crate :: SyntaxKind :: AMP2 } ; [||] => { $ crate :: SyntaxKind :: PIPE2 } ; [<<] => { $ crate :: SyntaxKind :: SHL } ; [>>] => { $ crate :: SyntaxKind :: SHR } ; [<<=] => { $ crate :: SyntaxKind :: SHLEQ } ; [>>=] => { $ crate :: SyntaxKind :: SHREQ } ; [as] => { $ crate :: SyntaxKind :: AS_KW } ; [async] => { $ crate :: SyntaxKind :: ASYNC_KW } ; [await] => { $ crate :: SyntaxKind :: AWAIT_KW } ; [box] => { $ crate :: SyntaxKind :: BOX_KW } ; [break] => { $ crate :: SyntaxKind :: BREAK_KW } ; [const] => { $ crate :: SyntaxKind :: CONST_KW } ; [continue] => { $ crate :: SyntaxKind :: CONTINUE_KW } ; [crate] => { $ crate :: SyntaxKind :: CRATE_KW } ; [dyn] => { $ crate :: SyntaxKind :: DYN_KW } ; [else] => { $ crate :: SyntaxKind :: ELSE_KW } ; [enum] => { $ crate :: SyntaxKind :: ENUM_KW } ; [extern] => { $ crate :: SyntaxKind :: EXTERN_KW } ; [false] => { $ crate :: SyntaxKind :: FALSE_KW } ; [fn] => { $ crate :: SyntaxKind :: FN_KW } ; [for] => { $ crate :: SyntaxKind :: FOR_KW } ; [if] => { $ crate :: SyntaxKind :: IF_KW } ; [impl] => { $ crate :: SyntaxKind :: IMPL_KW } ; [in] => { $ crate :: SyntaxKind :: IN_KW } ; [let] => { $ crate :: SyntaxKind :: LET_KW } ; [loop] => { $ crate :: SyntaxKind :: LOOP_KW } ; [macro] => { $ crate :: SyntaxKind :: MACRO_KW } ; [match] => { $ crate :: SyntaxKind :: MATCH_KW } ; [mod] => { $ crate :: SyntaxKind :: MOD_KW } ; [move] => { $ crate :: SyntaxKind :: MOVE_KW } ; [mut] => { $ crate :: SyntaxKind :: MUT_KW } ; [pub] => { $ crate :: SyntaxKind :: PUB_KW } ; [ref] => { $ crate :: SyntaxKind :: REF_KW } ; [return] => { $ crate :: SyntaxKind :: RETURN_KW } ; [self] => { $ crate :: SyntaxKind :: SELF_KW } ; [static] => { $ crate :: SyntaxKind :: STATIC_KW } ; [struct] => { $ crate :: SyntaxKind :: STRUCT_KW } ; [super] => { $ crate :: SyntaxKind :: SUPER_KW } ; [trait] => { $ crate :: SyntaxKind :: TRAIT_KW } ; [true] => { $ crate :: SyntaxKind :: TRUE_KW } ; [try] => { $ crate :: SyntaxKind :: TRY_KW } ; [type] => { $ crate :: SyntaxKind :: TYPE_KW } ; [unsafe] => { $ crate :: SyntaxKind :: UNSAFE_KW } ; [use] => { $ crate :: SyntaxKind :: USE_KW } ; [where] => { $ crate :: SyntaxKind :: WHERE_KW } ; [while] => { $ crate :: SyntaxKind :: WHILE_KW } ; [auto] => { $ crate :: SyntaxKind :: AUTO_KW } ; [default] => { $ crate :: SyntaxKind :: DEFAULT_KW } ; [existential] => { $ crate :: SyntaxKind :: EXISTENTIAL_KW } ; [union] => { $ crate :: SyntaxKind :: UNION_KW } ; [raw] => { $ crate :: SyntaxKind :: RAW_KW } ; [macro_rules] => { $ crate :: SyntaxKind :: MACRO_RULES_KW } ; [lifetime_ident] => { $ crate :: SyntaxKind :: LIFETIME_IDENT } ; [ident] => { $ crate :: SyntaxKind :: IDENT } ; [shebang] => { $ crate :: SyntaxKind :: SHEBANG } ; } | 374 | macro_rules ! T { [;] => { $ crate :: SyntaxKind :: SEMICOLON } ; [,] => { $ crate :: SyntaxKind :: COMMA } ; ['('] => { $ crate :: SyntaxKind :: L_PAREN } ; [')'] => { $ crate :: SyntaxKind :: R_PAREN } ; ['{'] => { $ crate :: SyntaxKind :: L_CURLY } ; ['}'] => { $ crate :: SyntaxKind :: R_CURLY } ; ['['] => { $ crate :: SyntaxKind :: L_BRACK } ; [']'] => { $ crate :: SyntaxKind :: R_BRACK } ; [<] => { $ crate :: SyntaxKind :: L_ANGLE } ; [>] => { $ crate :: SyntaxKind :: R_ANGLE } ; [@] => { $ crate :: SyntaxKind :: AT } ; [#] => { $ crate :: SyntaxKind :: POUND } ; [~] => { $ crate :: SyntaxKind :: TILDE } ; [?] => { $ crate :: SyntaxKind :: QUESTION } ; [$] => { $ crate :: SyntaxKind :: DOLLAR } ; [&] => { $ crate :: SyntaxKind :: AMP } ; [|] => { $ crate :: SyntaxKind :: PIPE } ; [+] => { $ crate :: SyntaxKind :: PLUS } ; [*] => { $ crate :: SyntaxKind :: STAR } ; [/] => { $ crate :: SyntaxKind :: SLASH } ; [^] => { $ crate :: SyntaxKind :: CARET } ; [%] => { $ crate :: SyntaxKind :: PERCENT } ; [_] => { $ crate :: SyntaxKind :: UNDERSCORE } ; [.] => { $ crate :: SyntaxKind :: DOT } ; [..] => { $ crate :: SyntaxKind :: DOT2 } ; [...] => { $ crate :: SyntaxKind :: DOT3 } ; [..=] => { $ crate :: SyntaxKind :: DOT2EQ } ; [:] => { $ crate :: SyntaxKind :: COLON } ; [::] => { $ crate :: SyntaxKind :: COLON2 } ; [=] => { $ crate :: SyntaxKind :: EQ } ; [==] => { $ crate :: SyntaxKind :: EQ2 } ; [=>] => { $ crate :: SyntaxKind :: FAT_ARROW } ; [!] => { $ crate :: SyntaxKind :: BANG } ; [!=] => { $ crate :: SyntaxKind :: NEQ } ; [-] => { $ crate :: SyntaxKind :: MINUS } ; [->] => { $ crate :: SyntaxKind :: THIN_ARROW } ; [<=] => { $ crate :: SyntaxKind :: LTEQ } ; [>=] => { $ crate :: SyntaxKind :: GTEQ } ; [+=] => { $ crate :: SyntaxKind :: PLUSEQ } ; [-=] => { $ crate :: SyntaxKind :: MINUSEQ } ; [|=] => { $ crate :: SyntaxKind :: PIPEEQ } ; [&=] => { $ crate :: SyntaxKind :: AMPEQ } ; [^=] => { $ crate :: SyntaxKind :: CARETEQ } ; [/=] => { $ crate :: SyntaxKind :: SLASHEQ } ; [*=] => { $ crate :: SyntaxKind :: STAREQ } ; [%=] => { $ crate :: SyntaxKind :: PERCENTEQ } ; [&&] => { $ crate :: SyntaxKind :: AMP2 } ; [||] => { $ crate :: SyntaxKind :: PIPE2 } ; [<<] => { $ crate :: SyntaxKind :: SHL } ; [>>] => { $ crate :: SyntaxKind :: SHR } ; [<<=] => { $ crate :: SyntaxKind :: SHLEQ } ; [>>=] => { $ crate :: SyntaxKind :: SHREQ } ; [as] => { $ crate :: SyntaxKind :: AS_KW } ; [async] => { $ crate :: SyntaxKind :: ASYNC_KW } ; [await] => { $ crate :: SyntaxKind :: AWAIT_KW } ; [box] => { $ crate :: SyntaxKind :: BOX_KW } ; [break] => { $ crate :: SyntaxKind :: BREAK_KW } ; [const] => { $ crate :: SyntaxKind :: CONST_KW } ; [continue] => { $ crate :: SyntaxKind :: CONTINUE_KW } ; [crate] => { $ crate :: SyntaxKind :: CRATE_KW } ; [dyn] => { $ crate :: SyntaxKind :: DYN_KW } ; [else] => { $ crate :: SyntaxKind :: ELSE_KW } ; [enum] => { $ crate :: SyntaxKind :: ENUM_KW } ; [extern] => { $ crate :: SyntaxKind :: EXTERN_KW } ; [false] => { $ crate :: SyntaxKind :: FALSE_KW } ; [fn] => { $ crate :: SyntaxKind :: FN_KW } ; [for] => { $ crate :: SyntaxKind :: FOR_KW } ; [if] => { $ crate :: SyntaxKind :: IF_KW } ; [impl] => { $ crate :: SyntaxKind :: IMPL_KW } ; [in] => { $ crate :: SyntaxKind :: IN_KW } ; [let] => { $ crate :: SyntaxKind :: LET_KW } ; [loop] => { $ crate :: SyntaxKind :: LOOP_KW } ; [macro] => { $ crate :: SyntaxKind :: MACRO_KW } ; [match] => { $ crate :: SyntaxKind :: MATCH_KW } ; [mod] => { $ crate :: SyntaxKind :: MOD_KW } ; [move] => { $ crate :: SyntaxKind :: MOVE_KW } ; [mut] => { $ crate :: SyntaxKind :: MUT_KW } ; [pub] => { $ crate :: SyntaxKind :: PUB_KW } ; [ref] => { $ crate :: SyntaxKind :: REF_KW } ; [return] => { $ crate :: SyntaxKind :: RETURN_KW } ; [self] => { $ crate :: SyntaxKind :: SELF_KW } ; [static] => { $ crate :: SyntaxKind :: STATIC_KW } ; [struct] => { $ crate :: SyntaxKind :: STRUCT_KW } ; [super] => { $ crate :: SyntaxKind :: SUPER_KW } ; [trait] => { $ crate :: SyntaxKind :: TRAIT_KW } ; [true] => { $ crate :: SyntaxKind :: TRUE_KW } ; [try] => { $ crate :: SyntaxKind :: TRY_KW } ; [type] => { $ crate :: SyntaxKind :: TYPE_KW } ; [unsafe] => { $ crate :: SyntaxKind :: UNSAFE_KW } ; [use] => { $ crate :: SyntaxKind :: USE_KW } ; [where] => { $ crate :: SyntaxKind :: WHERE_KW } ; [while] => { $ crate :: SyntaxKind :: WHILE_KW } ; [yield] => { $ crate :: SyntaxKind :: YIELD_KW } ; [auto] => { $ crate :: SyntaxKind :: AUTO_KW } ; [default] => { $ crate :: SyntaxKind :: DEFAULT_KW } ; [existential] => { $ crate :: SyntaxKind :: EXISTENTIAL_KW } ; [union] => { $ crate :: SyntaxKind :: UNION_KW } ; [raw] => { $ crate :: SyntaxKind :: RAW_KW } ; [macro_rules] => { $ crate :: SyntaxKind :: MACRO_RULES_KW } ; [lifetime_ident] => { $ crate :: SyntaxKind :: LIFETIME_IDENT } ; [ident] => { $ crate :: SyntaxKind :: IDENT } ; [shebang] => { $ crate :: SyntaxKind :: SHEBANG } ; } |