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.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/parser/event_parser/grammar/items.rs b/src/parser/event_parser/grammar/items.rs
new file mode 100644
index 000000000..b9eb1934c
--- /dev/null
+++ b/src/parser/event_parser/grammar/items.rs
@@ -0,0 +1,33 @@
1use super::*;
2
3pub(super) fn item_first(p: &Parser) -> bool {
4 match p.current() {
5 STRUCT_KW | FN_KW => true,
6 _ => false,
7 }
8}
9
10pub(super) fn item(p: &mut Parser) {
11 attributes::outer_attributes(p);
12 visibility(p);
13 node_if(p, STRUCT_KW, STRUCT_ITEM, struct_item)
14 || node_if(p, FN_KW, FN_ITEM, fn_item);
15}
16
17fn struct_item(p: &mut Parser) {
18 p.expect(IDENT)
19 && p.curly_block(|p| comma_list(p, EOF, struct_field));
20}
21
22fn struct_field(p: &mut Parser) -> bool {
23 node_if(p, IDENT, STRUCT_FIELD, |p| {
24 p.expect(COLON) && p.expect(IDENT);
25 })
26}
27
28fn fn_item(p: &mut Parser) {
29 p.expect(IDENT) && p.expect(L_PAREN) && p.expect(R_PAREN)
30 && p.curly_block(|p| ());
31}
32
33