diff options
author | Aleksey Kladov <[email protected]> | 2018-01-28 09:57:03 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-01-28 09:57:03 +0000 |
commit | 83aa6f0899fa3d8de87389d789d0e330739d0117 (patch) | |
tree | 3b5ede1d3e49da79eb002ee6178af15102e5f8cb /src | |
parent | 469654e08867b60c8a499fb3751a1c26e0b90397 (diff) |
Simplify item parsing
Diffstat (limited to 'src')
-rw-r--r-- | src/parser/event_parser/grammar/items.rs | 9 | ||||
-rw-r--r-- | src/parser/event_parser/grammar/mod.rs | 2 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/parser/event_parser/grammar/items.rs b/src/parser/event_parser/grammar/items.rs index e569e5047..0638e3093 100644 --- a/src/parser/event_parser/grammar/items.rs +++ b/src/parser/event_parser/grammar/items.rs | |||
@@ -1,8 +1,8 @@ | |||
1 | use super::*; | 1 | use super::*; |
2 | 2 | ||
3 | pub(super) fn mod_contents(p: &mut Parser) { | 3 | pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) { |
4 | attributes::inner_attributes(p); | 4 | attributes::inner_attributes(p); |
5 | while !p.at(EOF) { | 5 | while !p.at(EOF) && !(stop_on_r_curly && p.at(R_CURLY)) { |
6 | item(p); | 6 | item(p); |
7 | } | 7 | } |
8 | } | 8 | } |
@@ -152,7 +152,10 @@ fn mod_item(p: &mut Parser) { | |||
152 | p.bump(); | 152 | p.bump(); |
153 | 153 | ||
154 | if p.expect(IDENT) && !p.eat(SEMI) { | 154 | if p.expect(IDENT) && !p.eat(SEMI) { |
155 | p.curly_block(mod_contents); | 155 | if p.expect(L_CURLY) { |
156 | mod_contents(p, true); | ||
157 | p.expect(R_CURLY); | ||
158 | } | ||
156 | } | 159 | } |
157 | } | 160 | } |
158 | 161 | ||
diff --git a/src/parser/event_parser/grammar/mod.rs b/src/parser/event_parser/grammar/mod.rs index 82f8b7f3e..b87f3ca8a 100644 --- a/src/parser/event_parser/grammar/mod.rs +++ b/src/parser/event_parser/grammar/mod.rs | |||
@@ -11,7 +11,7 @@ mod paths; | |||
11 | pub(crate) fn file(p: &mut Parser) { | 11 | pub(crate) fn file(p: &mut Parser) { |
12 | let file = p.start(); | 12 | let file = p.start(); |
13 | p.eat(SHEBANG); | 13 | p.eat(SHEBANG); |
14 | items::mod_contents(p); | 14 | items::mod_contents(p, false); |
15 | file.complete(p, FILE); | 15 | file.complete(p, FILE); |
16 | } | 16 | } |
17 | 17 | ||