about summary refs log tree commit diff
path: root/src/comp/syntax/parse
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2011-11-23 20:57:34 +0100
committerMarijn Haverbeke <marijnh@gmail.com>2011-11-23 20:57:34 +0100
commite98286b5944c27cde4a5a268ff4ca926b40b8e76 (patch)
tree0c1f23fa08465a7048a87ff82336b101c4133f6e /src/comp/syntax/parse
parent03f6060e802e1acd8efe85b07bc98a97bf5caa7d (diff)
downloadrust-e98286b5944c27cde4a5a268ff4ca926b40b8e76.tar.gz
rust-e98286b5944c27cde4a5a268ff4ca926b40b8e76.zip
Allow import directives in any block
Closes #49
Diffstat (limited to 'src/comp/syntax/parse')
-rw-r--r--src/comp/syntax/parse/parser.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index 391d5eb8819..df769033028 100644
--- a/src/comp/syntax/parse/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -1697,8 +1697,8 @@ fn parse_block_no_value(p: parser) -> ast::blk {
 // necessary, and this should take a qualifier.
 // some blocks start with "#{"...
 fn parse_block_tail(p: parser, lo: uint, s: ast::blk_check_mode) -> ast::blk {
-    let stmts: [@ast::stmt] = [];
-    let expr: option::t<@ast::expr> = none;
+    let view_items = [], stmts = [], expr = none;
+    while is_word(p, "import") { view_items += [parse_view_item(p)]; }
     while p.peek() != token::RBRACE {
         alt p.peek() {
           token::SEMI. {
@@ -1736,7 +1736,8 @@ fn parse_block_tail(p: parser, lo: uint, s: ast::blk_check_mode) -> ast::blk {
     }
     let hi = p.get_hi_pos();
     p.bump();
-    let bloc = {stmts: stmts, expr: expr, id: p.get_id(), rules: s};
+    let bloc = {view_items: view_items, stmts: stmts, expr: expr,
+                id: p.get_id(), rules: s};
     ret spanned(lo, hi, bloc);
 }