Skip to content

Commit 83aa6f0

Browse files
committed
Simplify item parsing
1 parent 469654e commit 83aa6f0

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/parser/event_parser/grammar/items.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use super::*;
22

3-
pub(super) fn mod_contents(p: &mut Parser) {
3+
pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) {
44
attributes::inner_attributes(p);
5-
while !p.at(EOF) {
5+
while !p.at(EOF) && !(stop_on_r_curly && p.at(R_CURLY)) {
66
item(p);
77
}
88
}
@@ -152,7 +152,10 @@ fn mod_item(p: &mut Parser) {
152152
p.bump();
153153

154154
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+
}
156159
}
157160
}
158161

src/parser/event_parser/grammar/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mod paths;
1111
pub(crate) fn file(p: &mut Parser) {
1212
let file = p.start();
1313
p.eat(SHEBANG);
14-
items::mod_contents(p);
14+
items::mod_contents(p, false);
1515
file.complete(p, FILE);
1616
}
1717

0 commit comments

Comments
 (0)