aboutsummaryrefslogtreecommitdiff
path: root/src/parser
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-01-28 10:02:15 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-01-28 10:02:15 +0000
commit37ee4c4c2afc1df536f50a776ac16dab69a67058 (patch)
treed5fa1fb60be28d819300eb4aec9df0dfe6200303 /src/parser
parent469654e08867b60c8a499fb3751a1c26e0b90397 (diff)
parent0663c24222ebb2da10c26f690ad508e7b1fae8f9 (diff)
Merge #23
23: Simplify item parsing r=matklad a=matklad
Diffstat (limited to 'src/parser')
-rw-r--r--src/parser/event_parser/grammar/items.rs9
-rw-r--r--src/parser/event_parser/grammar/mod.rs2
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 @@
1use super::*; 1use super::*;
2 2
3pub(super) fn mod_contents(p: &mut Parser) { 3pub(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;
11pub(crate) fn file(p: &mut Parser) { 11pub(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