From 9a8e9bc4c6339051ef260f7794603481b6ff0bf2 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 11 Jan 2018 23:01:12 +0300 Subject: G: item outer attributes --- src/parser/event_parser/grammar/attributes.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/parser/event_parser/grammar/attributes.rs') 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 @@ use super::*; +enum AttrKind { + Inner, Outer +} + pub(super) fn inner_attributes(p: &mut Parser) { - many(p, |p| attribute(p, true)) + many(p, |p| attribute(p, AttrKind::Inner)) } -pub(super) fn outer_attributes(_: &mut Parser) { +pub(super) fn outer_attributes(p: &mut Parser) { + many(p, |p| attribute(p, AttrKind::Outer)) } -fn attribute(p: &mut Parser, inner: bool) -> bool { +fn attribute(p: &mut Parser, kind: AttrKind) -> bool { fn attr_tail(p: &mut Parser) { meta_item(p) && p.expect(R_BRACK); } - if inner { - node_if(p, [POUND, EXCL, L_BRACK], ATTR, attr_tail) - } else { - node_if(p, [POUND, L_BRACK], ATTR, attr_tail) + match kind { + AttrKind::Inner => node_if(p, [POUND, EXCL, L_BRACK], ATTR, attr_tail), + AttrKind::Outer => node_if(p, [POUND, L_BRACK], ATTR, attr_tail), } } -- cgit v1.2.3