about summary refs log tree commit diff
path: root/src/comp/syntax/parse
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2011-07-07 15:31:54 -0700
committerPatrick Walton <pcwalton@mimiga.net>2011-07-07 18:39:05 -0700
commite1b107d74ef5c27ec4c000f1fe4a9f55a7c67b97 (patch)
tree3fb5b61494d04031acf71fe90353b0db043daf28 /src/comp/syntax/parse
parent3958c72cd8c899bfc77a56ad859e31e13615c1c5 (diff)
downloadrust-e1b107d74ef5c27ec4c000f1fe4a9f55a7c67b97.tar.gz
rust-e1b107d74ef5c27ec4c000f1fe4a9f55a7c67b97.zip
rustc: Remove all exterior vectors from the AST
Diffstat (limited to 'src/comp/syntax/parse')
-rw-r--r--src/comp/syntax/parse/eval.rs20
-rw-r--r--src/comp/syntax/parse/parser.rs36
2 files changed, 27 insertions, 29 deletions
diff --git a/src/comp/syntax/parse/eval.rs b/src/comp/syntax/parse/eval.rs
index d3806454b06..feaf24d62b0 100644
--- a/src/comp/syntax/parse/eval.rs
+++ b/src/comp/syntax/parse/eval.rs
@@ -25,8 +25,8 @@ type ctx =
          ast::crate_cfg cfg);
 
 fn eval_crate_directives(ctx cx, &(@ast::crate_directive)[] cdirs,
-                         str prefix, &mutable vec[@ast::view_item] view_items,
-                         &mutable vec[@ast::item] items) {
+                         str prefix, &mutable (@ast::view_item)[] view_items,
+                         &mutable (@ast::item)[] items) {
     for (@ast::crate_directive sub_cdir in cdirs) {
         eval_crate_directive(cx, sub_cdir, prefix, view_items, items);
     }
@@ -34,15 +34,15 @@ fn eval_crate_directives(ctx cx, &(@ast::crate_directive)[] cdirs,
 
 fn eval_crate_directives_to_mod(ctx cx, &(@ast::crate_directive)[] cdirs,
                                 str prefix) -> ast::_mod {
-    let vec[@ast::view_item] view_items = [];
-    let vec[@ast::item] items = [];
+    let (@ast::view_item)[] view_items = ~[];
+    let (@ast::item)[] items = ~[];
     eval_crate_directives(cx, cdirs, prefix, view_items, items);
     ret rec(view_items=view_items, items=items);
 }
 
 fn eval_crate_directive(ctx cx, @ast::crate_directive cdir, str prefix,
-                        &mutable vec[@ast::view_item] view_items,
-                        &mutable vec[@ast::item] items) {
+                        &mutable (@ast::view_item)[] view_items,
+                        &mutable (@ast::item)[] items) {
     alt (cdir.node) {
         case (ast::cdir_src_mod(?id, ?file_opt, ?attrs)) {
             auto file_path = id + ".rs";
@@ -68,7 +68,7 @@ fn eval_crate_directive(ctx cx, @ast::crate_directive cdir, str prefix,
                  mod_attrs);
             // Thread defids and chpos through the parsers
             cx.chpos = p0.get_chpos();
-            vec::push[@ast::item](items, i);
+            items += ~[i];
         }
         case (ast::cdir_dir_mod(?id, ?dir_opt, ?cdirs, ?attrs)) {
             auto path = id;
@@ -85,11 +85,9 @@ fn eval_crate_directive(ctx cx, @ast::crate_directive cdir, str prefix,
                           node=ast::item_mod(m0),
                           span=cdir.span);
             cx.sess.next_id += 1;
-            vec::push[@ast::item](items, i);
-        }
-        case (ast::cdir_view_item(?vi)) {
-            vec::push[@ast::view_item](view_items, vi);
+            items += ~[i];
         }
+        case (ast::cdir_view_item(?vi)) { view_items += ~[vi]; }
         case (ast::cdir_syntax(?pth)) { }
         case (ast::cdir_auth(?pth, ?eff)) { }
     }
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index 455d95e0f93..75235bfb809 100644
--- a/src/comp/syntax/parse/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -1859,15 +1859,15 @@ fn parse_mod_items(&parser p, token::token term,
         parse_view(p)
     } else {
         // Shouldn't be any view items since we've already parsed an item attr
-        []
+        ~[]
     };
-    let vec[@ast::item] items = [];
+    let (@ast::item)[] items = ~[];
     auto initial_attrs = first_item_attrs;
     while (p.peek() != term) {
         auto attrs = initial_attrs + parse_outer_attributes(p);
         initial_attrs = ~[];
         alt (parse_item(p, attrs)) {
-            case (got_item(?i)) { vec::push(items, i); }
+            case (got_item(?i)) { items += ~[i]; }
             case (_) {
                 p.fatal("expected item but found " +
                           token::to_str(p.get_reader(), p.peek()));
@@ -1948,14 +1948,14 @@ fn parse_native_mod_items(&parser p, &str native_name, ast::native_abi abi,
         parse_native_view(p)
     } else {
         // Shouldn't be any view items since we've already parsed an item attr
-        []
+        ~[]
     };
-    let vec[@ast::native_item] items = [];
+    let (@ast::native_item)[] items = ~[];
     auto initial_attrs = first_item_attrs;
     while (p.peek() != token::RBRACE) {
         auto attrs = initial_attrs + parse_outer_attributes(p);
         initial_attrs = ~[];
-        items += [parse_native_item(p, attrs)];
+        items += ~[parse_native_item(p, attrs)];
     }
     ret rec(native_name=native_name,
             abi=abi,
@@ -2028,7 +2028,7 @@ fn parse_item_tag(&parser p, &ast::attribute[] attrs) -> @ast::item {
         expect(p, token::SEMI);
         auto variant = spanned(ty.span.lo, ty.span.hi,
                                rec(name=id,
-                                   args=[rec(ty=ty, id=p.get_id())],
+                                   args=~[rec(ty=ty, id=p.get_id())],
                                    id=p.get_id()));
         ret mk_item(p, lo, ty.span.hi, id,
                     ast::item_tag(~[variant], ty_params), attrs);
@@ -2041,14 +2041,14 @@ fn parse_item_tag(&parser p, &ast::attribute[] attrs) -> @ast::item {
                 check_bad_word(p);
                 auto vlo = p.get_lo_pos();
                 p.bump();
-                let vec[ast::variant_arg] args = [];
+                let ast::variant_arg[] args = ~[];
                 alt (p.peek()) {
                     case (token::LPAREN) {
                         auto arg_tys =
                             parse_seq(token::LPAREN, token::RPAREN,
                                       some(token::COMMA), parse_ty, p);
                         for (@ast::ty ty in arg_tys.node) {
-                            args += [rec(ty=ty, id=p.get_id())];
+                            args += ~[rec(ty=ty, id=p.get_id())];
                         }
                     }
                     case (_) {/* empty */ }
@@ -2243,7 +2243,7 @@ fn parse_rest_import_name(&parser p, ast::ident first,
                           option::t[ast::ident] def_ident) ->
    @ast::view_item {
     auto lo = p.get_lo_pos();
-    let vec[ast::ident] identifiers = [first];
+    let ast::ident[] identifiers = ~[first];
     let bool glob = false;
     while (true) {
         alt (p.peek()) {
@@ -2255,7 +2255,7 @@ fn parse_rest_import_name(&parser p, ast::ident first,
             case (_) { p.fatal("expecting '::' or ';'"); }
         }
         alt (p.peek()) {
-            case (token::IDENT(_, _)) { identifiers += [parse_ident(p)]; }
+            case (token::IDENT(_, _)) { identifiers += ~[parse_ident(p)]; }
             case (
                  //the lexer can't tell the different kinds of stars apart ) :
                  token::BINOP(token::STAR)) {
@@ -2278,7 +2278,7 @@ fn parse_rest_import_name(&parser p, ast::ident first,
                 import_decl =
                     ast::view_item_import_glob(identifiers, p.get_id());
             } else {
-                auto len = vec::len(identifiers);
+                auto len = ivec::len(identifiers);
                 import_decl =
                     ast::view_item_import(identifiers.(len - 1u), identifiers,
                                           p.get_id());
@@ -2347,15 +2347,15 @@ fn is_view_item(&parser p) -> bool {
     ret false;
 }
 
-fn parse_view(&parser p) -> vec[@ast::view_item] {
-    let vec[@ast::view_item] items = [];
-    while (is_view_item(p)) { items += [parse_view_item(p)]; }
+fn parse_view(&parser p) -> (@ast::view_item)[] {
+    let (@ast::view_item)[] items = ~[];
+    while (is_view_item(p)) { items += ~[parse_view_item(p)]; }
     ret items;
 }
 
-fn parse_native_view(&parser p) -> vec[@ast::view_item] {
-    let vec[@ast::view_item] items = [];
-    while (is_view_item(p)) { items += [parse_view_item(p)]; }
+fn parse_native_view(&parser p) -> (@ast::view_item)[] {
+    let (@ast::view_item)[] items = ~[];
+    while (is_view_item(p)) { items += ~[parse_view_item(p)]; }
     ret items;
 }