diff options
author | Aleksey Kladov <[email protected]> | 2018-01-08 19:40:14 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-01-08 19:40:14 +0000 |
commit | 0cf2d6afee52fe248c8a032346c5bdb6dc7cd928 (patch) | |
tree | f98f950ada46f596502d8d9987efc67848c46321 /src/parser/event_parser/grammar/attributes.rs | |
parent | bdddfc9eb89ee717c38a117383a313e5a49bb267 (diff) |
Generalized lookahead
Diffstat (limited to 'src/parser/event_parser/grammar/attributes.rs')
-rw-r--r-- | src/parser/event_parser/grammar/attributes.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/parser/event_parser/grammar/attributes.rs b/src/parser/event_parser/grammar/attributes.rs index c80f782ab..52210ccad 100644 --- a/src/parser/event_parser/grammar/attributes.rs +++ b/src/parser/event_parser/grammar/attributes.rs | |||
@@ -9,16 +9,15 @@ pub(super) fn outer_attributes(_: &mut Parser) { | |||
9 | 9 | ||
10 | 10 | ||
11 | fn attribute(p: &mut Parser, inner: bool) -> bool { | 11 | fn attribute(p: &mut Parser, inner: bool) -> bool { |
12 | let attr_start = inner && p.lookahead(&[POUND, EXCL, L_BRACK]) | 12 | fn attr_tail(p: &mut Parser) { |
13 | || !inner && p.lookahead(&[POUND, L_BRACK]); | ||
14 | if !attr_start { | ||
15 | return false; | ||
16 | } | ||
17 | node(p, ATTR, |p| { | ||
18 | p.bump_n(if inner { 3 } else { 2 }); | ||
19 | meta_item(p) && p.expect(R_BRACK); | 13 | meta_item(p) && p.expect(R_BRACK); |
20 | }); | 14 | } |
21 | true | 15 | |
16 | if inner { | ||
17 | node_if(p, [POUND, EXCL, L_BRACK], ATTR, attr_tail) | ||
18 | } else { | ||
19 | node_if(p, [POUND, L_BRACK], ATTR, attr_tail) | ||
20 | } | ||
22 | } | 21 | } |
23 | 22 | ||
24 | fn meta_item(p: &mut Parser) -> bool { | 23 | fn meta_item(p: &mut Parser) -> bool { |