diff options
author | Aleksey Kladov <[email protected]> | 2018-01-11 20:01:12 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-01-11 20:01:12 +0000 |
commit | 9a8e9bc4c6339051ef260f7794603481b6ff0bf2 (patch) | |
tree | b9d23b06feda7249873ca40c88419e1b5c5d9bd6 /src/parser/event_parser/grammar/attributes.rs | |
parent | 89699c4803a0d12155adf653742f463872667610 (diff) |
G: item outer attributes
Diffstat (limited to 'src/parser/event_parser/grammar/attributes.rs')
-rw-r--r-- | src/parser/event_parser/grammar/attributes.rs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/parser/event_parser/grammar/attributes.rs b/src/parser/event_parser/grammar/attributes.rs index 52210ccad..d774f8827 100644 --- a/src/parser/event_parser/grammar/attributes.rs +++ b/src/parser/event_parser/grammar/attributes.rs | |||
@@ -1,22 +1,26 @@ | |||
1 | use super::*; | 1 | use super::*; |
2 | 2 | ||
3 | enum AttrKind { | ||
4 | Inner, Outer | ||
5 | } | ||
6 | |||
3 | pub(super) fn inner_attributes(p: &mut Parser) { | 7 | pub(super) fn inner_attributes(p: &mut Parser) { |
4 | many(p, |p| attribute(p, true)) | 8 | many(p, |p| attribute(p, AttrKind::Inner)) |
5 | } | 9 | } |
6 | 10 | ||
7 | pub(super) fn outer_attributes(_: &mut Parser) { | 11 | pub(super) fn outer_attributes(p: &mut Parser) { |
12 | many(p, |p| attribute(p, AttrKind::Outer)) | ||
8 | } | 13 | } |
9 | 14 | ||
10 | 15 | ||
11 | fn attribute(p: &mut Parser, inner: bool) -> bool { | 16 | fn attribute(p: &mut Parser, kind: AttrKind) -> bool { |
12 | fn attr_tail(p: &mut Parser) { | 17 | fn attr_tail(p: &mut Parser) { |
13 | meta_item(p) && p.expect(R_BRACK); | 18 | meta_item(p) && p.expect(R_BRACK); |
14 | } | 19 | } |
15 | 20 | ||
16 | if inner { | 21 | match kind { |
17 | node_if(p, [POUND, EXCL, L_BRACK], ATTR, attr_tail) | 22 | AttrKind::Inner => node_if(p, [POUND, EXCL, L_BRACK], ATTR, attr_tail), |
18 | } else { | 23 | AttrKind::Outer => node_if(p, [POUND, L_BRACK], ATTR, attr_tail), |
19 | node_if(p, [POUND, L_BRACK], ATTR, attr_tail) | ||
20 | } | 24 | } |
21 | } | 25 | } |
22 | 26 | ||