diff options
Diffstat (limited to 'src/parser/event_parser/grammar/attributes.rs')
-rw-r--r-- | src/parser/event_parser/grammar/attributes.rs | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/src/parser/event_parser/grammar/attributes.rs b/src/parser/event_parser/grammar/attributes.rs index a896b4901..8b5e5bcfe 100644 --- a/src/parser/event_parser/grammar/attributes.rs +++ b/src/parser/event_parser/grammar/attributes.rs | |||
@@ -1,5 +1,6 @@ | |||
1 | use super::*; | 1 | use super::*; |
2 | 2 | ||
3 | #[derive(PartialEq, Eq)] | ||
3 | enum AttrKind { | 4 | enum AttrKind { |
4 | Inner, Outer | 5 | Inner, Outer |
5 | } | 6 | } |
@@ -14,18 +15,27 @@ pub(super) fn outer_attributes(p: &mut Parser) { | |||
14 | 15 | ||
15 | 16 | ||
16 | fn attribute(p: &mut Parser, kind: AttrKind) -> bool { | 17 | fn attribute(p: &mut Parser, kind: AttrKind) -> bool { |
17 | fn attr_tail(p: &mut Parser) { | 18 | if p.at(POUND) { |
18 | meta_item(p) && p.expect(R_BRACK); | 19 | if kind == AttrKind::Inner && p.raw_lookahead(1) != EXCL { |
19 | } | 20 | return false; |
20 | 21 | } | |
21 | match kind { | 22 | p.start(ATTR); |
22 | AttrKind::Inner => node_if(p, [POUND, EXCL, L_BRACK], ATTR, attr_tail), | 23 | p.bump(); |
23 | AttrKind::Outer => node_if(p, [POUND, L_BRACK], ATTR, attr_tail), | 24 | if kind == AttrKind::Inner { |
25 | p.bump(); | ||
26 | } | ||
27 | p.expect(L_BRACK) && meta_item(p) && p.expect(R_BRACK); | ||
28 | p.finish(); | ||
29 | true | ||
30 | } else { | ||
31 | false | ||
24 | } | 32 | } |
25 | } | 33 | } |
26 | 34 | ||
27 | fn meta_item(p: &mut Parser) -> bool { | 35 | fn meta_item(p: &mut Parser) -> bool { |
28 | node_if(p, IDENT, META_ITEM, |p| { | 36 | if p.at(IDENT) { |
37 | p.start(META_ITEM); | ||
38 | p.bump(); | ||
29 | if p.eat(EQ) { | 39 | if p.eat(EQ) { |
30 | if !expressions::literal(p) { | 40 | if !expressions::literal(p) { |
31 | p.error() | 41 | p.error() |
@@ -36,7 +46,12 @@ fn meta_item(p: &mut Parser) -> bool { | |||
36 | comma_list(p, R_PAREN, meta_item_inner); | 46 | comma_list(p, R_PAREN, meta_item_inner); |
37 | p.expect(R_PAREN); | 47 | p.expect(R_PAREN); |
38 | } | 48 | } |
39 | }) | 49 | p.finish(); |
50 | true | ||
51 | } else { | ||
52 | false | ||
53 | } | ||
54 | |||
40 | } | 55 | } |
41 | 56 | ||
42 | fn meta_item_inner(p: &mut Parser) -> bool { | 57 | fn meta_item_inner(p: &mut Parser) -> bool { |