aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/parser/event_parser/grammar/paths.rs13
-rw-r--r--src/syntax_kinds.rs135
2 files changed, 80 insertions, 68 deletions
diff --git a/src/parser/event_parser/grammar/paths.rs b/src/parser/event_parser/grammar/paths.rs
index 108545bc2..d6887a9ba 100644
--- a/src/parser/event_parser/grammar/paths.rs
+++ b/src/parser/event_parser/grammar/paths.rs
@@ -1,7 +1,7 @@
1use super::*; 1use super::*;
2 2
3pub(crate) fn use_path(p: &mut Parser) { 3pub(crate) fn use_path(p: &mut Parser) {
4 if !AnyOf(&[IDENT, COLONCOLON]).is_ahead(p) { 4 if !AnyOf(&[IDENT, SELF_KW, SUPER_KW, COLONCOLON]).is_ahead(p) {
5 return; 5 return;
6 } 6 }
7 let mut prev = p.mark(); 7 let mut prev = p.mark();
@@ -23,6 +23,15 @@ fn path_segment(p: &mut Parser, first: bool) {
23 if first { 23 if first {
24 p.eat(COLONCOLON); 24 p.eat(COLONCOLON);
25 } 25 }
26 p.expect(IDENT); 26 match p.current() {
27 IDENT | SELF_KW | SUPER_KW => {
28 p.bump();
29 },
30 _ => {
31 p.error()
32 .message("expected identifier")
33 .emit();
34 }
35 };
27 }) 36 })
28} \ No newline at end of file 37} \ No newline at end of file
diff --git a/src/syntax_kinds.rs b/src/syntax_kinds.rs
index 84f1072b7..48f55fa97 100644
--- a/src/syntax_kinds.rs
+++ b/src/syntax_kinds.rs
@@ -16,73 +16,74 @@ pub const MOD_KW: SyntaxKind = SyntaxKind(11);
16pub const PUB_KW: SyntaxKind = SyntaxKind(12); 16pub const PUB_KW: SyntaxKind = SyntaxKind(12);
17pub const SELF_KW: SyntaxKind = SyntaxKind(13); 17pub const SELF_KW: SyntaxKind = SyntaxKind(13);
18pub const SUPER_KW: SyntaxKind = SyntaxKind(14); 18pub const SUPER_KW: SyntaxKind = SyntaxKind(14);
19pub const ERROR: SyntaxKind = SyntaxKind(15); 19pub const IN_KW: SyntaxKind = SyntaxKind(15);
20pub const IDENT: SyntaxKind = SyntaxKind(16); 20pub const ERROR: SyntaxKind = SyntaxKind(16);
21pub const UNDERSCORE: SyntaxKind = SyntaxKind(17); 21pub const IDENT: SyntaxKind = SyntaxKind(17);
22pub const WHITESPACE: SyntaxKind = SyntaxKind(18); 22pub const UNDERSCORE: SyntaxKind = SyntaxKind(18);
23pub const INT_NUMBER: SyntaxKind = SyntaxKind(19); 23pub const WHITESPACE: SyntaxKind = SyntaxKind(19);
24pub const FLOAT_NUMBER: SyntaxKind = SyntaxKind(20); 24pub const INT_NUMBER: SyntaxKind = SyntaxKind(20);
25pub const SEMI: SyntaxKind = SyntaxKind(21); 25pub const FLOAT_NUMBER: SyntaxKind = SyntaxKind(21);
26pub const COMMA: SyntaxKind = SyntaxKind(22); 26pub const SEMI: SyntaxKind = SyntaxKind(22);
27pub const DOT: SyntaxKind = SyntaxKind(23); 27pub const COMMA: SyntaxKind = SyntaxKind(23);
28pub const DOTDOT: SyntaxKind = SyntaxKind(24); 28pub const DOT: SyntaxKind = SyntaxKind(24);
29pub const DOTDOTDOT: SyntaxKind = SyntaxKind(25); 29pub const DOTDOT: SyntaxKind = SyntaxKind(25);
30pub const DOTDOTEQ: SyntaxKind = SyntaxKind(26); 30pub const DOTDOTDOT: SyntaxKind = SyntaxKind(26);
31pub const L_PAREN: SyntaxKind = SyntaxKind(27); 31pub const DOTDOTEQ: SyntaxKind = SyntaxKind(27);
32pub const R_PAREN: SyntaxKind = SyntaxKind(28); 32pub const L_PAREN: SyntaxKind = SyntaxKind(28);
33pub const L_CURLY: SyntaxKind = SyntaxKind(29); 33pub const R_PAREN: SyntaxKind = SyntaxKind(29);
34pub const R_CURLY: SyntaxKind = SyntaxKind(30); 34pub const L_CURLY: SyntaxKind = SyntaxKind(30);
35pub const L_BRACK: SyntaxKind = SyntaxKind(31); 35pub const R_CURLY: SyntaxKind = SyntaxKind(31);
36pub const R_BRACK: SyntaxKind = SyntaxKind(32); 36pub const L_BRACK: SyntaxKind = SyntaxKind(32);
37pub const L_ANGLE: SyntaxKind = SyntaxKind(33); 37pub const R_BRACK: SyntaxKind = SyntaxKind(33);
38pub const R_ANGLE: SyntaxKind = SyntaxKind(34); 38pub const L_ANGLE: SyntaxKind = SyntaxKind(34);
39pub const AT: SyntaxKind = SyntaxKind(35); 39pub const R_ANGLE: SyntaxKind = SyntaxKind(35);
40pub const POUND: SyntaxKind = SyntaxKind(36); 40pub const AT: SyntaxKind = SyntaxKind(36);
41pub const TILDE: SyntaxKind = SyntaxKind(37); 41pub const POUND: SyntaxKind = SyntaxKind(37);
42pub const QUESTION: SyntaxKind = SyntaxKind(38); 42pub const TILDE: SyntaxKind = SyntaxKind(38);
43pub const COLON: SyntaxKind = SyntaxKind(39); 43pub const QUESTION: SyntaxKind = SyntaxKind(39);
44pub const COLONCOLON: SyntaxKind = SyntaxKind(40); 44pub const COLON: SyntaxKind = SyntaxKind(40);
45pub const DOLLAR: SyntaxKind = SyntaxKind(41); 45pub const COLONCOLON: SyntaxKind = SyntaxKind(41);
46pub const EQ: SyntaxKind = SyntaxKind(42); 46pub const DOLLAR: SyntaxKind = SyntaxKind(42);
47pub const EQEQ: SyntaxKind = SyntaxKind(43); 47pub const EQ: SyntaxKind = SyntaxKind(43);
48pub const FAT_ARROW: SyntaxKind = SyntaxKind(44); 48pub const EQEQ: SyntaxKind = SyntaxKind(44);
49pub const NEQ: SyntaxKind = SyntaxKind(45); 49pub const FAT_ARROW: SyntaxKind = SyntaxKind(45);
50pub const EXCL: SyntaxKind = SyntaxKind(46); 50pub const NEQ: SyntaxKind = SyntaxKind(46);
51pub const LIFETIME: SyntaxKind = SyntaxKind(47); 51pub const EXCL: SyntaxKind = SyntaxKind(47);
52pub const CHAR: SyntaxKind = SyntaxKind(48); 52pub const LIFETIME: SyntaxKind = SyntaxKind(48);
53pub const BYTE: SyntaxKind = SyntaxKind(49); 53pub const CHAR: SyntaxKind = SyntaxKind(49);
54pub const STRING: SyntaxKind = SyntaxKind(50); 54pub const BYTE: SyntaxKind = SyntaxKind(50);
55pub const RAW_STRING: SyntaxKind = SyntaxKind(51); 55pub const STRING: SyntaxKind = SyntaxKind(51);
56pub const BYTE_STRING: SyntaxKind = SyntaxKind(52); 56pub const RAW_STRING: SyntaxKind = SyntaxKind(52);
57pub const RAW_BYTE_STRING: SyntaxKind = SyntaxKind(53); 57pub const BYTE_STRING: SyntaxKind = SyntaxKind(53);
58pub const PLUS: SyntaxKind = SyntaxKind(54); 58pub const RAW_BYTE_STRING: SyntaxKind = SyntaxKind(54);
59pub const MINUS: SyntaxKind = SyntaxKind(55); 59pub const PLUS: SyntaxKind = SyntaxKind(55);
60pub const STAR: SyntaxKind = SyntaxKind(56); 60pub const MINUS: SyntaxKind = SyntaxKind(56);
61pub const SLASH: SyntaxKind = SyntaxKind(57); 61pub const STAR: SyntaxKind = SyntaxKind(57);
62pub const CARET: SyntaxKind = SyntaxKind(58); 62pub const SLASH: SyntaxKind = SyntaxKind(58);
63pub const PERCENT: SyntaxKind = SyntaxKind(59); 63pub const CARET: SyntaxKind = SyntaxKind(59);
64pub const AMPERSAND: SyntaxKind = SyntaxKind(60); 64pub const PERCENT: SyntaxKind = SyntaxKind(60);
65pub const PIPE: SyntaxKind = SyntaxKind(61); 65pub const AMPERSAND: SyntaxKind = SyntaxKind(61);
66pub const THIN_ARROW: SyntaxKind = SyntaxKind(62); 66pub const PIPE: SyntaxKind = SyntaxKind(62);
67pub const COMMENT: SyntaxKind = SyntaxKind(63); 67pub const THIN_ARROW: SyntaxKind = SyntaxKind(63);
68pub const DOC_COMMENT: SyntaxKind = SyntaxKind(64); 68pub const COMMENT: SyntaxKind = SyntaxKind(64);
69pub const SHEBANG: SyntaxKind = SyntaxKind(65); 69pub const DOC_COMMENT: SyntaxKind = SyntaxKind(65);
70pub const FILE: SyntaxKind = SyntaxKind(66); 70pub const SHEBANG: SyntaxKind = SyntaxKind(66);
71pub const STRUCT_ITEM: SyntaxKind = SyntaxKind(67); 71pub const FILE: SyntaxKind = SyntaxKind(67);
72pub const STRUCT_FIELD: SyntaxKind = SyntaxKind(68); 72pub const STRUCT_ITEM: SyntaxKind = SyntaxKind(68);
73pub const FN_ITEM: SyntaxKind = SyntaxKind(69); 73pub const STRUCT_FIELD: SyntaxKind = SyntaxKind(69);
74pub const EXTERN_CRATE_ITEM: SyntaxKind = SyntaxKind(70); 74pub const FN_ITEM: SyntaxKind = SyntaxKind(70);
75pub const ATTR: SyntaxKind = SyntaxKind(71); 75pub const EXTERN_CRATE_ITEM: SyntaxKind = SyntaxKind(71);
76pub const META_ITEM: SyntaxKind = SyntaxKind(72); 76pub const ATTR: SyntaxKind = SyntaxKind(72);
77pub const MOD_ITEM: SyntaxKind = SyntaxKind(73); 77pub const META_ITEM: SyntaxKind = SyntaxKind(73);
78pub const USE_ITEM: SyntaxKind = SyntaxKind(74); 78pub const MOD_ITEM: SyntaxKind = SyntaxKind(74);
79pub const PATH: SyntaxKind = SyntaxKind(75); 79pub const USE_ITEM: SyntaxKind = SyntaxKind(75);
80pub const PATH_SEGMENT: SyntaxKind = SyntaxKind(76); 80pub const PATH: SyntaxKind = SyntaxKind(76);
81pub const LITERAL: SyntaxKind = SyntaxKind(77); 81pub const PATH_SEGMENT: SyntaxKind = SyntaxKind(77);
82pub const ALIAS: SyntaxKind = SyntaxKind(78); 82pub const LITERAL: SyntaxKind = SyntaxKind(78);
83pub const VISIBILITY: SyntaxKind = SyntaxKind(79); 83pub const ALIAS: SyntaxKind = SyntaxKind(79);
84pub const VISIBILITY: SyntaxKind = SyntaxKind(80);
84 85
85static INFOS: [SyntaxInfo; 80] = [ 86static INFOS: [SyntaxInfo; 81] = [
86 SyntaxInfo { name: "USE_KW" }, 87 SyntaxInfo { name: "USE_KW" },
87 SyntaxInfo { name: "FN_KW" }, 88 SyntaxInfo { name: "FN_KW" },
88 SyntaxInfo { name: "STRUCT_KW" }, 89 SyntaxInfo { name: "STRUCT_KW" },
@@ -98,6 +99,7 @@ static INFOS: [SyntaxInfo; 80] = [
98 SyntaxInfo { name: "PUB_KW" }, 99 SyntaxInfo { name: "PUB_KW" },
99 SyntaxInfo { name: "SELF_KW" }, 100 SyntaxInfo { name: "SELF_KW" },
100 SyntaxInfo { name: "SUPER_KW" }, 101 SyntaxInfo { name: "SUPER_KW" },
102 SyntaxInfo { name: "IN_KW" },
101 SyntaxInfo { name: "ERROR" }, 103 SyntaxInfo { name: "ERROR" },
102 SyntaxInfo { name: "IDENT" }, 104 SyntaxInfo { name: "IDENT" },
103 SyntaxInfo { name: "UNDERSCORE" }, 105 SyntaxInfo { name: "UNDERSCORE" },
@@ -186,6 +188,7 @@ pub(crate) fn ident_to_keyword(ident: &str) -> Option<SyntaxKind> {
186 "pub" => Some(PUB_KW), 188 "pub" => Some(PUB_KW),
187 "self" => Some(SELF_KW), 189 "self" => Some(SELF_KW),
188 "super" => Some(SUPER_KW), 190 "super" => Some(SUPER_KW),
191 "in" => Some(IN_KW),
189 _ => None, 192 _ => None,
190 } 193 }
191} 194}