aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_parser/src')
-rw-r--r--crates/ra_parser/src/grammar/expressions.rs3
-rw-r--r--crates/ra_parser/src/grammar/types.rs15
-rw-r--r--crates/ra_parser/src/syntax_kind/generated.rs334
3 files changed, 33 insertions, 319 deletions
diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs
index c486c0211..a1bd53063 100644
--- a/crates/ra_parser/src/grammar/expressions.rs
+++ b/crates/ra_parser/src/grammar/expressions.rs
@@ -339,7 +339,8 @@ fn expr_bp(p: &mut Parser, mut r: Restrictions, bp: u8) -> (Option<CompletedMark
339 (Some(lhs), BlockLike::NotBlock) 339 (Some(lhs), BlockLike::NotBlock)
340} 340}
341 341
342const LHS_FIRST: TokenSet = atom::ATOM_EXPR_FIRST.union(token_set![AMP, STAR, EXCL, DOT, MINUS]); 342const LHS_FIRST: TokenSet =
343 atom::ATOM_EXPR_FIRST.union(token_set![T![&], T![*], T![!], T![.], T![-]]);
343 344
344fn lhs(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> { 345fn lhs(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> {
345 let m; 346 let m;
diff --git a/crates/ra_parser/src/grammar/types.rs b/crates/ra_parser/src/grammar/types.rs
index 386969d2d..fe1a039cb 100644
--- a/crates/ra_parser/src/grammar/types.rs
+++ b/crates/ra_parser/src/grammar/types.rs
@@ -3,8 +3,19 @@
3use super::*; 3use super::*;
4 4
5pub(super) const TYPE_FIRST: TokenSet = paths::PATH_FIRST.union(token_set![ 5pub(super) const TYPE_FIRST: TokenSet = paths::PATH_FIRST.union(token_set![
6 L_PAREN, EXCL, STAR, L_BRACK, AMP, UNDERSCORE, FN_KW, UNSAFE_KW, EXTERN_KW, FOR_KW, IMPL_KW, 6 T!['('],
7 DYN_KW, L_ANGLE, 7 T!['['],
8 T![<],
9 T![!],
10 T![*],
11 T![&],
12 T![_],
13 T![fn],
14 T![unsafe],
15 T![extern],
16 T![for],
17 T![impl],
18 T![dyn],
8]); 19]);
9 20
10const TYPE_RECOVERY_SET: TokenSet = token_set![R_PAREN, COMMA, L_DOLLAR]; 21const TYPE_RECOVERY_SET: TokenSet = token_set![R_PAREN, COMMA, L_DOLLAR];
diff --git a/crates/ra_parser/src/syntax_kind/generated.rs b/crates/ra_parser/src/syntax_kind/generated.rs
index 1dd4ce34a..524e7d784 100644
--- a/crates/ra_parser/src/syntax_kind/generated.rs
+++ b/crates/ra_parser/src/syntax_kind/generated.rs
@@ -9,7 +9,7 @@ pub enum SyntaxKind {
9 TOMBSTONE, 9 TOMBSTONE,
10 #[doc(hidden)] 10 #[doc(hidden)]
11 EOF, 11 EOF,
12 SEMI, 12 SEMICOLON,
13 COMMA, 13 COMMA,
14 L_PAREN, 14 L_PAREN,
15 R_PAREN, 15 R_PAREN,
@@ -33,15 +33,15 @@ pub enum SyntaxKind {
33 PERCENT, 33 PERCENT,
34 UNDERSCORE, 34 UNDERSCORE,
35 DOT, 35 DOT,
36 DOTDOT, 36 DOT2,
37 DOTDOTDOT, 37 DOT3,
38 DOTDOTEQ, 38 DOT2EQ,
39 COLON, 39 COLON,
40 COLONCOLON, 40 COLON2,
41 EQ, 41 EQ,
42 EQEQ, 42 EQ2,
43 FAT_ARROW, 43 FAT_ARROW,
44 EXCL, 44 BANG,
45 NEQ, 45 NEQ,
46 MINUS, 46 MINUS,
47 THIN_ARROW, 47 THIN_ARROW,
@@ -55,8 +55,8 @@ pub enum SyntaxKind {
55 SLASHEQ, 55 SLASHEQ,
56 STAREQ, 56 STAREQ,
57 PERCENTEQ, 57 PERCENTEQ,
58 AMPAMP, 58 AMP2,
59 PIPEPIPE, 59 PIPE2,
60 SHL, 60 SHL,
61 SHR, 61 SHR,
62 SHLEQ, 62 SHLEQ,
@@ -265,12 +265,12 @@ impl SyntaxKind {
265 } 265 }
266 pub fn is_punct(self) -> bool { 266 pub fn is_punct(self) -> bool {
267 match self { 267 match self {
268 SEMI | COMMA | L_PAREN | R_PAREN | L_CURLY | R_CURLY | L_BRACK | R_BRACK | L_ANGLE 268 SEMICOLON | COMMA | L_PAREN | R_PAREN | L_CURLY | R_CURLY | L_BRACK | R_BRACK
269 | R_ANGLE | AT | POUND | TILDE | QUESTION | DOLLAR | AMP | PIPE | PLUS | STAR 269 | L_ANGLE | R_ANGLE | AT | POUND | TILDE | QUESTION | DOLLAR | AMP | PIPE | PLUS
270 | SLASH | CARET | PERCENT | UNDERSCORE | DOT | DOTDOT | DOTDOTDOT | DOTDOTEQ 270 | STAR | SLASH | CARET | PERCENT | UNDERSCORE | DOT | DOT2 | DOT3 | DOT2EQ | COLON
271 | COLON | COLONCOLON | EQ | EQEQ | FAT_ARROW | EXCL | NEQ | MINUS | THIN_ARROW 271 | COLON2 | EQ | EQ2 | FAT_ARROW | BANG | NEQ | MINUS | THIN_ARROW | LTEQ | GTEQ
272 | LTEQ | GTEQ | PLUSEQ | MINUSEQ | PIPEEQ | AMPEQ | CARETEQ | SLASHEQ | STAREQ 272 | PLUSEQ | MINUSEQ | PIPEEQ | AMPEQ | CARETEQ | SLASHEQ | STAREQ | PERCENTEQ | AMP2
273 | PERCENTEQ | AMPAMP | PIPEPIPE | SHL | SHR | SHLEQ | SHREQ => true, 273 | PIPE2 | SHL | SHR | SHLEQ | SHREQ => true,
274 _ => false, 274 _ => false,
275 } 275 }
276 } 276 }
@@ -329,7 +329,7 @@ impl SyntaxKind {
329 } 329 }
330 pub fn from_char(c: char) -> Option<SyntaxKind> { 330 pub fn from_char(c: char) -> Option<SyntaxKind> {
331 let tok = match c { 331 let tok = match c {
332 ';' => SEMI, 332 ';' => SEMICOLON,
333 ',' => COMMA, 333 ',' => COMMA,
334 '(' => L_PAREN, 334 '(' => L_PAREN,
335 ')' => R_PAREN, 335 ')' => R_PAREN,
@@ -355,7 +355,7 @@ impl SyntaxKind {
355 '.' => DOT, 355 '.' => DOT,
356 ':' => COLON, 356 ':' => COLON,
357 '=' => EQ, 357 '=' => EQ,
358 '!' => EXCL, 358 '!' => BANG,
359 '-' => MINUS, 359 '-' => MINUS,
360 _ => return None, 360 _ => return None,
361 }; 361 };
@@ -363,302 +363,4 @@ impl SyntaxKind {
363 } 363 }
364} 364}
365#[macro_export] 365#[macro_export]
366macro_rules! T { 366macro_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 } ; [ lifetime ] => { $ crate :: SyntaxKind :: LIFETIME } ; [ ident ] => { $ crate :: SyntaxKind :: IDENT } ; }
367 ( ; ) => {
368 $crate::SyntaxKind::SEMI
369 };
370 ( , ) => {
371 $crate::SyntaxKind::COMMA
372 };
373 ( '(' ) => {
374 $crate::SyntaxKind::L_PAREN
375 };
376 ( ')' ) => {
377 $crate::SyntaxKind::R_PAREN
378 };
379 ( '{' ) => {
380 $crate::SyntaxKind::L_CURLY
381 };
382 ( '}' ) => {
383 $crate::SyntaxKind::R_CURLY
384 };
385 ( '[' ) => {
386 $crate::SyntaxKind::L_BRACK
387 };
388 ( ']' ) => {
389 $crate::SyntaxKind::R_BRACK
390 };
391 ( < ) => {
392 $crate::SyntaxKind::L_ANGLE
393 };
394 ( > ) => {
395 $crate::SyntaxKind::R_ANGLE
396 };
397 ( @ ) => {
398 $crate::SyntaxKind::AT
399 };
400 ( # ) => {
401 $crate::SyntaxKind::POUND
402 };
403 ( ~ ) => {
404 $crate::SyntaxKind::TILDE
405 };
406 ( ? ) => {
407 $crate::SyntaxKind::QUESTION
408 };
409 ( $ ) => {
410 $crate::SyntaxKind::DOLLAR
411 };
412 ( & ) => {
413 $crate::SyntaxKind::AMP
414 };
415 ( | ) => {
416 $crate::SyntaxKind::PIPE
417 };
418 ( + ) => {
419 $crate::SyntaxKind::PLUS
420 };
421 ( * ) => {
422 $crate::SyntaxKind::STAR
423 };
424 ( / ) => {
425 $crate::SyntaxKind::SLASH
426 };
427 ( ^ ) => {
428 $crate::SyntaxKind::CARET
429 };
430 ( % ) => {
431 $crate::SyntaxKind::PERCENT
432 };
433 ( _ ) => {
434 $crate::SyntaxKind::UNDERSCORE
435 };
436 ( . ) => {
437 $crate::SyntaxKind::DOT
438 };
439 ( .. ) => {
440 $crate::SyntaxKind::DOTDOT
441 };
442 ( ... ) => {
443 $crate::SyntaxKind::DOTDOTDOT
444 };
445 ( ..= ) => {
446 $crate::SyntaxKind::DOTDOTEQ
447 };
448 ( : ) => {
449 $crate::SyntaxKind::COLON
450 };
451 ( :: ) => {
452 $crate::SyntaxKind::COLONCOLON
453 };
454 ( = ) => {
455 $crate::SyntaxKind::EQ
456 };
457 ( == ) => {
458 $crate::SyntaxKind::EQEQ
459 };
460 ( => ) => {
461 $crate::SyntaxKind::FAT_ARROW
462 };
463 ( ! ) => {
464 $crate::SyntaxKind::EXCL
465 };
466 ( != ) => {
467 $crate::SyntaxKind::NEQ
468 };
469 ( - ) => {
470 $crate::SyntaxKind::MINUS
471 };
472 ( -> ) => {
473 $crate::SyntaxKind::THIN_ARROW
474 };
475 ( <= ) => {
476 $crate::SyntaxKind::LTEQ
477 };
478 ( >= ) => {
479 $crate::SyntaxKind::GTEQ
480 };
481 ( += ) => {
482 $crate::SyntaxKind::PLUSEQ
483 };
484 ( -= ) => {
485 $crate::SyntaxKind::MINUSEQ
486 };
487 ( |= ) => {
488 $crate::SyntaxKind::PIPEEQ
489 };
490 ( &= ) => {
491 $crate::SyntaxKind::AMPEQ
492 };
493 ( ^= ) => {
494 $crate::SyntaxKind::CARETEQ
495 };
496 ( /= ) => {
497 $crate::SyntaxKind::SLASHEQ
498 };
499 ( *= ) => {
500 $crate::SyntaxKind::STAREQ
501 };
502 ( %= ) => {
503 $crate::SyntaxKind::PERCENTEQ
504 };
505 ( && ) => {
506 $crate::SyntaxKind::AMPAMP
507 };
508 ( || ) => {
509 $crate::SyntaxKind::PIPEPIPE
510 };
511 ( << ) => {
512 $crate::SyntaxKind::SHL
513 };
514 ( >> ) => {
515 $crate::SyntaxKind::SHR
516 };
517 ( <<= ) => {
518 $crate::SyntaxKind::SHLEQ
519 };
520 ( >>= ) => {
521 $crate::SyntaxKind::SHREQ
522 };
523 ( as ) => {
524 $crate::SyntaxKind::AS_KW
525 };
526 ( async ) => {
527 $crate::SyntaxKind::ASYNC_KW
528 };
529 ( await ) => {
530 $crate::SyntaxKind::AWAIT_KW
531 };
532 ( box ) => {
533 $crate::SyntaxKind::BOX_KW
534 };
535 ( break ) => {
536 $crate::SyntaxKind::BREAK_KW
537 };
538 ( const ) => {
539 $crate::SyntaxKind::CONST_KW
540 };
541 ( continue ) => {
542 $crate::SyntaxKind::CONTINUE_KW
543 };
544 ( crate ) => {
545 $crate::SyntaxKind::CRATE_KW
546 };
547 ( dyn ) => {
548 $crate::SyntaxKind::DYN_KW
549 };
550 ( else ) => {
551 $crate::SyntaxKind::ELSE_KW
552 };
553 ( enum ) => {
554 $crate::SyntaxKind::ENUM_KW
555 };
556 ( extern ) => {
557 $crate::SyntaxKind::EXTERN_KW
558 };
559 ( false ) => {
560 $crate::SyntaxKind::FALSE_KW
561 };
562 ( fn ) => {
563 $crate::SyntaxKind::FN_KW
564 };
565 ( for ) => {
566 $crate::SyntaxKind::FOR_KW
567 };
568 ( if ) => {
569 $crate::SyntaxKind::IF_KW
570 };
571 ( impl ) => {
572 $crate::SyntaxKind::IMPL_KW
573 };
574 ( in ) => {
575 $crate::SyntaxKind::IN_KW
576 };
577 ( let ) => {
578 $crate::SyntaxKind::LET_KW
579 };
580 ( loop ) => {
581 $crate::SyntaxKind::LOOP_KW
582 };
583 ( macro ) => {
584 $crate::SyntaxKind::MACRO_KW
585 };
586 ( match ) => {
587 $crate::SyntaxKind::MATCH_KW
588 };
589 ( mod ) => {
590 $crate::SyntaxKind::MOD_KW
591 };
592 ( move ) => {
593 $crate::SyntaxKind::MOVE_KW
594 };
595 ( mut ) => {
596 $crate::SyntaxKind::MUT_KW
597 };
598 ( pub ) => {
599 $crate::SyntaxKind::PUB_KW
600 };
601 ( ref ) => {
602 $crate::SyntaxKind::REF_KW
603 };
604 ( return ) => {
605 $crate::SyntaxKind::RETURN_KW
606 };
607 ( self ) => {
608 $crate::SyntaxKind::SELF_KW
609 };
610 ( static ) => {
611 $crate::SyntaxKind::STATIC_KW
612 };
613 ( struct ) => {
614 $crate::SyntaxKind::STRUCT_KW
615 };
616 ( super ) => {
617 $crate::SyntaxKind::SUPER_KW
618 };
619 ( trait ) => {
620 $crate::SyntaxKind::TRAIT_KW
621 };
622 ( true ) => {
623 $crate::SyntaxKind::TRUE_KW
624 };
625 ( try ) => {
626 $crate::SyntaxKind::TRY_KW
627 };
628 ( type ) => {
629 $crate::SyntaxKind::TYPE_KW
630 };
631 ( unsafe ) => {
632 $crate::SyntaxKind::UNSAFE_KW
633 };
634 ( use ) => {
635 $crate::SyntaxKind::USE_KW
636 };
637 ( where ) => {
638 $crate::SyntaxKind::WHERE_KW
639 };
640 ( while ) => {
641 $crate::SyntaxKind::WHILE_KW
642 };
643 ( auto ) => {
644 $crate::SyntaxKind::AUTO_KW
645 };
646 ( default ) => {
647 $crate::SyntaxKind::DEFAULT_KW
648 };
649 ( existential ) => {
650 $crate::SyntaxKind::EXISTENTIAL_KW
651 };
652 ( union ) => {
653 $crate::SyntaxKind::UNION_KW
654 };
655 ( raw ) => {
656 $crate::SyntaxKind::RAW_KW
657 };
658 ( lifetime ) => {
659 $crate::SyntaxKind::LIFETIME
660 };
661 ( ident ) => {
662 $crate::SyntaxKind::IDENT
663 };
664}