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.rs29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/parser/event_parser/grammar/items.rs b/src/parser/event_parser/grammar/items.rs
index b9eb1934c..631eb4736 100644
--- a/src/parser/event_parser/grammar/items.rs
+++ b/src/parser/event_parser/grammar/items.rs
@@ -1,17 +1,40 @@
1use super::*; 1use super::*;
2 2
3pub(super) fn item_first(p: &Parser) -> bool { 3pub(super) fn mod_items(p: &mut Parser) {
4 many(p, |p| {
5 skip_to_first(
6 p, item_first, mod_item,
7 "expected item",
8 )
9 });
10}
11
12fn item_first(p: &Parser) -> bool {
4 match p.current() { 13 match p.current() {
5 STRUCT_KW | FN_KW => true, 14 STRUCT_KW | FN_KW => true,
6 _ => false, 15 _ => false,
7 } 16 }
8} 17}
9 18
10pub(super) fn item(p: &mut Parser) { 19fn mod_item(p: &mut Parser) {
20 if item(p) {
21 if p.current() == SEMI {
22 node(p, ERROR, |p| {
23 p.error()
24 .message("expected item, found `;`\n\
25 consider removing this semicolon")
26 .emit();
27 p.bump();
28 })
29 }
30 }
31}
32
33fn item(p: &mut Parser) -> bool {
11 attributes::outer_attributes(p); 34 attributes::outer_attributes(p);
12 visibility(p); 35 visibility(p);
13 node_if(p, STRUCT_KW, STRUCT_ITEM, struct_item) 36 node_if(p, STRUCT_KW, STRUCT_ITEM, struct_item)
14 || node_if(p, FN_KW, FN_ITEM, fn_item); 37 || node_if(p, FN_KW, FN_ITEM, fn_item)
15} 38}
16 39
17fn struct_item(p: &mut Parser) { 40fn struct_item(p: &mut Parser) {