aboutsummaryrefslogtreecommitdiff
path: root/src/parser/event_parser/grammar/attributes.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-01-20 18:49:58 +0000
committerAleksey Kladov <[email protected]>2018-01-20 18:49:58 +0000
commitbe60d5aa6669a74e92495288f44b7f9258a8518f (patch)
treeb115c6605755e903902ec2971ce2529cb87e3b8a /src/parser/event_parser/grammar/attributes.rs
parent111743d82c31bcaeb3cd7abbb261c0e038c2d909 (diff)
Drop more high-order stuff
Diffstat (limited to 'src/parser/event_parser/grammar/attributes.rs')
-rw-r--r--src/parser/event_parser/grammar/attributes.rs33
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 @@
1use super::*; 1use super::*;
2 2
3#[derive(PartialEq, Eq)]
3enum AttrKind { 4enum 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
16fn attribute(p: &mut Parser, kind: AttrKind) -> bool { 17fn 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
27fn meta_item(p: &mut Parser) -> bool { 35fn 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
42fn meta_item_inner(p: &mut Parser) -> bool { 57fn meta_item_inner(p: &mut Parser) -> bool {