mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-28 17:53:56 +00:00
Simplify item parsing
This commit is contained in:
parent
469654e088
commit
83aa6f0899
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user