rust-analyzer/crates/parser/src/syntax_kind/generated.rs

375 lines
12 KiB
Rust
Raw Normal View History

//! Generated by `sourcegen_ast`, do not edit by hand.
2018-10-04 20:43:58 +00:00
2018-01-28 02:36:28 +00:00
#![allow(bad_style, missing_docs, unreachable_pub)]
2020-07-30 15:50:40 +00:00
#[doc = r" The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT`."]
2019-08-19 10:11:51 +00:00
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
2019-04-08 22:06:30 +00:00
#[repr(u16)]
2018-01-28 02:36:28 +00:00
pub enum SyntaxKind {
2018-08-08 20:09:40 +00:00
#[doc(hidden)]
TOMBSTONE,
#[doc(hidden)]
EOF,
2020-04-10 15:06:57 +00:00
SEMICOLON,
2018-01-28 02:36:28 +00:00
COMMA,
L_PAREN,
R_PAREN,
L_CURLY,
R_CURLY,
L_BRACK,
R_BRACK,
L_ANGLE,
R_ANGLE,
AT,
POUND,
TILDE,
QUESTION,
2018-07-30 14:46:50 +00:00
DOLLAR,
2018-08-05 15:18:02 +00:00
AMP,
2018-07-30 14:46:50 +00:00
PIPE,
PLUS,
STAR,
SLASH,
CARET,
PERCENT,
2019-01-31 07:30:15 +00:00
UNDERSCORE,
2018-07-30 14:46:50 +00:00
DOT,
2020-04-10 15:06:57 +00:00
DOT2,
DOT3,
DOT2EQ,
2018-01-28 02:36:28 +00:00
COLON,
2020-04-10 15:06:57 +00:00
COLON2,
2018-01-28 02:36:28 +00:00
EQ,
2020-04-10 15:06:57 +00:00
EQ2,
2018-01-28 02:36:28 +00:00
FAT_ARROW,
2020-04-10 15:06:57 +00:00
BANG,
2018-07-30 14:46:50 +00:00
NEQ,
MINUS,
THIN_ARROW,
2018-08-05 13:09:25 +00:00
LTEQ,
GTEQ,
PLUSEQ,
MINUSEQ,
2018-08-23 21:48:10 +00:00
PIPEEQ,
AMPEQ,
CARETEQ,
SLASHEQ,
STAREQ,
2019-01-07 18:03:25 +00:00
PERCENTEQ,
2020-04-10 15:06:57 +00:00
AMP2,
PIPE2,
2018-08-07 11:24:03 +00:00
SHL,
SHR,
SHLEQ,
SHREQ,
AS_KW,
2019-03-09 23:40:22 +00:00
ASYNC_KW,
AWAIT_KW,
BOX_KW,
BREAK_KW,
CONST_KW,
CONTINUE_KW,
CRATE_KW,
2018-08-13 14:42:43 +00:00
DYN_KW,
ELSE_KW,
ENUM_KW,
2018-02-04 13:46:26 +00:00
EXTERN_KW,
FALSE_KW,
FN_KW,
2018-02-04 13:46:26 +00:00
FOR_KW,
IF_KW,
IMPL_KW,
IN_KW,
LET_KW,
LOOP_KW,
MACRO_KW,
2018-02-04 13:46:26 +00:00
MATCH_KW,
MOD_KW,
MOVE_KW,
2018-02-04 13:46:26 +00:00
MUT_KW,
PUB_KW,
REF_KW,
2018-08-01 08:27:31 +00:00
RETURN_KW,
SELF_KW,
STATIC_KW,
STRUCT_KW,
SUPER_KW,
TRAIT_KW,
TRUE_KW,
2019-06-06 11:36:16 +00:00
TRY_KW,
TYPE_KW,
UNSAFE_KW,
USE_KW,
WHERE_KW,
WHILE_KW,
2021-01-13 15:01:50 +00:00
YIELD_KW,
2018-02-04 13:46:26 +00:00
AUTO_KW,
DEFAULT_KW,
2019-06-11 13:24:14 +00:00
EXISTENTIAL_KW,
2018-02-04 13:46:26 +00:00
UNION_KW,
RAW_KW,
2020-12-15 14:37:37 +00:00
MACRO_RULES_KW,
2018-07-30 15:02:13 +00:00
INT_NUMBER,
FLOAT_NUMBER,
CHAR,
BYTE,
STRING,
BYTE_STRING,
2019-01-31 07:30:15 +00:00
ERROR,
IDENT,
WHITESPACE,
2020-12-15 18:23:51 +00:00
LIFETIME_IDENT,
2018-07-30 15:02:13 +00:00
COMMENT,
SHEBANG,
2019-04-11 03:02:41 +00:00
L_DOLLAR,
R_DOLLAR,
2018-11-07 15:38:43 +00:00
SOURCE_FILE,
2020-07-30 15:50:40 +00:00
STRUCT,
2020-07-30 15:36:46 +00:00
UNION,
2020-07-30 15:52:53 +00:00
ENUM,
2020-07-30 12:51:08 +00:00
FN,
2018-08-28 18:11:17 +00:00
RET_TYPE,
2020-07-30 10:26:57 +00:00
EXTERN_CRATE,
2018-08-11 07:56:40 +00:00
MODULE,
2020-07-30 12:12:04 +00:00
USE,
2020-07-30 16:02:20 +00:00
STATIC,
CONST,
2020-07-30 16:17:28 +00:00
TRAIT,
2020-07-30 16:28:28 +00:00
IMPL,
2020-07-30 13:25:46 +00:00
TYPE_ALIAS,
2018-08-05 11:08:46 +00:00
MACRO_CALL,
2020-12-15 14:37:37 +00:00
MACRO_RULES,
MACRO_ARM,
2018-08-05 11:08:46 +00:00
TOKEN_TREE,
2019-12-21 10:29:14 +00:00
MACRO_DEF,
2018-02-10 21:46:17 +00:00
PAREN_TYPE,
TUPLE_TYPE,
2021-01-18 15:58:43 +00:00
MACRO_TYPE,
2018-02-10 21:46:17 +00:00
NEVER_TYPE,
PATH_TYPE,
2020-08-01 11:47:19 +00:00
PTR_TYPE,
2018-02-11 08:37:08 +00:00
ARRAY_TYPE,
SLICE_TYPE,
2020-08-01 11:47:19 +00:00
REF_TYPE,
2020-07-31 11:22:47 +00:00
INFER_TYPE,
2020-08-01 11:47:19 +00:00
FN_PTR_TYPE,
2018-02-11 20:32:49 +00:00
FOR_TYPE,
2018-07-31 19:41:29 +00:00
IMPL_TRAIT_TYPE,
2018-08-13 14:42:43 +00:00
DYN_TRAIT_TYPE,
2020-02-09 18:57:01 +00:00
OR_PAT,
PAREN_PAT,
REF_PAT,
2019-08-23 20:04:58 +00:00
BOX_PAT,
2020-07-31 18:09:09 +00:00
IDENT_PAT,
2020-07-31 18:07:21 +00:00
WILDCARD_PAT,
2020-07-31 19:45:29 +00:00
REST_PAT,
2018-08-04 12:47:45 +00:00
PATH_PAT,
2019-08-23 12:55:21 +00:00
RECORD_PAT,
2020-07-31 17:54:16 +00:00
RECORD_PAT_FIELD_LIST,
RECORD_PAT_FIELD,
2018-08-07 11:41:03 +00:00
TUPLE_STRUCT_PAT,
2018-08-04 12:47:45 +00:00
TUPLE_PAT,
2018-08-07 14:00:45 +00:00
SLICE_PAT,
2018-08-08 12:05:33 +00:00
RANGE_PAT,
LITERAL_PAT,
MACRO_PAT,
CONST_BLOCK_PAT,
TUPLE_EXPR,
2018-08-05 15:24:56 +00:00
ARRAY_EXPR,
2018-08-05 14:19:03 +00:00
PAREN_EXPR,
2018-07-30 14:02:51 +00:00
PATH_EXPR,
2020-07-31 15:08:58 +00:00
CLOSURE_EXPR,
2018-07-31 21:14:26 +00:00
IF_EXPR,
2018-08-27 09:22:09 +00:00
WHILE_EXPR,
CONDITION,
2018-08-05 15:16:52 +00:00
LOOP_EXPR,
2018-08-24 08:45:14 +00:00
FOR_EXPR,
2018-08-24 08:21:13 +00:00
CONTINUE_EXPR,
BREAK_EXPR,
2018-08-24 08:45:14 +00:00
LABEL,
2018-08-01 08:27:31 +00:00
BLOCK_EXPR,
RETURN_EXPR,
2021-01-13 15:01:50 +00:00
YIELD_EXPR,
2018-08-04 10:39:03 +00:00
MATCH_EXPR,
2018-08-24 16:27:30 +00:00
MATCH_ARM_LIST,
2018-08-04 10:39:03 +00:00
MATCH_ARM,
MATCH_GUARD,
2020-07-30 14:21:30 +00:00
RECORD_EXPR,
RECORD_EXPR_FIELD_LIST,
RECORD_EXPR_FIELD,
2020-05-01 23:18:19 +00:00
EFFECT_EXPR,
BOX_EXPR,
2018-08-04 13:34:54 +00:00
CALL_EXPR,
2018-08-05 14:24:44 +00:00
INDEX_EXPR,
2018-08-04 13:34:54 +00:00
METHOD_CALL_EXPR,
FIELD_EXPR,
AWAIT_EXPR,
2018-08-04 13:34:54 +00:00
TRY_EXPR,
2018-08-07 00:55:16 +00:00
CAST_EXPR,
2018-08-04 13:34:54 +00:00
REF_EXPR,
2018-08-07 11:52:03 +00:00
PREFIX_EXPR,
2018-08-05 15:07:06 +00:00
RANGE_EXPR,
2018-08-04 13:34:54 +00:00
BIN_EXPR,
2018-08-24 16:27:30 +00:00
EXTERN_BLOCK,
EXTERN_ITEM_LIST,
2020-07-30 15:56:53 +00:00
VARIANT,
2020-07-30 14:49:13 +00:00
RECORD_FIELD_LIST,
RECORD_FIELD,
TUPLE_FIELD_LIST,
TUPLE_FIELD,
2020-07-30 15:56:53 +00:00
VARIANT_LIST,
2018-08-24 16:27:30 +00:00
ITEM_LIST,
2020-07-30 09:42:51 +00:00
ASSOC_ITEM_LIST,
2018-01-28 02:36:28 +00:00
ATTR,
2021-06-11 16:12:51 +00:00
META,
2018-01-28 02:36:28 +00:00
USE_TREE,
2018-08-24 16:27:30 +00:00
USE_TREE_LIST,
2018-01-28 02:36:28 +00:00
PATH,
PATH_SEGMENT,
LITERAL,
2020-07-30 09:58:41 +00:00
RENAME,
2018-01-28 02:36:28 +00:00
VISIBILITY,
2018-02-10 09:53:07 +00:00
WHERE_CLAUSE,
2018-08-08 16:26:38 +00:00
WHERE_PRED,
2018-02-02 19:08:14 +00:00
ABI,
2018-02-10 11:00:23 +00:00
NAME,
NAME_REF,
LET_STMT,
2018-07-31 09:59:52 +00:00
EXPR_STMT,
GENERIC_PARAM_LIST,
2020-07-30 16:52:02 +00:00
GENERIC_PARAM,
2018-07-31 16:37:40 +00:00
LIFETIME_PARAM,
TYPE_PARAM,
CONST_PARAM,
2020-07-31 16:29:29 +00:00
GENERIC_ARG_LIST,
2020-12-15 18:23:51 +00:00
LIFETIME,
2018-07-31 16:37:40 +00:00
LIFETIME_ARG,
TYPE_ARG,
ASSOC_TYPE_ARG,
CONST_ARG,
2018-07-31 09:32:53 +00:00
PARAM_LIST,
2018-07-31 20:13:55 +00:00
PARAM,
2018-07-31 15:03:50 +00:00
SELF_PARAM,
2018-07-31 09:32:53 +00:00
ARG_LIST,
TYPE_BOUND,
TYPE_BOUND_LIST,
MACRO_ITEMS,
MACRO_STMTS,
2019-04-08 22:06:30 +00:00
#[doc(hidden)]
__LAST,
2018-01-28 02:36:28 +00:00
}
2018-07-30 11:06:22 +00:00
use self::SyntaxKind::*;
2018-01-28 02:36:28 +00:00
impl SyntaxKind {
2018-08-01 07:40:07 +00:00
pub fn is_keyword(self) -> bool {
match self {
AS_KW | ASYNC_KW | AWAIT_KW | BOX_KW | BREAK_KW | CONST_KW | CONTINUE_KW | CRATE_KW
| DYN_KW | ELSE_KW | ENUM_KW | EXTERN_KW | FALSE_KW | FN_KW | FOR_KW | IF_KW
| IMPL_KW | IN_KW | LET_KW | LOOP_KW | MACRO_KW | MATCH_KW | MOD_KW | MOVE_KW
| MUT_KW | PUB_KW | REF_KW | RETURN_KW | SELF_KW | STATIC_KW | STRUCT_KW | SUPER_KW
| TRAIT_KW | TRUE_KW | TRY_KW | TYPE_KW | UNSAFE_KW | USE_KW | WHERE_KW | WHILE_KW
2021-01-13 15:01:50 +00:00
| YIELD_KW | AUTO_KW | DEFAULT_KW | EXISTENTIAL_KW | UNION_KW | RAW_KW
| MACRO_RULES_KW => true,
2019-08-19 08:02:18 +00:00
_ => false,
2018-08-01 07:40:07 +00:00
}
}
2019-01-31 07:30:15 +00:00
pub fn is_punct(self) -> bool {
match self {
2020-04-10 15:06:57 +00:00
SEMICOLON | COMMA | L_PAREN | R_PAREN | L_CURLY | R_CURLY | L_BRACK | R_BRACK
| L_ANGLE | R_ANGLE | AT | POUND | TILDE | QUESTION | DOLLAR | AMP | PIPE | PLUS
| STAR | SLASH | CARET | PERCENT | UNDERSCORE | DOT | DOT2 | DOT3 | DOT2EQ | COLON
| COLON2 | EQ | EQ2 | FAT_ARROW | BANG | NEQ | MINUS | THIN_ARROW | LTEQ | GTEQ
| PLUSEQ | MINUSEQ | PIPEEQ | AMPEQ | CARETEQ | SLASHEQ | STAREQ | PERCENTEQ | AMP2
| PIPE2 | SHL | SHR | SHLEQ | SHREQ => true,
2019-08-19 08:02:18 +00:00
_ => false,
2019-01-31 07:30:15 +00:00
}
}
pub fn is_literal(self) -> bool {
match self {
INT_NUMBER | FLOAT_NUMBER | CHAR | BYTE | STRING | BYTE_STRING => true,
2019-08-19 08:02:18 +00:00
_ => false,
2019-01-31 07:30:15 +00:00
}
}
2019-02-21 10:27:45 +00:00
pub fn from_keyword(ident: &str) -> Option<SyntaxKind> {
2018-07-30 11:06:22 +00:00
let kw = match ident {
"as" => AS_KW,
2019-03-09 23:40:22 +00:00
"async" => ASYNC_KW,
"await" => AWAIT_KW,
"box" => BOX_KW,
"break" => BREAK_KW,
"const" => CONST_KW,
"continue" => CONTINUE_KW,
"crate" => CRATE_KW,
2018-08-13 14:42:43 +00:00
"dyn" => DYN_KW,
"else" => ELSE_KW,
"enum" => ENUM_KW,
2018-07-30 11:06:22 +00:00
"extern" => EXTERN_KW,
"false" => FALSE_KW,
"fn" => FN_KW,
2018-07-30 11:06:22 +00:00
"for" => FOR_KW,
"if" => IF_KW,
"impl" => IMPL_KW,
"in" => IN_KW,
"let" => LET_KW,
"loop" => LOOP_KW,
"macro" => MACRO_KW,
2018-07-30 11:06:22 +00:00
"match" => MATCH_KW,
"mod" => MOD_KW,
"move" => MOVE_KW,
2018-07-30 11:06:22 +00:00
"mut" => MUT_KW,
"pub" => PUB_KW,
2018-07-30 11:06:22 +00:00
"ref" => REF_KW,
2018-08-01 08:27:31 +00:00
"return" => RETURN_KW,
"self" => SELF_KW,
"static" => STATIC_KW,
"struct" => STRUCT_KW,
"super" => SUPER_KW,
"trait" => TRAIT_KW,
"true" => TRUE_KW,
2019-06-06 11:36:16 +00:00
"try" => TRY_KW,
"type" => TYPE_KW,
"unsafe" => UNSAFE_KW,
"use" => USE_KW,
"where" => WHERE_KW,
"while" => WHILE_KW,
2021-01-13 15:01:50 +00:00
"yield" => YIELD_KW,
2018-07-30 11:06:22 +00:00
_ => return None,
};
Some(kw)
2018-01-28 02:36:28 +00:00
}
2019-02-21 10:27:45 +00:00
pub fn from_char(c: char) -> Option<SyntaxKind> {
2018-07-30 14:46:50 +00:00
let tok = match c {
2020-04-10 15:06:57 +00:00
';' => SEMICOLON,
2018-07-30 14:46:50 +00:00
',' => COMMA,
'(' => L_PAREN,
')' => R_PAREN,
'{' => L_CURLY,
'}' => R_CURLY,
'[' => L_BRACK,
']' => R_BRACK,
'<' => L_ANGLE,
'>' => R_ANGLE,
'@' => AT,
'#' => POUND,
'~' => TILDE,
'?' => QUESTION,
'$' => DOLLAR,
2018-08-05 15:18:02 +00:00
'&' => AMP,
2018-07-30 14:46:50 +00:00
'|' => PIPE,
'+' => PLUS,
'*' => STAR,
'/' => SLASH,
'^' => CARET,
'%' => PERCENT,
2019-01-31 07:30:15 +00:00
'_' => UNDERSCORE,
2019-09-22 20:46:27 +00:00
'.' => DOT,
':' => COLON,
'=' => EQ,
2020-04-10 15:06:57 +00:00
'!' => BANG,
2019-09-22 20:46:27 +00:00
'-' => MINUS,
2018-07-30 14:46:50 +00:00
_ => return None,
};
Some(tok)
}
2018-01-01 15:58:46 +00:00
}
2019-08-19 08:02:18 +00:00
#[macro_export]
2021-01-13 15:01:50 +00:00
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