Skip to content

Commit e0556c7

Browse files
committed
---
yaml --- r: 7286 b: refs/heads/master c: 17585cc h: refs/heads/master v: v3
1 parent b66c3f7 commit e0556c7

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 16462a77b0014356f75e5da60c787604371dd903
2+
refs/heads/master: 17585cc47ec7c4ffc9d14f33473c4238b6680e88

trunk/src/comp/syntax/parse/parser.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,8 +1630,8 @@ fn parse_block_no_value(p: parser) -> ast::blk {
16301630
// necessary, and this should take a qualifier.
16311631
// some blocks start with "#{"...
16321632
fn parse_block_tail(p: parser, lo: uint, s: ast::blk_check_mode) -> ast::blk {
1633-
let view_items = [], stmts = [], expr = none;
1634-
while is_word(p, "import") { view_items += [parse_view_item(p)]; }
1633+
let stmts = [], expr = none;
1634+
let view_items = parse_view_import_only(p);
16351635
while p.token != token::RBRACE {
16361636
alt p.token {
16371637
token::SEMI. {
@@ -2378,15 +2378,21 @@ fn is_view_item(p: parser) -> bool {
23782378
}
23792379

23802380
fn parse_view(p: parser) -> [@ast::view_item] {
2381-
let items: [@ast::view_item] = [];
2382-
while is_view_item(p) { items += [parse_view_item(p)]; }
2381+
parse_view_while(p, is_view_item)
2382+
}
2383+
2384+
fn parse_view_import_only(p: parser) -> [@ast::view_item] {
2385+
parse_view_while(p, bind is_word(_, "import"))
2386+
}
2387+
2388+
fn parse_view_while(p: parser, f: fn@(parser) -> bool) -> [@ast::view_item] {
2389+
let items = [];
2390+
while f(p) { items += [parse_view_item(p)]; }
23832391
ret items;
23842392
}
23852393

23862394
fn parse_native_view(p: parser) -> [@ast::view_item] {
2387-
let items: [@ast::view_item] = [];
2388-
while is_view_item(p) { items += [parse_view_item(p)]; }
2389-
ret items;
2395+
parse_view_while(p, is_view_item)
23902396
}
23912397

23922398
fn parse_crate_from_source_file(input: str, cfg: ast::crate_cfg,

0 commit comments

Comments
 (0)