diff options
author | Aleksey Kladov <[email protected]> | 2018-07-31 21:38:19 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-07-31 21:44:31 +0100 |
commit | 7912189ec304b28c4df0030b5282cf3d21074154 (patch) | |
tree | 03a0a1b128439fdefbd1d012b392995ca8a6e264 /src/parser/grammar/attributes.rs | |
parent | d1400e95d7ad701fcba1191cb00968c2eae8b394 (diff) |
reorganize
Diffstat (limited to 'src/parser/grammar/attributes.rs')
-rw-r--r-- | src/parser/grammar/attributes.rs | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/src/parser/grammar/attributes.rs b/src/parser/grammar/attributes.rs deleted file mode 100644 index c411d4d7f..000000000 --- a/src/parser/grammar/attributes.rs +++ /dev/null | |||
@@ -1,79 +0,0 @@ | |||
1 | use super::*; | ||
2 | |||
3 | pub(super) fn inner_attributes(p: &mut Parser) { | ||
4 | while p.current() == POUND && p.nth(1) == EXCL { | ||
5 | attribute(p, true) | ||
6 | } | ||
7 | } | ||
8 | |||
9 | pub(super) fn outer_attributes(p: &mut Parser) { | ||
10 | while p.at(POUND) { | ||
11 | attribute(p, false) | ||
12 | } | ||
13 | } | ||
14 | |||
15 | fn attribute(p: &mut Parser, inner: bool) { | ||
16 | let attr = p.start(); | ||
17 | assert!(p.at(POUND)); | ||
18 | p.bump(); | ||
19 | |||
20 | if inner { | ||
21 | assert!(p.at(EXCL)); | ||
22 | p.bump(); | ||
23 | } | ||
24 | |||
25 | if p.expect(L_BRACK) { | ||
26 | meta_item(p); | ||
27 | p.expect(R_BRACK); | ||
28 | } | ||
29 | attr.complete(p, ATTR); | ||
30 | } | ||
31 | |||
32 | fn meta_item(p: &mut Parser) { | ||
33 | if p.at(IDENT) { | ||
34 | let meta_item = p.start(); | ||
35 | p.bump(); | ||
36 | match p.current() { | ||
37 | EQ => { | ||
38 | p.bump(); | ||
39 | if expressions::literal(p).is_none() { | ||
40 | p.error("expected literal"); | ||
41 | } | ||
42 | } | ||
43 | L_PAREN => meta_item_arg_list(p), | ||
44 | _ => (), | ||
45 | } | ||
46 | meta_item.complete(p, META_ITEM); | ||
47 | } else { | ||
48 | p.error("expected attribute value"); | ||
49 | } | ||
50 | } | ||
51 | |||
52 | fn meta_item_arg_list(p: &mut Parser) { | ||
53 | assert!(p.at(L_PAREN)); | ||
54 | p.bump(); | ||
55 | loop { | ||
56 | match p.current() { | ||
57 | EOF | R_PAREN => break, | ||
58 | IDENT => meta_item(p), | ||
59 | c => if expressions::literal(p).is_none() { | ||
60 | let message = "expected attribute"; | ||
61 | |||
62 | if items::ITEM_FIRST.contains(c) { | ||
63 | p.error(message); | ||
64 | return; | ||
65 | } | ||
66 | |||
67 | let err = p.start(); | ||
68 | p.error(message); | ||
69 | p.bump(); | ||
70 | err.complete(p, ERROR); | ||
71 | continue; | ||
72 | }, | ||
73 | } | ||
74 | if !p.at(R_PAREN) { | ||
75 | p.expect(COMMA); | ||
76 | } | ||
77 | } | ||
78 | p.expect(R_PAREN); | ||
79 | } | ||