diff options
Diffstat (limited to 'src/syntax_kinds.rs')
-rw-r--r-- | src/syntax_kinds.rs | 130 |
1 files changed, 77 insertions, 53 deletions
diff --git a/src/syntax_kinds.rs b/src/syntax_kinds.rs index b83f48dd8..a1bcad062 100644 --- a/src/syntax_kinds.rs +++ b/src/syntax_kinds.rs | |||
@@ -1,60 +1,72 @@ | |||
1 | // Generated from grammar.ron | 1 | // Generated from grammar.ron |
2 | use tree::{SyntaxKind, SyntaxInfo}; | 2 | use tree::{SyntaxKind, SyntaxInfo}; |
3 | 3 | ||
4 | pub const ERROR: SyntaxKind = SyntaxKind(0); | 4 | pub const USE_KW: SyntaxKind = SyntaxKind(0); |
5 | pub const IDENT: SyntaxKind = SyntaxKind(1); | 5 | pub const FN_KW: SyntaxKind = SyntaxKind(1); |
6 | pub const UNDERSCORE: SyntaxKind = SyntaxKind(2); | 6 | pub const STRUCT_KW: SyntaxKind = SyntaxKind(2); |
7 | pub const WHITESPACE: SyntaxKind = SyntaxKind(3); | 7 | pub const ENUM_KW: SyntaxKind = SyntaxKind(3); |
8 | pub const INT_NUMBER: SyntaxKind = SyntaxKind(4); | 8 | pub const TRAIT_KW: SyntaxKind = SyntaxKind(4); |
9 | pub const FLOAT_NUMBER: SyntaxKind = SyntaxKind(5); | 9 | pub const IMPL_KW: SyntaxKind = SyntaxKind(5); |
10 | pub const SEMI: SyntaxKind = SyntaxKind(6); | 10 | pub const ERROR: SyntaxKind = SyntaxKind(6); |
11 | pub const COMMA: SyntaxKind = SyntaxKind(7); | 11 | pub const IDENT: SyntaxKind = SyntaxKind(7); |
12 | pub const DOT: SyntaxKind = SyntaxKind(8); | 12 | pub const UNDERSCORE: SyntaxKind = SyntaxKind(8); |
13 | pub const DOTDOT: SyntaxKind = SyntaxKind(9); | 13 | pub const WHITESPACE: SyntaxKind = SyntaxKind(9); |
14 | pub const DOTDOTDOT: SyntaxKind = SyntaxKind(10); | 14 | pub const INT_NUMBER: SyntaxKind = SyntaxKind(10); |
15 | pub const DOTDOTEQ: SyntaxKind = SyntaxKind(11); | 15 | pub const FLOAT_NUMBER: SyntaxKind = SyntaxKind(11); |
16 | pub const L_PAREN: SyntaxKind = SyntaxKind(12); | 16 | pub const SEMI: SyntaxKind = SyntaxKind(12); |
17 | pub const R_PAREN: SyntaxKind = SyntaxKind(13); | 17 | pub const COMMA: SyntaxKind = SyntaxKind(13); |
18 | pub const L_CURLY: SyntaxKind = SyntaxKind(14); | 18 | pub const DOT: SyntaxKind = SyntaxKind(14); |
19 | pub const R_CURLY: SyntaxKind = SyntaxKind(15); | 19 | pub const DOTDOT: SyntaxKind = SyntaxKind(15); |
20 | pub const L_BRACK: SyntaxKind = SyntaxKind(16); | 20 | pub const DOTDOTDOT: SyntaxKind = SyntaxKind(16); |
21 | pub const R_BRACK: SyntaxKind = SyntaxKind(17); | 21 | pub const DOTDOTEQ: SyntaxKind = SyntaxKind(17); |
22 | pub const L_ANGLE: SyntaxKind = SyntaxKind(18); | 22 | pub const L_PAREN: SyntaxKind = SyntaxKind(18); |
23 | pub const R_ANGLE: SyntaxKind = SyntaxKind(19); | 23 | pub const R_PAREN: SyntaxKind = SyntaxKind(19); |
24 | pub const AT: SyntaxKind = SyntaxKind(20); | 24 | pub const L_CURLY: SyntaxKind = SyntaxKind(20); |
25 | pub const POUND: SyntaxKind = SyntaxKind(21); | 25 | pub const R_CURLY: SyntaxKind = SyntaxKind(21); |
26 | pub const TILDE: SyntaxKind = SyntaxKind(22); | 26 | pub const L_BRACK: SyntaxKind = SyntaxKind(22); |
27 | pub const QUESTION: SyntaxKind = SyntaxKind(23); | 27 | pub const R_BRACK: SyntaxKind = SyntaxKind(23); |
28 | pub const COLON: SyntaxKind = SyntaxKind(24); | 28 | pub const L_ANGLE: SyntaxKind = SyntaxKind(24); |
29 | pub const COLONCOLON: SyntaxKind = SyntaxKind(25); | 29 | pub const R_ANGLE: SyntaxKind = SyntaxKind(25); |
30 | pub const DOLLAR: SyntaxKind = SyntaxKind(26); | 30 | pub const AT: SyntaxKind = SyntaxKind(26); |
31 | pub const EQ: SyntaxKind = SyntaxKind(27); | 31 | pub const POUND: SyntaxKind = SyntaxKind(27); |
32 | pub const EQEQ: SyntaxKind = SyntaxKind(28); | 32 | pub const TILDE: SyntaxKind = SyntaxKind(28); |
33 | pub const FAT_ARROW: SyntaxKind = SyntaxKind(29); | 33 | pub const QUESTION: SyntaxKind = SyntaxKind(29); |
34 | pub const NEQ: SyntaxKind = SyntaxKind(30); | 34 | pub const COLON: SyntaxKind = SyntaxKind(30); |
35 | pub const NOT: SyntaxKind = SyntaxKind(31); | 35 | pub const COLONCOLON: SyntaxKind = SyntaxKind(31); |
36 | pub const LIFETIME: SyntaxKind = SyntaxKind(32); | 36 | pub const DOLLAR: SyntaxKind = SyntaxKind(32); |
37 | pub const CHAR: SyntaxKind = SyntaxKind(33); | 37 | pub const EQ: SyntaxKind = SyntaxKind(33); |
38 | pub const BYTE: SyntaxKind = SyntaxKind(34); | 38 | pub const EQEQ: SyntaxKind = SyntaxKind(34); |
39 | pub const STRING: SyntaxKind = SyntaxKind(35); | 39 | pub const FAT_ARROW: SyntaxKind = SyntaxKind(35); |
40 | pub const RAW_STRING: SyntaxKind = SyntaxKind(36); | 40 | pub const NEQ: SyntaxKind = SyntaxKind(36); |
41 | pub const BYTE_STRING: SyntaxKind = SyntaxKind(37); | 41 | pub const NOT: SyntaxKind = SyntaxKind(37); |
42 | pub const RAW_BYTE_STRING: SyntaxKind = SyntaxKind(38); | 42 | pub const LIFETIME: SyntaxKind = SyntaxKind(38); |
43 | pub const PLUS: SyntaxKind = SyntaxKind(39); | 43 | pub const CHAR: SyntaxKind = SyntaxKind(39); |
44 | pub const MINUS: SyntaxKind = SyntaxKind(40); | 44 | pub const BYTE: SyntaxKind = SyntaxKind(40); |
45 | pub const STAR: SyntaxKind = SyntaxKind(41); | 45 | pub const STRING: SyntaxKind = SyntaxKind(41); |
46 | pub const SLASH: SyntaxKind = SyntaxKind(42); | 46 | pub const RAW_STRING: SyntaxKind = SyntaxKind(42); |
47 | pub const CARET: SyntaxKind = SyntaxKind(43); | 47 | pub const BYTE_STRING: SyntaxKind = SyntaxKind(43); |
48 | pub const PERCENT: SyntaxKind = SyntaxKind(44); | 48 | pub const RAW_BYTE_STRING: SyntaxKind = SyntaxKind(44); |
49 | pub const AMPERSAND: SyntaxKind = SyntaxKind(45); | 49 | pub const PLUS: SyntaxKind = SyntaxKind(45); |
50 | pub const PIPE: SyntaxKind = SyntaxKind(46); | 50 | pub const MINUS: SyntaxKind = SyntaxKind(46); |
51 | pub const THIN_ARROW: SyntaxKind = SyntaxKind(47); | 51 | pub const STAR: SyntaxKind = SyntaxKind(47); |
52 | pub const COMMENT: SyntaxKind = SyntaxKind(48); | 52 | pub const SLASH: SyntaxKind = SyntaxKind(48); |
53 | pub const DOC_COMMENT: SyntaxKind = SyntaxKind(49); | 53 | pub const CARET: SyntaxKind = SyntaxKind(49); |
54 | pub const SHEBANG: SyntaxKind = SyntaxKind(50); | 54 | pub const PERCENT: SyntaxKind = SyntaxKind(50); |
55 | pub const FILE: SyntaxKind = SyntaxKind(51); | 55 | pub const AMPERSAND: SyntaxKind = SyntaxKind(51); |
56 | pub const PIPE: SyntaxKind = SyntaxKind(52); | ||
57 | pub const THIN_ARROW: SyntaxKind = SyntaxKind(53); | ||
58 | pub const COMMENT: SyntaxKind = SyntaxKind(54); | ||
59 | pub const DOC_COMMENT: SyntaxKind = SyntaxKind(55); | ||
60 | pub const SHEBANG: SyntaxKind = SyntaxKind(56); | ||
61 | pub const FILE: SyntaxKind = SyntaxKind(57); | ||
56 | 62 | ||
57 | static INFOS: [SyntaxInfo; 52] = [ | 63 | static INFOS: [SyntaxInfo; 58] = [ |
64 | SyntaxInfo { name: "USE_KW" }, | ||
65 | SyntaxInfo { name: "FN_KW" }, | ||
66 | SyntaxInfo { name: "STRUCT_KW" }, | ||
67 | SyntaxInfo { name: "ENUM_KW" }, | ||
68 | SyntaxInfo { name: "TRAIT_KW" }, | ||
69 | SyntaxInfo { name: "IMPL_KW" }, | ||
58 | SyntaxInfo { name: "ERROR" }, | 70 | SyntaxInfo { name: "ERROR" }, |
59 | SyntaxInfo { name: "IDENT" }, | 71 | SyntaxInfo { name: "IDENT" }, |
60 | SyntaxInfo { name: "UNDERSCORE" }, | 72 | SyntaxInfo { name: "UNDERSCORE" }, |
@@ -112,3 +124,15 @@ static INFOS: [SyntaxInfo; 52] = [ | |||
112 | pub(crate) fn syntax_info(kind: SyntaxKind) -> &'static SyntaxInfo { | 124 | pub(crate) fn syntax_info(kind: SyntaxKind) -> &'static SyntaxInfo { |
113 | &INFOS[kind.0 as usize] | 125 | &INFOS[kind.0 as usize] |
114 | } | 126 | } |
127 | |||
128 | pub(crate) fn ident_to_keyword(ident: &str) -> Option<SyntaxKind> { | ||
129 | match ident { | ||
130 | "use" => Some(USE_KW), | ||
131 | "fn" => Some(FN_KW), | ||
132 | "struct" => Some(STRUCT_KW), | ||
133 | "enum" => Some(ENUM_KW), | ||
134 | "trait" => Some(TRAIT_KW), | ||
135 | "impl" => Some(IMPL_KW), | ||
136 | _ => None, | ||
137 | } | ||
138 | } | ||