diff options
Diffstat (limited to 'src/parser')
-rw-r--r-- | src/parser/event_parser/grammar/items.rs | 9 | ||||
-rw-r--r-- | src/parser/event_parser/grammar/mod.rs | 7 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/parser/event_parser/grammar/items.rs b/src/parser/event_parser/grammar/items.rs index 68b444b69..9b174679c 100644 --- a/src/parser/event_parser/grammar/items.rs +++ b/src/parser/event_parser/grammar/items.rs | |||
@@ -11,7 +11,7 @@ pub(super) fn mod_items(p: &mut Parser) { | |||
11 | 11 | ||
12 | fn item_first(p: &Parser) -> bool { | 12 | fn item_first(p: &Parser) -> bool { |
13 | match p.current() { | 13 | match p.current() { |
14 | STRUCT_KW | FN_KW => true, | 14 | STRUCT_KW | FN_KW | EXTERN_KW => true, |
15 | _ => false, | 15 | _ => false, |
16 | } | 16 | } |
17 | } | 17 | } |
@@ -41,7 +41,8 @@ fn item(p: &mut Parser) -> bool { | |||
41 | // || node_if(p, FN_KW, FN_ITEM, fn_item) | 41 | // || node_if(p, FN_KW, FN_ITEM, fn_item) |
42 | // || node_if(p, MOD_KW, MOD_ITEM, mod_item) | 42 | // || node_if(p, MOD_KW, MOD_ITEM, mod_item) |
43 | // || node_if(p, TYPE_KW, TYPE_ITEM, type_item) | 43 | // || node_if(p, TYPE_KW, TYPE_ITEM, type_item) |
44 | node_if(p, STRUCT_KW, STRUCT_ITEM, struct_item) | 44 | node_if(p, [EXTERN_KW, CRATE_KW], EXTERN_CRATE_ITEM, extern_crate_item) |
45 | || node_if(p, STRUCT_KW, STRUCT_ITEM, struct_item) | ||
45 | || node_if(p, FN_KW, FN_ITEM, fn_item) | 46 | || node_if(p, FN_KW, FN_ITEM, fn_item) |
46 | } | 47 | } |
47 | 48 | ||
@@ -50,6 +51,10 @@ fn struct_item(p: &mut Parser) { | |||
50 | && p.curly_block(|p| comma_list(p, EOF, struct_field)); | 51 | && p.curly_block(|p| comma_list(p, EOF, struct_field)); |
51 | } | 52 | } |
52 | 53 | ||
54 | fn extern_crate_item(p: &mut Parser) { | ||
55 | p.expect(IDENT) && alias(p) && p.expect(SEMI); | ||
56 | } | ||
57 | |||
53 | fn struct_field(p: &mut Parser) -> bool { | 58 | fn struct_field(p: &mut Parser) -> bool { |
54 | node_if(p, IDENT, STRUCT_FIELD, |p| { | 59 | node_if(p, IDENT, STRUCT_FIELD, |p| { |
55 | p.expect(COLON) && p.expect(IDENT); | 60 | p.expect(COLON) && p.expect(IDENT); |
diff --git a/src/parser/event_parser/grammar/mod.rs b/src/parser/event_parser/grammar/mod.rs index 78309aa83..dd1270eae 100644 --- a/src/parser/event_parser/grammar/mod.rs +++ b/src/parser/event_parser/grammar/mod.rs | |||
@@ -18,6 +18,13 @@ pub(crate) fn file(p: &mut Parser) { | |||
18 | fn visibility(_: &mut Parser) { | 18 | fn visibility(_: &mut Parser) { |
19 | } | 19 | } |
20 | 20 | ||
21 | fn alias(p: &mut Parser) -> bool { | ||
22 | node_if(p, AS_KW, ALIAS, |p| { | ||
23 | p.expect(IDENT); | ||
24 | }); | ||
25 | true //FIXME: return false if three are errors | ||
26 | } | ||
27 | |||
21 | fn node_if<F: FnOnce(&mut Parser), L: Lookahead>( | 28 | fn node_if<F: FnOnce(&mut Parser), L: Lookahead>( |
22 | p: &mut Parser, | 29 | p: &mut Parser, |
23 | first: L, | 30 | first: L, |