aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/parser/event_parser/grammar/items/mod.rs28
-rw-r--r--src/syntax_kinds.rs11
2 files changed, 33 insertions, 6 deletions
diff --git a/src/parser/event_parser/grammar/items/mod.rs b/src/parser/event_parser/grammar/items/mod.rs
index 35825e7c4..9930de347 100644
--- a/src/parser/event_parser/grammar/items/mod.rs
+++ b/src/parser/event_parser/grammar/items/mod.rs
@@ -46,6 +46,10 @@ fn item(p: &mut Parser) {
46 } 46 }
47 } 47 }
48 } 48 }
49 STATIC_KW => {
50 static_item(p);
51 STATIC_ITEM
52 }
49 MOD_KW => { 53 MOD_KW => {
50 mod_item(p); 54 mod_item(p);
51 MOD_ITEM 55 MOD_ITEM
@@ -92,6 +96,24 @@ fn extern_crate_item(p: &mut Parser) {
92 p.expect(IDENT) && alias(p) && p.expect(SEMI); 96 p.expect(IDENT) && alias(p) && p.expect(SEMI);
93} 97}
94 98
99fn extern_block(p: &mut Parser) {
100 assert!(p.at(L_CURLY));
101 p.bump();
102 p.expect(R_CURLY);
103}
104
105fn static_item(p: &mut Parser) {
106 assert!(p.at(STATIC_KW));
107 p.bump();
108 p.eat(MUT_KW);
109 p.expect(IDENT);
110 p.expect(COLON);
111 types::type_ref(p);
112 p.expect(EQ);
113 expressions::expr(p);
114 p.expect(SEMI);
115}
116
95fn mod_item(p: &mut Parser) { 117fn mod_item(p: &mut Parser) {
96 assert!(p.at(MOD_KW)); 118 assert!(p.at(MOD_KW));
97 p.bump(); 119 p.bump();
@@ -104,12 +126,6 @@ fn mod_item(p: &mut Parser) {
104 } 126 }
105} 127}
106 128
107fn extern_block(p: &mut Parser) {
108 assert!(p.at(L_CURLY));
109 p.bump();
110 p.expect(R_CURLY);
111}
112
113fn abi(p: &mut Parser) { 129fn abi(p: &mut Parser) {
114 assert!(p.at(EXTERN_KW)); 130 assert!(p.at(EXTERN_KW));
115 let abi = p.start(); 131 let abi = p.start();
diff --git a/src/syntax_kinds.rs b/src/syntax_kinds.rs
index 7577fa037..8d21d3fb7 100644
--- a/src/syntax_kinds.rs
+++ b/src/syntax_kinds.rs
@@ -28,6 +28,9 @@ pub enum SyntaxKind {
28 WHILE_KW, 28 WHILE_KW,
29 IF_KW, 29 IF_KW,
30 MATCH_KW, 30 MATCH_KW,
31 CONST_KW,
32 STATIC_KW,
33 MUT_KW,
31 ERROR, 34 ERROR,
32 IDENT, 35 IDENT,
33 UNDERSCORE, 36 UNDERSCORE,
@@ -86,6 +89,7 @@ pub enum SyntaxKind {
86 EXTERN_CRATE_ITEM, 89 EXTERN_CRATE_ITEM,
87 MOD_ITEM, 90 MOD_ITEM,
88 USE_ITEM, 91 USE_ITEM,
92 STATIC_ITEM,
89 EXTERN_BLOCK, 93 EXTERN_BLOCK,
90 ENUM_VARIANT, 94 ENUM_VARIANT,
91 NAMED_FIELD, 95 NAMED_FIELD,
@@ -137,6 +141,9 @@ impl SyntaxKind {
137 WHILE_KW => &SyntaxInfo { name: "WHILE_KW" }, 141 WHILE_KW => &SyntaxInfo { name: "WHILE_KW" },
138 IF_KW => &SyntaxInfo { name: "IF_KW" }, 142 IF_KW => &SyntaxInfo { name: "IF_KW" },
139 MATCH_KW => &SyntaxInfo { name: "MATCH_KW" }, 143 MATCH_KW => &SyntaxInfo { name: "MATCH_KW" },
144 CONST_KW => &SyntaxInfo { name: "CONST_KW" },
145 STATIC_KW => &SyntaxInfo { name: "STATIC_KW" },
146 MUT_KW => &SyntaxInfo { name: "MUT_KW" },
140 ERROR => &SyntaxInfo { name: "ERROR" }, 147 ERROR => &SyntaxInfo { name: "ERROR" },
141 IDENT => &SyntaxInfo { name: "IDENT" }, 148 IDENT => &SyntaxInfo { name: "IDENT" },
142 UNDERSCORE => &SyntaxInfo { name: "UNDERSCORE" }, 149 UNDERSCORE => &SyntaxInfo { name: "UNDERSCORE" },
@@ -195,6 +202,7 @@ impl SyntaxKind {
195 EXTERN_CRATE_ITEM => &SyntaxInfo { name: "EXTERN_CRATE_ITEM" }, 202 EXTERN_CRATE_ITEM => &SyntaxInfo { name: "EXTERN_CRATE_ITEM" },
196 MOD_ITEM => &SyntaxInfo { name: "MOD_ITEM" }, 203 MOD_ITEM => &SyntaxInfo { name: "MOD_ITEM" },
197 USE_ITEM => &SyntaxInfo { name: "USE_ITEM" }, 204 USE_ITEM => &SyntaxInfo { name: "USE_ITEM" },
205 STATIC_ITEM => &SyntaxInfo { name: "STATIC_ITEM" },
198 EXTERN_BLOCK => &SyntaxInfo { name: "EXTERN_BLOCK" }, 206 EXTERN_BLOCK => &SyntaxInfo { name: "EXTERN_BLOCK" },
199 ENUM_VARIANT => &SyntaxInfo { name: "ENUM_VARIANT" }, 207 ENUM_VARIANT => &SyntaxInfo { name: "ENUM_VARIANT" },
200 NAMED_FIELD => &SyntaxInfo { name: "NAMED_FIELD" }, 208 NAMED_FIELD => &SyntaxInfo { name: "NAMED_FIELD" },
@@ -242,6 +250,9 @@ pub(crate) fn ident_to_keyword(ident: &str) -> Option<SyntaxKind> {
242 "while" => Some(WHILE_KW), 250 "while" => Some(WHILE_KW),
243 "if" => Some(IF_KW), 251 "if" => Some(IF_KW),
244 "match" => Some(MATCH_KW), 252 "match" => Some(MATCH_KW),
253 "const" => Some(CONST_KW),
254 "static" => Some(STATIC_KW),
255 "mut" => Some(MUT_KW),
245 _ => None, 256 _ => None,
246 } 257 }
247} 258}