aboutsummaryrefslogtreecommitdiff
path: root/src/parser/event_parser/grammar/items.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser/event_parser/grammar/items.rs')
-rw-r--r--src/parser/event_parser/grammar/items.rs38
1 files changed, 11 insertions, 27 deletions
diff --git a/src/parser/event_parser/grammar/items.rs b/src/parser/event_parser/grammar/items.rs
index 7706690cc..e569e5047 100644
--- a/src/parser/event_parser/grammar/items.rs
+++ b/src/parser/event_parser/grammar/items.rs
@@ -7,15 +7,8 @@ pub(super) fn mod_contents(p: &mut Parser) {
7 } 7 }
8} 8}
9 9
10pub(super) const ITEM_FIRST: TokenSet = token_set![ 10pub(super) const ITEM_FIRST: TokenSet =
11 EXTERN_KW, 11 token_set![EXTERN_KW, MOD_KW, USE_KW, STRUCT_KW, FN_KW, PUB_KW, POUND,];
12 MOD_KW,
13 USE_KW,
14 STRUCT_KW,
15 FN_KW,
16 PUB_KW,
17 POUND,
18];
19 12
20fn item(p: &mut Parser) { 13fn item(p: &mut Parser) {
21 let item = p.start(); 14 let item = p.start();
@@ -48,7 +41,7 @@ fn item(p: &mut Parser) {
48 let message = if err_token == SEMI { 41 let message = if err_token == SEMI {
49 //TODO: if the item is incomplete, this message is misleading 42 //TODO: if the item is incomplete, this message is misleading
50 "expected item, found `;`\n\ 43 "expected item, found `;`\n\
51 consider removing this semicolon" 44 consider removing this semicolon"
52 } else { 45 } else {
53 "expected item" 46 "expected item"
54 }; 47 };
@@ -76,10 +69,9 @@ fn struct_item(p: &mut Parser) {
76 return; 69 return;
77 } 70 }
78 L_CURLY => named_fields(p), 71 L_CURLY => named_fields(p),
79 _ => { //TODO: special case `(` error message 72 _ => {
80 p.error() 73 //TODO: special case `(` error message
81 .message("expected `;` or `{`") 74 p.error().message("expected `;` or `{`").emit();
82 .emit();
83 return; 75 return;
84 } 76 }
85 } 77 }
@@ -94,9 +86,7 @@ fn struct_item(p: &mut Parser) {
94 p.expect(SEMI); 86 p.expect(SEMI);
95 } 87 }
96 _ => { 88 _ => {
97 p.error() 89 p.error().message("expected `;`, `{`, or `(`").emit();
98 .message("expected `;`, `{`, or `(`")
99 .emit();
100 return; 90 return;
101 } 91 }
102 } 92 }
@@ -177,7 +167,7 @@ fn use_item(p: &mut Parser) {
177 use_tree(p); 167 use_tree(p);
178 p.expect(SEMI); 168 p.expect(SEMI);
179 169
180 fn use_tree(p: &mut Parser){ 170 fn use_tree(p: &mut Parser) {
181 let la = p.raw_lookahead(1); 171 let la = p.raw_lookahead(1);
182 let m = p.start(); 172 let m = p.start();
183 match (p.current(), la) { 173 match (p.current(), la) {
@@ -209,9 +199,7 @@ fn use_item(p: &mut Parser) {
209 L_CURLY => nested_trees(p), 199 L_CURLY => nested_trees(p),
210 _ => { 200 _ => {
211 // is this unreachable? 201 // is this unreachable?
212 p.error() 202 p.error().message("expected `{` or `*`").emit();
213 .message("expected `{` or `*`")
214 .emit();
215 } 203 }
216 } 204 }
217 } 205 }
@@ -222,7 +210,7 @@ fn use_item(p: &mut Parser) {
222 m.abandon(p); 210 m.abandon(p);
223 p.err_and_bump("expected one of `*`, `::`, `{`, `self`, `super`, `indent`"); 211 p.err_and_bump("expected one of `*`, `::`, `{`, `self`, `super`, `indent`");
224 return; 212 return;
225 }, 213 }
226 } 214 }
227 m.complete(p, USE_TREE); 215 m.complete(p, USE_TREE);
228 } 216 }
@@ -240,13 +228,9 @@ fn use_item(p: &mut Parser) {
240 } 228 }
241} 229}
242 230
243
244fn fn_item(p: &mut Parser) { 231fn fn_item(p: &mut Parser) {
245 assert!(p.at(FN_KW)); 232 assert!(p.at(FN_KW));
246 p.bump(); 233 p.bump();
247 234
248 p.expect(IDENT) && p.expect(L_PAREN) && p.expect(R_PAREN) 235 p.expect(IDENT) && p.expect(L_PAREN) && p.expect(R_PAREN) && p.curly_block(|_| ());
249 && p.curly_block(|_| ());
250} 236}
251
252