Simplify item parsing

This commit is contained in:
Aleksey Kladov 2018-01-28 12:57:03 +03:00
parent 469654e088
commit 83aa6f0899
2 changed files with 7 additions and 4 deletions

View File

@ -1,8 +1,8 @@
use super::*;
pub(super) fn mod_contents(p: &mut Parser) {
pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) {
attributes::inner_attributes(p);
while !p.at(EOF) {
while !p.at(EOF) && !(stop_on_r_curly && p.at(R_CURLY)) {
item(p);
}
}
@ -152,7 +152,10 @@ fn mod_item(p: &mut Parser) {
p.bump();
if p.expect(IDENT) && !p.eat(SEMI) {
p.curly_block(mod_contents);
if p.expect(L_CURLY) {
mod_contents(p, true);
p.expect(R_CURLY);
}
}
}

View File

@ -11,7 +11,7 @@ mod paths;
pub(crate) fn file(p: &mut Parser) {
let file = p.start();
p.eat(SHEBANG);
items::mod_contents(p);
items::mod_contents(p, false);
file.complete(p, FILE);
}