aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src/grammar.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_parser/src/grammar.rs')
-rw-r--r--crates/ra_parser/src/grammar.rs42
1 files changed, 21 insertions, 21 deletions
diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs
index a538ec081..cf603eba1 100644
--- a/crates/ra_parser/src/grammar.rs
+++ b/crates/ra_parser/src/grammar.rs
@@ -59,7 +59,7 @@ pub(crate) fn macro_stmts(p: &mut Parser) {
59 let m = p.start(); 59 let m = p.start();
60 60
61 while !p.at(EOF) { 61 while !p.at(EOF) {
62 if p.current() == SEMI { 62 if p.current() == T![;] {
63 p.bump(); 63 p.bump();
64 continue; 64 continue;
65 } 65 }
@@ -103,7 +103,7 @@ pub(crate) fn block(p: &mut Parser) {
103pub(crate) fn meta_item(p: &mut Parser) { 103pub(crate) fn meta_item(p: &mut Parser) {
104 fn is_delimiter(p: &mut Parser) -> bool { 104 fn is_delimiter(p: &mut Parser) -> bool {
105 match p.current() { 105 match p.current() {
106 L_CURLY | L_PAREN | L_BRACK => true, 106 T!['{'] | T!['('] | T!['['] => true,
107 _ => false, 107 _ => false,
108 } 108 }
109 } 109 }
@@ -123,12 +123,12 @@ pub(crate) fn meta_item(p: &mut Parser) {
123 // https://doc.rust-lang.org/reference/paths.html#simple-paths 123 // https://doc.rust-lang.org/reference/paths.html#simple-paths
124 // The start of an meta must be a simple path 124 // The start of an meta must be a simple path
125 match p.current() { 125 match p.current() {
126 IDENT | COLONCOLON | SUPER_KW | SELF_KW | CRATE_KW => p.bump(), 126 IDENT | T![::] | T![super] | T![self] | T![crate] => p.bump(),
127 EQ => { 127 T![=] => {
128 p.bump(); 128 p.bump();
129 match p.current() { 129 match p.current() {
130 c if c.is_literal() => p.bump(), 130 c if c.is_literal() => p.bump(),
131 TRUE_KW | FALSE_KW => p.bump(), 131 T![true] | T![false] => p.bump(),
132 _ => {} 132 _ => {}
133 } 133 }
134 break; 134 break;
@@ -158,7 +158,7 @@ pub(crate) fn reparser(
158 MATCH_ARM_LIST => items::match_arm_list, 158 MATCH_ARM_LIST => items::match_arm_list,
159 USE_TREE_LIST => items::use_tree_list, 159 USE_TREE_LIST => items::use_tree_list,
160 EXTERN_ITEM_LIST => items::extern_item_list, 160 EXTERN_ITEM_LIST => items::extern_item_list,
161 TOKEN_TREE if first_child? == L_CURLY => items::token_tree, 161 TOKEN_TREE if first_child? == T!['{'] => items::token_tree,
162 ITEM_LIST => match parent? { 162 ITEM_LIST => match parent? {
163 IMPL_BLOCK => items::impl_item_list, 163 IMPL_BLOCK => items::impl_item_list,
164 TRAIT_DEF => items::trait_item_list, 164 TRAIT_DEF => items::trait_item_list,
@@ -184,26 +184,26 @@ impl BlockLike {
184 184
185pub(crate) fn opt_visibility(p: &mut Parser) -> bool { 185pub(crate) fn opt_visibility(p: &mut Parser) -> bool {
186 match p.current() { 186 match p.current() {
187 PUB_KW => { 187 T![pub] => {
188 let m = p.start(); 188 let m = p.start();
189 p.bump(); 189 p.bump();
190 if p.at(L_PAREN) { 190 if p.at(T!['(']) {
191 match p.nth(1) { 191 match p.nth(1) {
192 // test crate_visibility 192 // test crate_visibility
193 // pub(crate) struct S; 193 // pub(crate) struct S;
194 // pub(self) struct S; 194 // pub(self) struct S;
195 // pub(self) struct S; 195 // pub(self) struct S;
196 // pub(self) struct S; 196 // pub(self) struct S;
197 CRATE_KW | SELF_KW | SUPER_KW => { 197 T![crate] | T![self] | T![super] => {
198 p.bump(); 198 p.bump();
199 p.bump(); 199 p.bump();
200 p.expect(R_PAREN); 200 p.expect(T![')']);
201 } 201 }
202 IN_KW => { 202 T![in] => {
203 p.bump(); 203 p.bump();
204 p.bump(); 204 p.bump();
205 paths::use_path(p); 205 paths::use_path(p);
206 p.expect(R_PAREN); 206 p.expect(T![')']);
207 } 207 }
208 _ => (), 208 _ => (),
209 } 209 }
@@ -217,7 +217,7 @@ pub(crate) fn opt_visibility(p: &mut Parser) -> bool {
217 // 217 //
218 // test crate_keyword_path 218 // test crate_keyword_path
219 // fn foo() { crate::foo(); } 219 // fn foo() { crate::foo(); }
220 CRATE_KW if p.nth(1) != COLONCOLON => { 220 T![crate] if p.nth(1) != T![::] => {
221 let m = p.start(); 221 let m = p.start();
222 p.bump(); 222 p.bump();
223 m.complete(p, VISIBILITY); 223 m.complete(p, VISIBILITY);
@@ -228,10 +228,10 @@ pub(crate) fn opt_visibility(p: &mut Parser) -> bool {
228} 228}
229 229
230fn opt_alias(p: &mut Parser) { 230fn opt_alias(p: &mut Parser) {
231 if p.at(AS_KW) { 231 if p.at(T![as]) {
232 let m = p.start(); 232 let m = p.start();
233 p.bump(); 233 p.bump();
234 if !p.eat(UNDERSCORE) { 234 if !p.eat(T![_]) {
235 name(p); 235 name(p);
236 } 236 }
237 m.complete(p, ALIAS); 237 m.complete(p, ALIAS);
@@ -239,7 +239,7 @@ fn opt_alias(p: &mut Parser) {
239} 239}
240 240
241fn abi(p: &mut Parser) { 241fn abi(p: &mut Parser) {
242 assert!(p.at(EXTERN_KW)); 242 assert!(p.at(T![extern]));
243 let abi = p.start(); 243 let abi = p.start();
244 p.bump(); 244 p.bump();
245 match p.current() { 245 match p.current() {
@@ -250,7 +250,7 @@ fn abi(p: &mut Parser) {
250} 250}
251 251
252fn opt_fn_ret_type(p: &mut Parser) -> bool { 252fn opt_fn_ret_type(p: &mut Parser) -> bool {
253 if p.at(THIN_ARROW) { 253 if p.at(T![->]) {
254 let m = p.start(); 254 let m = p.start();
255 p.bump(); 255 p.bump();
256 types::type_(p); 256 types::type_(p);
@@ -280,21 +280,21 @@ fn name_ref(p: &mut Parser) {
280 let m = p.start(); 280 let m = p.start();
281 p.bump(); 281 p.bump();
282 m.complete(p, NAME_REF); 282 m.complete(p, NAME_REF);
283 } else if p.at(SELF_KW) { 283 } else if p.at(T![self]) {
284 let m = p.start(); 284 let m = p.start();
285 p.bump(); 285 p.bump();
286 m.complete(p, SELF_KW); 286 m.complete(p, T![self]);
287 } else { 287 } else {
288 p.err_and_bump("expected identifier"); 288 p.err_and_bump("expected identifier");
289 } 289 }
290} 290}
291 291
292fn error_block(p: &mut Parser, message: &str) { 292fn error_block(p: &mut Parser, message: &str) {
293 assert!(p.at(L_CURLY)); 293 assert!(p.at(T!['{']));
294 let m = p.start(); 294 let m = p.start();
295 p.error(message); 295 p.error(message);
296 p.bump(); 296 p.bump();
297 expressions::expr_block_contents(p); 297 expressions::expr_block_contents(p);
298 p.eat(R_CURLY); 298 p.eat(T!['}']);
299 m.complete(p, ERROR); 299 m.complete(p, ERROR);
300} 300}