about summary refs log tree commit diff
path: root/src/comp/syntax
diff options
context:
space:
mode:
authorErick Tryzelaar <erick.tryzelaar@gmail.com>2011-08-12 06:36:51 -0700
committerGraydon Hoare <graydon@mozilla.com>2011-08-16 15:05:56 -0700
commit4abc471390d897e97e07eafcb723a8dcb59c520f (patch)
treeddd4e2cd31c18e1f786ed9b240b1dfe2cd947e46 /src/comp/syntax
parent4c9049c50c5c32f556eaefbcc50209ef8ee353d0 (diff)
downloadrust-4abc471390d897e97e07eafcb723a8dcb59c520f.tar.gz
rust-4abc471390d897e97e07eafcb723a8dcb59c520f.zip
Port the compiler to foo<T> decl syntax.
Diffstat (limited to 'src/comp/syntax')
-rw-r--r--src/comp/syntax/ast.rs12
-rw-r--r--src/comp/syntax/ext/simplext.rs4
-rw-r--r--src/comp/syntax/fold.rs2
-rw-r--r--src/comp/syntax/parse/parser.rs16
-rw-r--r--src/comp/syntax/print/pprust.rs10
-rw-r--r--src/comp/syntax/untyped_ast.rs4
-rw-r--r--src/comp/syntax/util/interner.rs10
-rw-r--r--src/comp/syntax/visit.rs46
8 files changed, 52 insertions, 52 deletions
diff --git a/src/comp/syntax/ast.rs b/src/comp/syntax/ast.rs
index 05a9f86d04e..5500d7a3e68 100644
--- a/src/comp/syntax/ast.rs
+++ b/src/comp/syntax/ast.rs
@@ -5,8 +5,8 @@ import std::str;
 import codemap::span;
 import codemap::filename;
 
-type spanned[T] = {node: T, span: span};
-fn respan[T](sp: &span, t: &T) -> spanned<T> { ret {node: t, span: sp}; }
+type spanned<T> = {node: T, span: span};
+fn respan<T>(sp: &span, t: &T) -> spanned<T> { ret {node: t, span: sp}; }
 
 /* assuming that we're not in macro expansion */
 fn mk_sp(lo: uint, hi: uint) -> span {
@@ -468,10 +468,10 @@ so that the typestate pass doesn't have to map a function name onto its decl.
 So, the constr_arg type is parameterized: it's instantiated with uint for
 declarations, and ident for uses.
 */
-tag constr_arg_general_[T] { carg_base; carg_ident(T); carg_lit(@lit); }
+tag constr_arg_general_<T> { carg_base; carg_ident(T); carg_lit(@lit); }
 
 type fn_constr_arg = constr_arg_general_<uint>;
-type sp_constr_arg[T] = spanned<constr_arg_general_<T>>;
+type sp_constr_arg<T> = spanned<constr_arg_general_<T>>;
 type ty_constr_arg = sp_constr_arg<path>;
 type constr_arg = spanned<fn_constr_arg>;
 
@@ -480,12 +480,12 @@ type constr_arg = spanned<fn_constr_arg>;
 // The implicit root of such path, in the constraint-list for a
 // constrained type, is * (referring to the base record)
 
-type constr_general_[ARG, ID] =
+type constr_general_<ARG, ID> =
     {path: path, args: [@spanned<constr_arg_general_<ARG>>], id: ID};
 
 // In the front end, constraints have a node ID attached.
 // Typeck turns this to a def_id, using the output of resolve.
-type constr_general[ARG] = spanned<constr_general_<ARG, node_id>>;
+type constr_general<ARG> = spanned<constr_general_<ARG, node_id>>;
 type constr_ = constr_general_<uint, node_id>;
 type constr = spanned<constr_general_<uint, node_id>>;
 type ty_constr_ = ast::constr_general_<ast::path, ast::node_id>;
diff --git a/src/comp/syntax/ext/simplext.rs b/src/comp/syntax/ext/simplext.rs
index aae2404f57b..462f9d7ce0c 100644
--- a/src/comp/syntax/ext/simplext.rs
+++ b/src/comp/syntax/ext/simplext.rs
@@ -43,7 +43,7 @@ fn path_to_ident(pth: &path) -> option::t<ident> {
 type clause = {params: binders, body: @expr};
 
 /* logically, an arb_depth should contain only one kind of matchable */
-tag arb_depth[T] { leaf(T); seq(@[arb_depth<T>], span); }
+tag arb_depth<T> { leaf(T); seq(@[arb_depth<T>], span); }
 
 
 tag matchable {
@@ -121,7 +121,7 @@ fn elts_to_ell(cx: &ext_ctxt, elts: &[@expr])
     }
 }
 
-fn option_flatten_map[T, U](f: &fn(&T) -> option::t<U>, v: &[T]) ->
+fn option_flatten_map<T, U>(f: &fn(&T) -> option::t<U>, v: &[T]) ->
    option::t<[U]> {
     let res = ~[];
     for elem: T in v {
diff --git a/src/comp/syntax/fold.rs b/src/comp/syntax/fold.rs
index ca318f191d8..5e6db11c9d2 100644
--- a/src/comp/syntax/fold.rs
+++ b/src/comp/syntax/fold.rs
@@ -75,7 +75,7 @@ type a_f =
      new_span: fn(&span) -> span};
 
 
-//fn nf_dummy[T](&T node) -> T { fail; }
+//fn nf_dummy<T>(&T node) -> T { fail; }
 fn nf_crate_dummy(c: &crate) -> crate { fail; }
 fn nf_crate_directive_dummy(c: &@crate_directive) -> @crate_directive {
     fail;
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index 3bdeef0c011..aa5628b1bad 100644
--- a/src/comp/syntax/parse/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -224,7 +224,7 @@ fn expect_gt(p: &parser) {
     }
 }
 
-fn spanned[T](lo: uint, hi: uint, node: &T) -> spanned<T> {
+fn spanned<T>(lo: uint, hi: uint, node: &T) -> spanned<T> {
     ret {node: node, span: ast::mk_sp(lo, hi)};
 }
 
@@ -429,7 +429,7 @@ fn parse_constr_in_type(p: &parser) -> @ast::ty_constr {
 }
 
 
-fn parse_constrs[T](pser: fn(&parser) -> @ast::constr_general<T>, p: &parser)
+fn parse_constrs<T>(pser: fn(&parser) -> @ast::constr_general<T>, p: &parser)
    -> [@ast::constr_general<T>] {
     let constrs: [@ast::constr_general<T>] = ~[];
     while true {
@@ -643,7 +643,7 @@ fn parse_fn_block_arg(p: &parser) -> ast::arg {
     ret {mode: m, ty: t, ident: i, id: p.get_id()};
 }
 
-fn parse_seq_to_before_gt[T](sep: option::t<token::token>,
+fn parse_seq_to_before_gt<T>(sep: option::t<token::token>,
                              f: fn(&parser) -> T, p: &parser) -> [T] {
     let first = true;
     let v = ~[];
@@ -660,7 +660,7 @@ fn parse_seq_to_before_gt[T](sep: option::t<token::token>,
     ret v;
 }
 
-fn parse_seq_to_gt[T](sep: option::t<token::token>, f: fn(&parser) -> T,
+fn parse_seq_to_gt<T>(sep: option::t<token::token>, f: fn(&parser) -> T,
                       p: &parser) -> [T] {
     let v = parse_seq_to_before_gt(sep, f, p);
     expect_gt(p);
@@ -668,7 +668,7 @@ fn parse_seq_to_gt[T](sep: option::t<token::token>, f: fn(&parser) -> T,
     ret v;
 }
 
-fn parse_seq_lt_gt[T](sep: option::t<token::token>, f: fn(&parser) -> T,
+fn parse_seq_lt_gt<T>(sep: option::t<token::token>, f: fn(&parser) -> T,
                       p: &parser) -> spanned<[T]> {
     let lo = p.get_lo_pos();
     expect(p, token::LT);
@@ -678,14 +678,14 @@ fn parse_seq_lt_gt[T](sep: option::t<token::token>, f: fn(&parser) -> T,
     ret spanned(lo, hi, result);
 }
 
-fn parse_seq_to_end[T](ket: token::token, sep: option::t<token::token>,
+fn parse_seq_to_end<T>(ket: token::token, sep: option::t<token::token>,
                        f: fn(&parser) -> T , p: &parser) -> [T] {
     let val = parse_seq_to_before_end(ket, sep, f, p);
     p.bump();
     ret val;
 }
 
-fn parse_seq_to_before_end[T](ket: token::token, sep: option::t<token::token>,
+fn parse_seq_to_before_end<T>(ket: token::token, sep: option::t<token::token>,
                               f: fn(&parser) -> T , p: &parser) -> [T] {
     let first: bool = true;
     let v: [T] = ~[];
@@ -700,7 +700,7 @@ fn parse_seq_to_before_end[T](ket: token::token, sep: option::t<token::token>,
 }
 
 
-fn parse_seq[T](bra: token::token, ket: token::token,
+fn parse_seq<T>(bra: token::token, ket: token::token,
                 sep: option::t<token::token>, f: fn(&parser) -> T ,
                 p: &parser) -> spanned<[T]> {
     let lo = p.get_lo_pos();
diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs
index 330b859aa85..66a1062de7e 100644
--- a/src/comp/syntax/print/pprust.rs
+++ b/src/comp/syntax/print/pprust.rs
@@ -217,7 +217,7 @@ fn synth_comment(s: &ps, text: str) {
     word(s.s, "*/");
 }
 
-fn commasep[IN](s: &ps, b: breaks, elts: &[IN], op: fn(&ps, &IN) ) {
+fn commasep<IN>(s: &ps, b: breaks, elts: &[IN], op: fn(&ps, &IN) ) {
     box(s, 0u, b);
     let first = true;
     for elt: IN in elts {
@@ -228,7 +228,7 @@ fn commasep[IN](s: &ps, b: breaks, elts: &[IN], op: fn(&ps, &IN) ) {
 }
 
 
-fn commasep_cmnt[IN](s: &ps, b: breaks, elts: &[IN], op: fn(&ps, &IN) ,
+fn commasep_cmnt<IN>(s: &ps, b: breaks, elts: &[IN], op: fn(&ps, &IN) ,
                      get_span: fn(&IN) -> codemap::span ) {
     box(s, 0u, b);
     let len = vec::len[IN](elts);
@@ -1515,7 +1515,7 @@ fn escape_str(st: str, to_escape: char) -> str {
     ret out;
 }
 
-fn to_str[T](t: &T, f: fn(&ps, &T) ) -> str {
+fn to_str<T>(t: &T, f: fn(&ps, &T) ) -> str {
     let writer = io::string_writer();
     let s = rust_printer(writer.get_writer());
     f(s, t);
@@ -1536,7 +1536,7 @@ fn next_comment(s: &ps) -> option::t<lexer::cmnt> {
 
 // Removing the aliases from the type of f in the next two functions
 // triggers memory corruption, but I haven't isolated the bug yet. FIXME
-fn constr_args_to_str[T](f: &fn(&T) -> str ,
+fn constr_args_to_str<T>(f: &fn(&T) -> str ,
                          args: &[@ast::sp_constr_arg<T>]) -> str {
     let comma = false;
     let s = "(";
@@ -1548,7 +1548,7 @@ fn constr_args_to_str[T](f: &fn(&T) -> str ,
     ret s;
 }
 
-fn constr_arg_to_str[T](f: &fn(&T) -> str, c: &ast::constr_arg_general_<T>)
+fn constr_arg_to_str<T>(f: &fn(&T) -> str, c: &ast::constr_arg_general_<T>)
    -> str {
     alt c {
       ast::carg_base. { ret "*"; }
diff --git a/src/comp/syntax/untyped_ast.rs b/src/comp/syntax/untyped_ast.rs
index ad92513ede0..cc746c00f41 100644
--- a/src/comp/syntax/untyped_ast.rs
+++ b/src/comp/syntax/untyped_ast.rs
@@ -370,7 +370,7 @@ fn dummy() {
          extract_fn(ctx, elts.(idx))]];
 }
 
-fn seq_cv[T](conversion: fn (&ctx, &@ast_node) -> T)
+fn seq_cv<T>(conversion: fn (&ctx, &@ast_node) -> T)
     -> fn (&ctx, @ast_node) -> T[] {
     ret lambda(ctx: &ctx, ut: @ast_node) -> T[] {
         ret alt *ut {
@@ -383,7 +383,7 @@ fn seq_cv[T](conversion: fn (&ctx, &@ast_node) -> T)
     }
 }
 
-fn opt_cv[T](conversion: fn (&ctx, &@ast_node) -> T)
+fn opt_cv<T>(conversion: fn (&ctx, &@ast_node) -> T)
     -> fn (&ctx, @ast_node) -> option::t<T> {
     ret lambda(ctx: &ctx, ut: @ast_node) -> option::t<T> {
         ret alt *ut {
diff --git a/src/comp/syntax/util/interner.rs b/src/comp/syntax/util/interner.rs
index b0838d5329d..8edfd3cb618 100644
--- a/src/comp/syntax/util/interner.rs
+++ b/src/comp/syntax/util/interner.rs
@@ -10,18 +10,18 @@ import std::option;
 import std::option::none;
 import std::option::some;
 
-type interner[T] =
+type interner<T> =
     {map: hashmap<T, uint>,
      mutable vect: [T],
      hasher: hashfn<T>,
      eqer: eqfn<T>};
 
-fn mk[@T](hasher: hashfn<T>, eqer: eqfn<T>) -> interner<T> {
+fn mk<@T>(hasher: hashfn<T>, eqer: eqfn<T>) -> interner<T> {
     let m = map::mk_hashmap[T, uint](hasher, eqer);
     ret {map: m, mutable vect: ~[], hasher: hasher, eqer: eqer};
 }
 
-fn intern[@T](itr: &interner<T>, val: &T) -> uint {
+fn intern<@T>(itr: &interner<T>, val: &T) -> uint {
     alt itr.map.find(val) {
       some(idx) { ret idx; }
       none. {
@@ -33,7 +33,7 @@ fn intern[@T](itr: &interner<T>, val: &T) -> uint {
     }
 }
 
-fn get[T](itr: &interner<T>, idx: uint) -> T { ret itr.vect.(idx); }
+fn get<T>(itr: &interner<T>, idx: uint) -> T { ret itr.vect.(idx); }
 
-fn len[T](itr : &interner<T>) -> uint { ret vec::len(itr.vect); }
+fn len<T>(itr : &interner<T>) -> uint { ret vec::len(itr.vect); }
 
diff --git a/src/comp/syntax/visit.rs b/src/comp/syntax/visit.rs
index 8f4323e5c17..2b91f704285 100644
--- a/src/comp/syntax/visit.rs
+++ b/src/comp/syntax/visit.rs
@@ -14,9 +14,9 @@ import codemap::span;
 
 // Our typesystem doesn't do circular types, so the visitor record can not
 // hold functions that take visitors. A vt tag is used to break the cycle.
-tag vt[E] { mk_vt(visitor<E>); }
+tag vt<E> { mk_vt(visitor<E>); }
 
-type visitor[E] =
+type visitor<E> =
     // takes the components so that one function can be
     // generic over constr and ty_constr
     @{visit_mod: fn(&_mod, &span, &E, &vt<E>),
@@ -35,7 +35,7 @@ type visitor[E] =
       visit_fn:
           fn(&_fn, &[ty_param], &span, &fn_ident, node_id, &E, &vt<E>) };
 
-fn default_visitor[E]() -> visitor<E> {
+fn default_visitor<E>() -> visitor<E> {
     ret @{visit_mod: bind visit_mod[E](_, _, _, _),
           visit_view_item: bind visit_view_item[E](_, _, _),
           visit_native_item: bind visit_native_item[E](_, _, _),
@@ -52,11 +52,11 @@ fn default_visitor[E]() -> visitor<E> {
           visit_fn: bind visit_fn[E](_, _, _, _, _, _, _)};
 }
 
-fn visit_crate[E](c: &crate, e: &E, v: &vt<E>) {
+fn visit_crate<E>(c: &crate, e: &E, v: &vt<E>) {
     v.visit_mod(c.node.module, c.span, e, v);
 }
 
-fn visit_crate_directive[E](cd: &@crate_directive, e: &E, v: &vt<E>) {
+fn visit_crate_directive<E>(cd: &@crate_directive, e: &E, v: &vt<E>) {
     alt cd.node {
       cdir_src_mod(_, _, _) { }
       cdir_dir_mod(_, _, cdirs, _) {
@@ -70,20 +70,20 @@ fn visit_crate_directive[E](cd: &@crate_directive, e: &E, v: &vt<E>) {
     }
 }
 
-fn visit_mod[E](m: &_mod, sp: &span, e: &E, v: &vt<E>) {
+fn visit_mod<E>(m: &_mod, sp: &span, e: &E, v: &vt<E>) {
     for vi: @view_item in m.view_items { v.visit_view_item(vi, e, v); }
     for i: @item in m.items { v.visit_item(i, e, v); }
 }
 
-fn visit_view_item[E](vi: &@view_item, e: &E, v: &vt<E>) { }
+fn visit_view_item<E>(vi: &@view_item, e: &E, v: &vt<E>) { }
 
-fn visit_local[E](loc: &@local, e: &E, v: &vt<E>) {
+fn visit_local<E>(loc: &@local, e: &E, v: &vt<E>) {
     v.visit_pat(loc.node.pat, e, v);
     v.visit_ty(loc.node.ty, e, v);
     alt loc.node.init { none. { } some(i) { v.visit_expr(i.expr, e, v); } }
 }
 
-fn visit_item[E](i: &@item, e: &E, v: &vt<E>) {
+fn visit_item<E>(i: &@item, e: &E, v: &vt<E>) {
     alt i.node {
       item_const(t, ex) { v.visit_ty(t, e, v); v.visit_expr(ex, e, v); }
       item_fn(f, tp) { v.visit_fn(f, tp, i.span, some(i.ident), i.id, e, v); }
@@ -111,7 +111,7 @@ fn visit_item[E](i: &@item, e: &E, v: &vt<E>) {
     }
 }
 
-fn visit_ty[E](t: &@ty, e: &E, v: &vt<E>) {
+fn visit_ty<E>(t: &@ty, e: &E, v: &vt<E>) {
     alt t.node {
       ty_nil. {/* no-op */ }
       ty_bot. {/* no-op */ }
@@ -161,12 +161,12 @@ fn visit_ty[E](t: &@ty, e: &E, v: &vt<E>) {
     }
 }
 
-fn visit_constr[E](operator: &path, sp: &span, id: node_id, e: &E,
+fn visit_constr<E>(operator: &path, sp: &span, id: node_id, e: &E,
                    v: &vt<E>) {
     // default
 }
 
-fn visit_pat[E](p: &@pat, e: &E, v: &vt<E>) {
+fn visit_pat<E>(p: &@pat, e: &E, v: &vt<E>) {
     alt p.node {
       pat_tag(path, children) {
         for tp: @ty in path.node.types { v.visit_ty(tp, e, v); }
@@ -183,14 +183,14 @@ fn visit_pat[E](p: &@pat, e: &E, v: &vt<E>) {
     }
 }
 
-fn visit_native_item[E](ni: &@native_item, e: &E, v: &vt<E>) {
+fn visit_native_item<E>(ni: &@native_item, e: &E, v: &vt<E>) {
     alt ni.node {
       native_item_fn(_, fd, _) { visit_fn_decl(fd, e, v); }
       native_item_ty. { }
     }
 }
 
-fn visit_fn_decl[E](fd: &fn_decl, e: &E, v: &vt<E>) {
+fn visit_fn_decl<E>(fd: &fn_decl, e: &E, v: &vt<E>) {
     for a: arg in fd.inputs { v.visit_ty(a.ty, e, v); }
     for c: @constr in fd.constraints {
         v.visit_constr(c.node.path, c.span, c.node.id, e, v);
@@ -198,18 +198,18 @@ fn visit_fn_decl[E](fd: &fn_decl, e: &E, v: &vt<E>) {
     v.visit_ty(fd.output, e, v);
 }
 
-fn visit_fn[E](f: &_fn, tp: &[ty_param], sp: &span, i: &fn_ident, id: node_id,
+fn visit_fn<E>(f: &_fn, tp: &[ty_param], sp: &span, i: &fn_ident, id: node_id,
                e: &E, v: &vt<E>) {
     visit_fn_decl(f.decl, e, v);
     v.visit_block(f.body, e, v);
 }
 
-fn visit_block[E](b: &ast::blk, e: &E, v: &vt<E>) {
+fn visit_block<E>(b: &ast::blk, e: &E, v: &vt<E>) {
     for s: @stmt in b.node.stmts { v.visit_stmt(s, e, v); }
     visit_expr_opt(b.node.expr, e, v);
 }
 
-fn visit_stmt[E](s: &@stmt, e: &E, v: &vt<E>) {
+fn visit_stmt<E>(s: &@stmt, e: &E, v: &vt<E>) {
     alt s.node {
       stmt_decl(d, _) { v.visit_decl(d, e, v); }
       stmt_expr(ex, _) { v.visit_expr(ex, e, v); }
@@ -217,7 +217,7 @@ fn visit_stmt[E](s: &@stmt, e: &E, v: &vt<E>) {
     }
 }
 
-fn visit_decl[E](d: &@decl, e: &E, v: &vt<E>) {
+fn visit_decl<E>(d: &@decl, e: &E, v: &vt<E>) {
     alt d.node {
       decl_local(locs) {
         for loc: @ast::local in locs { v.visit_local(loc, e, v); }
@@ -226,15 +226,15 @@ fn visit_decl[E](d: &@decl, e: &E, v: &vt<E>) {
     }
 }
 
-fn visit_expr_opt[E](eo: option::t<@expr>, e: &E, v: &vt<E>) {
+fn visit_expr_opt<E>(eo: option::t<@expr>, e: &E, v: &vt<E>) {
     alt eo { none. { } some(ex) { v.visit_expr(ex, e, v); } }
 }
 
-fn visit_exprs[E](exprs: &[@expr], e: &E, v: &vt<E>) {
+fn visit_exprs<E>(exprs: &[@expr], e: &E, v: &vt<E>) {
     for ex: @expr in exprs { v.visit_expr(ex, e, v); }
 }
 
-fn visit_mac[E](m: mac, e: &E, v: &vt<E>) {
+fn visit_mac<E>(m: mac, e: &E, v: &vt<E>) {
     alt m.node {
       ast::mac_invoc(pth, arg, body) { visit_expr(arg, e, v); }
       ast::mac_embed_type(ty) { v.visit_ty(ty, e, v); }
@@ -243,7 +243,7 @@ fn visit_mac[E](m: mac, e: &E, v: &vt<E>) {
     }
 }
 
-fn visit_expr[E](ex: &@expr, e: &E, v: &vt<E>) {
+fn visit_expr<E>(ex: &@expr, e: &E, v: &vt<E>) {
     alt ex.node {
       expr_vec(es, _, _) { visit_exprs(es, e, v); }
       expr_rec(flds, base) {
@@ -338,7 +338,7 @@ fn visit_expr[E](ex: &@expr, e: &E, v: &vt<E>) {
     }
 }
 
-fn visit_arm[E](a: &arm, e: &E, v: &vt<E>) {
+fn visit_arm<E>(a: &arm, e: &E, v: &vt<E>) {
     for p: @pat in a.pats { v.visit_pat(p, e, v); }
     v.visit_block(a.body, e, v);
 }