about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2011-07-05 11:48:19 +0200
committerMarijn Haverbeke <marijnh@gmail.com>2011-07-05 15:57:21 +0200
commit6fd6fdea93fca19f168526943c177f942212cbc6 (patch)
tree967778dac7798a33628a4e7992f2d26492e9d71f
parentc59ebf0f018b748011fc9b23ce0bab3dcfcfe733 (diff)
Move everything syntax-related to syntax/, break deps on rest of compiler
src/comp/syntax is currently just a sub-module of rustc, but it will,
in the near future, be its own crate. This includes:

 - The AST data structure
 - The parser
 - The pretty-printer
 - Visit, walk, and fold
 - The syntax extension system
 - Some utility stuff that should be in the stdlib*

*) Stdlib extensions currently require a snapshot before they can be
   used, and the win build is very broken right now. This is temporary
   and will be cleaned up when one of those problems goes away.

A lot of code was moved by this patch, mostly towards a more organized
layout. Some package paths did get longer, and I guess the new layout
will take some getting used to. Sorry about that!

Please try not to re-introduce any dependencies in syntax/ on any of
the other src/comp/ subdirs.
-rw-r--r--src/comp/back/link.rs4
-rw-r--r--src/comp/back/x86.rs2
-rw-r--r--src/comp/driver/rustc.rs61
-rw-r--r--src/comp/driver/session.rs56
-rw-r--r--src/comp/front/attr.rs10
-rw-r--r--src/comp/front/codemap.rs52
-rw-r--r--src/comp/front/config.rs4
-rw-r--r--src/comp/lib/llvm.rs6
-rw-r--r--src/comp/metadata/creader.rs11
-rw-r--r--src/comp/metadata/cwriter.rs2
-rw-r--r--src/comp/metadata/decoder.rs4
-rw-r--r--src/comp/metadata/encoder.rs2
-rw-r--r--src/comp/metadata/tydecode.rs33
-rw-r--r--src/comp/metadata/tyencode.rs28
-rw-r--r--src/comp/middle/alias.rs17
-rw-r--r--src/comp/middle/ast_map.rs3
-rw-r--r--src/comp/middle/resolve.rs23
-rw-r--r--src/comp/middle/trans.rs90
-rw-r--r--src/comp/middle/tstate/ann.rs1
-rw-r--r--src/comp/middle/tstate/annotate.rs11
-rw-r--r--src/comp/middle/tstate/auxiliary.rs32
-rw-r--r--src/comp/middle/tstate/bitvectors.rs3
-rw-r--r--src/comp/middle/tstate/ck.rs45
-rw-r--r--src/comp/middle/tstate/collect_locals.rs27
-rw-r--r--src/comp/middle/tstate/pre_post_conditions.rs12
-rw-r--r--src/comp/middle/tstate/states.rs9
-rw-r--r--src/comp/middle/ty.rs138
-rw-r--r--src/comp/middle/typeck.rs31
-rw-r--r--src/comp/pretty/ppaux.rs433
-rw-r--r--src/comp/rustc.rc47
-rw-r--r--src/comp/syntax/_std.rs29
-rw-r--r--src/comp/syntax/ast.rs (renamed from src/comp/front/ast.rs)41
-rw-r--r--src/comp/syntax/codemap.rs96
-rw-r--r--src/comp/syntax/ext/base.rs (renamed from src/comp/front/ext.rs)34
-rw-r--r--src/comp/syntax/ext/env.rs (renamed from src/comp/front/extenv.rs)9
-rw-r--r--src/comp/syntax/ext/fmt.rs (renamed from src/comp/front/extfmt.rs)44
-rw-r--r--src/comp/syntax/ext/simplext.rs (renamed from src/comp/front/extsimplext.rs)12
-rw-r--r--src/comp/syntax/fold.rs (renamed from src/comp/front/fold.rs)2
-rw-r--r--src/comp/syntax/parse/eval.rs (renamed from src/comp/front/eval.rs)33
-rw-r--r--src/comp/syntax/parse/lexer.rs (renamed from src/comp/front/lexer.rs)61
-rw-r--r--src/comp/syntax/parse/parser.rs (renamed from src/comp/front/parser.rs)149
-rw-r--r--src/comp/syntax/parse/token.rs (renamed from src/comp/front/token.rs)8
-rw-r--r--src/comp/syntax/print/pp.rs (renamed from src/comp/pretty/pp.rs)0
-rw-r--r--src/comp/syntax/print/pprust.rs (renamed from src/comp/pretty/pprust.rs)290
-rw-r--r--src/comp/syntax/util/interner.rs35
-rw-r--r--src/comp/syntax/visit.rs (renamed from src/comp/middle/visit.rs)5
-rw-r--r--src/comp/syntax/walk.rs (renamed from src/comp/middle/walk.rs)8
-rw-r--r--src/comp/util/common.rs139
-rw-r--r--src/comp/util/data.rs39
-rw-r--r--src/comp/util/ppaux.rs182
-rw-r--r--src/lib/int.rs1
-rw-r--r--src/lib/map.rs28
-rw-r--r--src/lib/uint.rs2
-rw-r--r--src/lib/vec.rs13
54 files changed, 1254 insertions, 1203 deletions
diff --git a/src/comp/back/link.rs b/src/comp/back/link.rs
index 562b029dfe8..47168a3dd8c 100644
--- a/src/comp/back/link.rs
+++ b/src/comp/back/link.rs
@@ -13,7 +13,7 @@ import option::none;
 import std::sha1::sha1;
 import std::sort;
 import trans::crate_ctxt;
-import front::ast;
+import syntax::ast;
 import lib::llvm::llvm::ModuleRef;
 import lib::llvm::llvm::ValueRef;
 import lib::llvm::mk_pass_manager;
@@ -436,7 +436,7 @@ fn mangle_exported_name(&@crate_ctxt ccx, &vec[str] path, &ty::t t) -> str {
 
 fn mangle_internal_name_by_type_only(&@crate_ctxt ccx, &ty::t t, &str name) ->
    str {
-    auto s = pretty::ppaux::ty_to_short_str(ccx.tcx, t);
+    auto s = util::ppaux::ty_to_short_str(ccx.tcx, t);
     auto hash = get_symbol_hash(ccx, t);
     ret mangle([name, s, hash]);
 }
diff --git a/src/comp/back/x86.rs b/src/comp/back/x86.rs
index 6a0872734ff..018c99e153a 100644
--- a/src/comp/back/x86.rs
+++ b/src/comp/back/x86.rs
@@ -4,7 +4,7 @@ import lib::llvm::llvm::ModuleRef;
 import std::str;
 import std::vec;
 import std::os::target_os;
-import util::common::istr;
+import syntax::_std::istr;
 
 fn get_module_asm() -> str { ret ""; }
 
diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs
index 10f374d2392..9ad42103a90 100644
--- a/src/comp/driver/rustc.rs
+++ b/src/comp/driver/rustc.rs
@@ -2,19 +2,19 @@
 
 // -*- rust -*-
 import metadata::creader;
-import front::parser;
-import front::token;
-import front::eval;
-import front::ast;
+import syntax::parse::parser;
+import syntax::parse::token;
+import syntax::ast;
+import syntax::codemap;
 import front::attr;
 import middle::trans;
 import middle::resolve;
 import middle::ty;
 import middle::typeck;
 import middle::tstate::ck;
-import pretty::pp;
-import pretty::pprust;
-import pretty::ppaux;
+import syntax::print::pp;
+import syntax::print::pprust;
+import util::ppaux;
 import back::link;
 import lib::llvm;
 import util::common;
@@ -76,12 +76,14 @@ fn parse_cfgspecs(&vec[str] cfgspecs) -> ast::crate_cfg {
     ret vec::map(to_meta_word, cfgspecs);
 }
 
-fn parse_input(session::session sess, parser::parser p, str input) ->
-   @ast::crate {
+fn parse_input(session::session sess, &ast::crate_cfg cfg, str input)
+    -> @ast::crate {
     ret if (str::ends_with(input, ".rc")) {
-            parser::parse_crate_from_crate_file(p)
+            parser::parse_crate_from_crate_file
+                (input, cfg, sess.get_codemap())
         } else if (str::ends_with(input, ".rs")) {
-            parser::parse_crate_from_source_file(p)
+            parser::parse_crate_from_source_file
+                (input, cfg, sess.get_codemap())
         } else { sess.fatal("unknown input file type: " + input); fail };
 }
 
@@ -99,9 +101,8 @@ fn time[T](bool do_it, str what, fn() -> T  thunk) -> T {
 fn compile_input(session::session sess, ast::crate_cfg cfg, str input,
                  str output) {
     auto time_passes = sess.get_opts().time_passes;
-    auto p = parser::new_parser(sess, cfg, input, 0u, 0);
     auto crate =
-        time(time_passes, "parsing", bind parse_input(sess, p, input));
+        time(time_passes, "parsing", bind parse_input(sess, cfg, input));
     if (sess.get_opts().output_type == link::output_type_none) { ret; }
     crate = time(time_passes, "configuration",
                  bind front::config::strip_unconfigured_items(crate));
@@ -129,17 +130,17 @@ fn compile_input(session::session sess, ast::crate_cfg cfg, str input,
 
 fn pretty_print_input(session::session sess, ast::crate_cfg cfg,
                       str input, pp_mode ppm) {
-    fn ann_paren_for_expr(&ppaux::ann_node node) {
+    fn ann_paren_for_expr(&pprust::ann_node node) {
         alt (node) {
-            case (ppaux::node_expr(?s, ?expr)) {
+            case (pprust::node_expr(?s, ?expr)) {
                 pprust::popen(s);
             }
             case (_) {}
         }
     }
-    fn ann_typed_post(&ty::ctxt tcx, &ppaux::ann_node node) {
+    fn ann_typed_post(&ty::ctxt tcx, &pprust::ann_node node) {
         alt (node) {
-            case (ppaux::node_expr(?s, ?expr)) {
+            case (pprust::node_expr(?s, ?expr)) {
                 pp::space(s.s);
                 pp::word(s.s, "as");
                 pp::space(s.s);
@@ -149,18 +150,18 @@ fn pretty_print_input(session::session sess, ast::crate_cfg cfg,
             case (_) {}
         }
     }
-    fn ann_identified_post(&ppaux::ann_node node) {
+    fn ann_identified_post(&pprust::ann_node node) {
         alt (node) {
-            case (ppaux::node_item(?s, ?item)) {
+            case (pprust::node_item(?s, ?item)) {
                 pp::space(s.s);
                 pprust::synth_comment(s, int::to_str(item.id, 10u));
             }
-            case (ppaux::node_block(?s, ?blk)) {
+            case (pprust::node_block(?s, ?blk)) {
                 pp::space(s.s);
                 pprust::synth_comment(s, "block " +
                                       int::to_str(blk.node.id, 10u));
             }
-            case (ppaux::node_expr(?s, ?expr)) {
+            case (pprust::node_expr(?s, ?expr)) {
                 pp::space(s.s);
                 pprust::synth_comment(s, int::to_str(expr.id, 10u));
                 pprust::pclose(s);
@@ -169,8 +170,7 @@ fn pretty_print_input(session::session sess, ast::crate_cfg cfg,
         }
     }
 
-    auto p = front::parser::new_parser(sess, cfg, input, 0u, 0);
-    auto crate = parse_input(sess, p, input);
+    auto crate = parse_input(sess, cfg, input);
     auto ann;
     alt (ppm) {
         case (ppm_typed) {
@@ -186,10 +186,11 @@ fn pretty_print_input(session::session sess, ast::crate_cfg cfg,
                       post=ann_identified_post);
         }
         case (ppm_normal) {
-            ann = ppaux::no_ann();
+            ann = pprust::no_ann();
         }
     }
-    pprust::print_crate(sess, crate, input, std::io::stdout(), ann);
+    pprust::print_crate(sess.get_codemap(), crate, input,
+                        std::io::stdout(), ann);
 }
 
 fn version(str argv0) {
@@ -268,9 +269,9 @@ fn build_target_config() -> @session::config {
     let @session::config target_cfg =
         @rec(os=get_os(triple),
              arch=get_arch(triple),
-             int_type=common::ty_i32,
-             uint_type=common::ty_u32,
-             float_type=common::ty_f64);
+             int_type=ast::ty_i32,
+             uint_type=ast::ty_u32,
+             float_type=ast::ty_f64);
     ret target_cfg;
 }
 
@@ -342,11 +343,11 @@ fn build_session_options(str binary, getopts::match match, str binary_dir) ->
 
 fn build_session(@session::options sopts) -> session::session {
     auto target_cfg = build_target_config();
-    auto crate_cache = common::new_int_hash[session::crate_metadata]();
+    auto crate_cache = syntax::_std::new_int_hash[session::crate_metadata]();
     auto target_crate_num = 0;
     auto sess =
         session::session(target_crate_num, target_cfg, sopts, crate_cache, [],
-                         [], [], front::codemap::new_codemap(), 0u);
+                         [], [], codemap::new_codemap(), 0u);
     ret sess;
 }
 
diff --git a/src/comp/driver/session.rs b/src/comp/driver/session.rs
index 8d296f355ae..8ef558f2fde 100644
--- a/src/comp/driver/session.rs
+++ b/src/comp/driver/session.rs
@@ -1,10 +1,9 @@
 
-import front::ast;
-import front::codemap;
-import util::common::span;
-import util::common::ty_mach;
+import syntax::ast;
+import syntax::codemap;
+import codemap::span;
+import syntax::ast::ty_mach;
 import std::uint;
-import std::term;
 import std::io;
 import std::map;
 import std::option;
@@ -42,30 +41,6 @@ type options =
 
 type crate_metadata = rec(str name, vec[u8] data);
 
-fn span_to_str(span sp, codemap::codemap cm) -> str {
-    auto lo = codemap::lookup_pos(cm, sp.lo);
-    auto hi = codemap::lookup_pos(cm, sp.hi);
-    ret #fmt("%s:%u:%u:%u:%u", lo.filename, lo.line, lo.col, hi.line, hi.col);
-}
-
-fn emit_diagnostic(option::t[span] sp, str msg, str kind, u8 color,
-                   codemap::codemap cm) {
-    auto ss = "<input>:0:0:0:0";
-    alt (sp) {
-        case (some(?ssp)) { ss = span_to_str(ssp, cm); }
-        case (none) { }
-    }
-    io::stdout().write_str(ss + ": ");
-    if (term::color_supported()) {
-        term::fg(io::stdout().get_buf_writer(), color);
-    }
-    io::stdout().write_str(#fmt("%s:", kind));
-    if (term::color_supported()) {
-        term::reset(io::stdout().get_buf_writer());
-    }
-    io::stdout().write_str(#fmt(" %s\n", msg));
-}
-
 obj session(ast::crate_num cnum,
             @config targ_cfg,
             @options opts,
@@ -80,20 +55,19 @@ obj session(ast::crate_num cnum,
     fn get_targ_crate_num() -> ast::crate_num { ret cnum; }
     fn span_fatal(span sp, str msg) -> ! {
         // FIXME: Use constants, but rustboot doesn't know how to export them.
-
-        emit_diagnostic(some(sp), msg, "error", 9u8, cm);
+        codemap::emit_error(some(sp), msg, cm);
         fail;
     }
     fn fatal(str msg) -> ! {
-        emit_diagnostic(none[span], msg, "error", 9u8, cm);
+        codemap::emit_error(none, msg, cm);
         fail;
     }
     fn span_err(span sp, str msg) {
-        emit_diagnostic(some(sp), msg, "error", 9u8, cm);
+        codemap::emit_error(some(sp), msg, cm);
         err_count += 1u;
     }
     fn err(str msg) {
-        emit_diagnostic(none, msg, "error", 9u8, cm);
+        codemap::emit_error(none, msg, cm);
         err_count += 1u;
     }
     fn abort_if_errors() {
@@ -103,19 +77,17 @@ obj session(ast::crate_num cnum,
     }
     fn span_warn(span sp, str msg) {
         // FIXME: Use constants, but rustboot doesn't know how to export them.
-
-        emit_diagnostic(some(sp), msg, "warning", 11u8, cm);
+        codemap::emit_warning(some(sp), msg, cm);
     }
     fn warn(str msg) {
-        emit_diagnostic(none[span], msg, "warning", 11u8, cm);
+        codemap::emit_warning(none, msg, cm);
     }
     fn span_note(span sp, str msg) {
         // FIXME: Use constants, but rustboot doesn't know how to export them.
-
-        emit_diagnostic(some(sp), msg, "note", 10u8, cm);
+        codemap::emit_note(some(sp), msg, cm);
     }
     fn note(str msg) {
-        emit_diagnostic(none, msg, "note", 10u8, cm);
+        codemap::emit_note(none, msg, cm);
     }
     fn span_bug(span sp, str msg) -> ! {
         self.span_fatal(sp, #fmt("internal compiler error %s", msg));
@@ -172,7 +144,9 @@ obj session(ast::crate_num cnum,
     fn lookup_pos(uint pos) -> codemap::loc {
         ret codemap::lookup_pos(cm, pos);
     }
-    fn span_str(span sp) -> str { ret span_to_str(sp, self.get_codemap()); }
+    fn span_str(span sp) -> str {
+        ret codemap::span_to_str(sp, self.get_codemap());
+    }
 }
 // Local Variables:
 // fill-column: 78;
diff --git a/src/comp/front/attr.rs b/src/comp/front/attr.rs
index 1312851c5f0..00e64e33f6b 100644
--- a/src/comp/front/attr.rs
+++ b/src/comp/front/attr.rs
@@ -2,7 +2,7 @@
 
 import std::vec;
 import std::option;
-import front::ast;
+import syntax::ast;
 import util::common;
 
 export attr_metas;
@@ -105,9 +105,11 @@ fn eq(@ast::meta_item a, @ast::meta_item b) -> bool {
 }
 
 fn contains(&vec[@ast::meta_item] haystack, @ast::meta_item needle) -> bool {
-    log #fmt("looking for %s", pretty::pprust::meta_item_to_str(*needle));
+    log #fmt("looking for %s",
+             syntax::print::pprust::meta_item_to_str(*needle));
     for (@ast::meta_item item in haystack) {
-        log #fmt("looking in %s", pretty::pprust::meta_item_to_str(*item));
+        log #fmt("looking in %s",
+                 syntax::print::pprust::meta_item_to_str(*item));
         if (eq(item, needle)) {
             log "found it!";
             ret true;
@@ -166,7 +168,7 @@ fn remove_meta_items_by_name(&vec[@ast::meta_item] items,
     ret vec::filter_map(filter, items);
 }
 
-fn span[T](&T item) -> common::spanned[T] {
+fn span[T](&T item) -> ast::spanned[T] {
     ret rec(node=item, span=rec(lo=0u, hi=0u));
 }
 
diff --git a/src/comp/front/codemap.rs b/src/comp/front/codemap.rs
deleted file mode 100644
index 3e1aa3c5940..00000000000
--- a/src/comp/front/codemap.rs
+++ /dev/null
@@ -1,52 +0,0 @@
-
-import std::vec;
-
-
-/* A codemap is a thing that maps uints to file/line/column positions
- * in a crate. This to make it possible to represent the positions
- * with single-word things, rather than passing records all over the
- * compiler.
- */
-type filemap = @rec(str name, uint start_pos, mutable vec[uint] lines);
-
-type codemap = @rec(mutable vec[filemap] files);
-
-type loc = rec(str filename, uint line, uint col);
-
-fn new_codemap() -> codemap {
-    let vec[filemap] files = [];
-    ret @rec(mutable files=files);
-}
-
-fn new_filemap(str filename, uint start_pos) -> filemap {
-    ret @rec(name=filename, start_pos=start_pos, mutable lines=[0u]);
-}
-
-fn next_line(filemap file, uint pos) { vec::push[uint](file.lines, pos); }
-
-fn lookup_pos(codemap map, uint pos) -> loc {
-    auto a = 0u;
-    auto b = vec::len[filemap](map.files);
-    while (b - a > 1u) {
-        auto m = (a + b) / 2u;
-        if (map.files.(m).start_pos > pos) { b = m; } else { a = m; }
-    }
-    auto f = map.files.(a);
-    a = 0u;
-    b = vec::len[uint](f.lines);
-    while (b - a > 1u) {
-        auto m = (a + b) / 2u;
-        if (f.lines.(m) > pos) { b = m; } else { a = m; }
-    }
-    ret rec(filename=f.name, line=a + 1u, col=pos - f.lines.(a));
-}
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
-// End:
-//
diff --git a/src/comp/front/config.rs b/src/comp/front/config.rs
index bbfc9001572..63646ffca69 100644
--- a/src/comp/front/config.rs
+++ b/src/comp/front/config.rs
@@ -1,7 +1,7 @@
 import std::option;
 import std::vec;
-import ast;
-import fold;
+import syntax::ast;
+import syntax::fold;
 import attr;
 
 export strip_unconfigured_items;
diff --git a/src/comp/lib/llvm.rs b/src/comp/lib/llvm.rs
index 1cbd4c0a98c..8a9c5aa5857 100644
--- a/src/comp/lib/llvm.rs
+++ b/src/comp/lib/llvm.rs
@@ -1457,7 +1457,7 @@ state obj type_names(std::map::hashmap[TypeRef, str] type_names,
 }
 
 fn mk_type_names() -> type_names {
-    auto nt = util::common::new_str_hash[TypeRef]();
+    auto nt = syntax::_std::new_str_hash[TypeRef]();
 
     fn hash(&TypeRef t) -> uint {
         ret t as uint;
@@ -1519,7 +1519,7 @@ fn type_to_str_inner(type_names names,
         case (6) { ret "Label"; }
 
         case (7) {
-            ret "i" + util::common::istr(llvm::LLVMGetIntTypeWidth(ty)
+            ret "i" + syntax::_std::istr(llvm::LLVMGetIntTypeWidth(ty)
                                          as int);
         }
 
@@ -1558,7 +1558,7 @@ fn type_to_str_inner(type_names names,
                 i += 1u;
                 if (tout as int == ty as int) {
                     let uint n = vec::len[TypeRef](outer0) - i;
-                    ret "*\\" + util::common::istr(n as int);
+                    ret "*\\" + syntax::_std::istr(n as int);
                 }
             }
             ret "*" + type_to_str_inner(names, outer,
diff --git a/src/comp/metadata/creader.rs b/src/comp/metadata/creader.rs
index 5e9cf52a282..5ef08cfd02d 100644
--- a/src/comp/metadata/creader.rs
+++ b/src/comp/metadata/creader.rs
@@ -1,14 +1,15 @@
 // Extracting metadata from crate files
 
 import driver::session;
-import front::ast;
+import syntax::ast;
 import lib::llvm::False;
 import lib::llvm::llvm;
 import lib::llvm::mk_object_file;
 import lib::llvm::mk_section_iter;
 import front::attr;
 import middle::resolve;
-import middle::walk;
+import syntax::walk;
+import syntax::codemap::span;
 import back::x86;
 import util::common;
 import std::str;
@@ -20,7 +21,7 @@ import std::option;
 import std::option::none;
 import std::option::some;
 import std::map::hashmap;
-import pretty::pprust;
+import syntax::print::pprust;
 import tags::*;
 
 export read_crates;
@@ -129,7 +130,7 @@ fn get_metadata_section(str filename) -> option::t[vec[u8]] {
     ret option::none[vec[u8]];
 }
 
-fn load_library_crate(&session::session sess, common::span span, int cnum,
+fn load_library_crate(&session::session sess, span span, int cnum,
                       &ast::ident ident, vec[@ast::meta_item] metas,
                       &vec[str] library_search_paths) {
     alt (find_library_crate(sess, ident, metas, library_search_paths)) {
@@ -202,7 +203,7 @@ fn read_crates(session::session sess, resolve::crate_map crate_map,
     auto e =
         @rec(sess=sess,
              crate_map=crate_map,
-             crate_cache=@common::new_str_hash[int](),
+             crate_cache=@syntax::_std::new_str_hash[int](),
              library_search_paths=sess.get_opts().library_search_paths,
              mutable next_crate_num=1);
     auto v =
diff --git a/src/comp/metadata/cwriter.rs b/src/comp/metadata/cwriter.rs
index 9956a46c828..3c1875d07d4 100644
--- a/src/comp/metadata/cwriter.rs
+++ b/src/comp/metadata/cwriter.rs
@@ -2,7 +2,7 @@
 
 import std::str;
 import middle::trans;
-import front::ast::crate;
+import syntax::ast::crate;
 import back::x86;
 import lib::llvm::llvm;
 import lib::llvm::llvm::ValueRef;
diff --git a/src/comp/metadata/decoder.rs b/src/comp/metadata/decoder.rs
index 0eda4bbf5af..14d4035185f 100644
--- a/src/comp/metadata/decoder.rs
+++ b/src/comp/metadata/decoder.rs
@@ -6,7 +6,7 @@ import std::vec;
 import std::str;
 import std::io;
 import std::map::hashmap;
-import front::ast;
+import syntax::ast;
 import front::attr;
 import middle::ty;
 import tags::*;
@@ -14,7 +14,7 @@ import tydecode::parse_def_id;
 import tydecode::parse_ty_data;
 import driver::session;
 import util::common;
-import pretty::pprust;
+import syntax::print::pprust;
 
 export get_symbol;
 export get_tag_variants;
diff --git a/src/comp/metadata/encoder.rs b/src/comp/metadata/encoder.rs
index c867f483dd3..4526e515f79 100644
--- a/src/comp/metadata/encoder.rs
+++ b/src/comp/metadata/encoder.rs
@@ -8,7 +8,7 @@ import std::option;
 import std::option::some;
 import std::option::none;
 import std::ebml;
-import front::ast::*;
+import syntax::ast::*;
 import tags::*;
 import middle::trans::crate_ctxt;
 import middle::trans::node_id_type;
diff --git a/src/comp/metadata/tydecode.rs b/src/comp/metadata/tydecode.rs
index d0ef42f4d14..b40a84ec305 100644
--- a/src/comp/metadata/tydecode.rs
+++ b/src/comp/metadata/tydecode.rs
@@ -6,12 +6,9 @@ import std::uint;
 import std::option;
 import std::option::none;
 import std::option::some;
-import front::ast;
+import syntax::ast;
+import ast::respan;
 import middle::ty;
-import util::common;
-import util::common::respan;
-import util::common::a_ty;
-import util::common::a_bang;
 
 export parse_def_id;
 export parse_ty_data;
@@ -26,7 +23,7 @@ type str_def = fn(str) -> ast::def_id ;
 type pstate =
     rec(vec[u8] data, int crate, mutable uint pos, uint len, ty::ctxt tcx);
 
-type ty_or_bang = util::common::ty_or_bang[ty::t];
+tag ty_or_bang { a_ty(ty::t); a_bang; }
 
 fn peek(@pstate st) -> u8 { ret st.data.(st.pos); }
 
@@ -63,8 +60,8 @@ fn parse_ty_data(vec[u8] data, int crate_num, uint pos, uint len, str_def sd,
 
 fn parse_ty_or_bang(@pstate st, str_def sd) -> ty_or_bang {
     alt (peek(st) as char) {
-        case ('!') { next(st); ret a_bang[ty::t]; }
-        case (_) { ret a_ty[ty::t](parse_ty(st, sd)); }
+        case ('!') { next(st); ret a_bang; }
+        case (_) { ret a_ty(parse_ty(st, sd)); }
     }
 }
 
@@ -154,16 +151,16 @@ fn parse_ty(@pstate st, str_def sd) -> ty::t {
         case ('l') { ret ty::mk_float(st.tcx); }
         case ('M') {
             alt (next(st) as char) {
-                case ('b') { ret ty::mk_mach(st.tcx, common::ty_u8); }
-                case ('w') { ret ty::mk_mach(st.tcx, common::ty_u16); }
-                case ('l') { ret ty::mk_mach(st.tcx, common::ty_u32); }
-                case ('d') { ret ty::mk_mach(st.tcx, common::ty_u64); }
-                case ('B') { ret ty::mk_mach(st.tcx, common::ty_i8); }
-                case ('W') { ret ty::mk_mach(st.tcx, common::ty_i16); }
-                case ('L') { ret ty::mk_mach(st.tcx, common::ty_i32); }
-                case ('D') { ret ty::mk_mach(st.tcx, common::ty_i64); }
-                case ('f') { ret ty::mk_mach(st.tcx, common::ty_f32); }
-                case ('F') { ret ty::mk_mach(st.tcx, common::ty_f64); }
+                case ('b') { ret ty::mk_mach(st.tcx, ast::ty_u8); }
+                case ('w') { ret ty::mk_mach(st.tcx, ast::ty_u16); }
+                case ('l') { ret ty::mk_mach(st.tcx, ast::ty_u32); }
+                case ('d') { ret ty::mk_mach(st.tcx, ast::ty_u64); }
+                case ('B') { ret ty::mk_mach(st.tcx, ast::ty_i8); }
+                case ('W') { ret ty::mk_mach(st.tcx, ast::ty_i16); }
+                case ('L') { ret ty::mk_mach(st.tcx, ast::ty_i32); }
+                case ('D') { ret ty::mk_mach(st.tcx, ast::ty_i64); }
+                case ('f') { ret ty::mk_mach(st.tcx, ast::ty_f32); }
+                case ('F') { ret ty::mk_mach(st.tcx, ast::ty_f64); }
             }
         }
         case ('c') { ret ty::mk_char(st.tcx); }
diff --git a/src/comp/metadata/tyencode.rs b/src/comp/metadata/tyencode.rs
index a9090c3624c..af7f3f67118 100644
--- a/src/comp/metadata/tyencode.rs
+++ b/src/comp/metadata/tyencode.rs
@@ -5,9 +5,9 @@ import std::map::hashmap;
 import std::option::some;
 import std::option::none;
 import std::uint;
-import front::ast::*;
+import syntax::ast::*;
 import middle::ty;
-import pretty::ppaux::lit_to_str;
+import syntax::print::pprust::lit_to_str;
 import util::common;
 
 export ctxt;
@@ -105,16 +105,16 @@ fn enc_sty(&io::writer w, &@ctxt cx, &ty::sty st) {
         case (ty::ty_float) { w.write_char('l'); }
         case (ty::ty_machine(?mach)) {
             alt (mach) {
-                case (common::ty_u8) { w.write_str("Mb"); }
-                case (common::ty_u16) { w.write_str("Mw"); }
-                case (common::ty_u32) { w.write_str("Ml"); }
-                case (common::ty_u64) { w.write_str("Md"); }
-                case (common::ty_i8) { w.write_str("MB"); }
-                case (common::ty_i16) { w.write_str("MW"); }
-                case (common::ty_i32) { w.write_str("ML"); }
-                case (common::ty_i64) { w.write_str("MD"); }
-                case (common::ty_f32) { w.write_str("Mf"); }
-                case (common::ty_f64) { w.write_str("MF"); }
+                case (ty_u8) { w.write_str("Mb"); }
+                case (ty_u16) { w.write_str("Mw"); }
+                case (ty_u32) { w.write_str("Ml"); }
+                case (ty_u64) { w.write_str("Md"); }
+                case (ty_i8) { w.write_str("MB"); }
+                case (ty_i16) { w.write_str("MW"); }
+                case (ty_i32) { w.write_str("ML"); }
+                case (ty_i64) { w.write_str("MD"); }
+                case (ty_f32) { w.write_str("Mf"); }
+                case (ty_f64) { w.write_str("MF"); }
             }
         }
         case (ty::ty_char) { w.write_char('c'); }
@@ -182,7 +182,7 @@ fn enc_sty(&io::writer w, &@ctxt cx, &ty::sty st) {
         }
         case (ty::ty_var(?id)) {
             w.write_char('X');
-            w.write_str(common::istr(id));
+            w.write_str(syntax::_std::istr(id));
         }
         case (ty::ty_native(?def)) {
             w.write_char('E');
@@ -191,7 +191,7 @@ fn enc_sty(&io::writer w, &@ctxt cx, &ty::sty st) {
         }
         case (ty::ty_param(?id)) {
             w.write_char('p');
-            w.write_str(common::uistr(id));
+            w.write_str(syntax::_std::uistr(id));
         }
         case (ty::ty_type) { w.write_char('Y'); }
         case (ty::ty_task) { w.write_char('a'); }
diff --git a/src/comp/middle/alias.rs b/src/comp/middle/alias.rs
index 3c482cc252e..e419426c969 100644
--- a/src/comp/middle/alias.rs
+++ b/src/comp/middle/alias.rs
@@ -1,10 +1,11 @@
 
-import front::ast;
-import front::ast::ident;
-import front::ast::fn_ident;
-import front::ast::node_id;
-import front::ast::def_id;
-import util::common::span;
+import syntax::ast;
+import ast::ident;
+import ast::fn_ident;
+import ast::node_id;
+import ast::def_id;
+import syntax::codemap::span;
+import syntax::visit;
 import visit::vt;
 import std::vec;
 import std::str;
@@ -44,7 +45,7 @@ fn check_crate(@ty::ctxt tcx, &@ast::crate crate) {
 
              // Stores information about object fields and function
              // arguments that's otherwise not easily available.
-             local_map=util::common::new_int_hash());
+             local_map=syntax::_std::new_int_hash());
     auto v =
         @rec(visit_fn=bind visit_fn(cx, _, _, _, _, _, _, _),
              visit_item=bind visit_item(cx, _, _, _),
@@ -348,7 +349,7 @@ fn check_for(&ctx cx, &@ast::local local, &@ast::expr seq, &ast::block block,
         case (ty::ty_istr) { /* no-op */ }
         case (_) {
             cx.tcx.sess.span_unimpl(seq.span, "unknown seq type " +
-                                    pretty::ppaux::ty_to_str(*cx.tcx, seq_t));
+                                    util::ppaux::ty_to_str(*cx.tcx, seq_t));
         }
     }
     auto new_sc =
diff --git a/src/comp/middle/ast_map.rs b/src/comp/middle/ast_map.rs
index eeee4149345..9b19e6a9970 100644
--- a/src/comp/middle/ast_map.rs
+++ b/src/comp/middle/ast_map.rs
@@ -1,6 +1,7 @@
 import std::smallintmap;
 import std::option;
-import front::ast::*;
+import syntax::ast::*;
+import syntax::visit;
 import visit::vt;
 
 tag ast_node {
diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs
index 0fdf9219246..2e3ed812900 100644
--- a/src/comp/middle/resolve.rs
+++ b/src/comp/middle/resolve.rs
@@ -1,21 +1,22 @@
 
-import front::ast;
-import front::ast::ident;
-import front::ast::fn_ident;
-import front::ast::def;
-import front::ast::def_id;
-import front::ast::node_id;
-import front::ast::local_def;
+import syntax::ast;
+import ast::ident;
+import ast::fn_ident;
+import ast::def;
+import ast::def_id;
+import ast::node_id;
+import ast::local_def;
 
 import metadata::creader;
 import metadata::decoder;
 import driver::session::session;
 import util::common::new_def_hash;
-import util::common::new_int_hash;
-import util::common::new_str_hash;
-import util::common::span;
-import util::common::respan;
+import syntax::_std::new_int_hash;
+import syntax::_std::new_str_hash;
+import syntax::codemap::span;
+import syntax::ast::respan;
 import middle::ty::constr_table;
+import syntax::visit;
 import visit::vt;
 import std::map::hashmap;
 import std::list;
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index d05f65d5fd7..f2c00abd6f1 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -24,7 +24,8 @@ import std::option;
 import std::option::some;
 import std::option::none;
 import std::fs;
-import front::ast;
+import syntax::ast;
+import syntax::walk;
 import driver::session;
 import middle::ty;
 import back::link;
@@ -32,14 +33,15 @@ import back::x86;
 import back::abi;
 import back::upcall;
 import middle::ty::pat_ty;
+import syntax::visit;
 import visit::vt;
 import util::common;
-import util::common::istr;
+import syntax::_std::istr;
 import util::common::new_def_hash;
-import util::common::new_int_hash;
-import util::common::new_str_hash;
+import syntax::_std::new_int_hash;
+import syntax::_std::new_str_hash;
 import util::common::local_rhs_span;
-import util::common::span;
+import syntax::codemap::span;
 import lib::llvm::llvm;
 import lib::llvm::builder;
 import lib::llvm::target_data;
@@ -65,10 +67,10 @@ import link::mangle_exported_name;
 import metadata::tyencode;
 import metadata::creader;
 import metadata::decoder;
-import pretty::ppaux::ty_to_str;
-import pretty::ppaux::ty_to_short_str;
-import pretty::pprust::expr_to_str;
-import pretty::pprust::path_to_str;
+import util::ppaux::ty_to_str;
+import util::ppaux::ty_to_short_str;
+import syntax::print::pprust::expr_to_str;
+import syntax::print::pprust::path_to_str;
 
 obj namegen(mutable int i) {
     fn next(str prefix) -> str { i += 1; ret prefix + istr(i); }
@@ -795,16 +797,16 @@ fn type_of_inner(&@crate_ctxt cx, &span sp, &ty::t t) -> TypeRef {
         case (ty::ty_uint) { llty = T_int(); }
         case (ty::ty_machine(?tm)) {
             alt (tm) {
-                case (common::ty_i8) { llty = T_i8(); }
-                case (common::ty_u8) { llty = T_i8(); }
-                case (common::ty_i16) { llty = T_i16(); }
-                case (common::ty_u16) { llty = T_i16(); }
-                case (common::ty_i32) { llty = T_i32(); }
-                case (common::ty_u32) { llty = T_i32(); }
-                case (common::ty_i64) { llty = T_i64(); }
-                case (common::ty_u64) { llty = T_i64(); }
-                case (common::ty_f32) { llty = T_f32(); }
-                case (common::ty_f64) { llty = T_f64(); }
+                case (ast::ty_i8) { llty = T_i8(); }
+                case (ast::ty_u8) { llty = T_i8(); }
+                case (ast::ty_i16) { llty = T_i16(); }
+                case (ast::ty_u16) { llty = T_i16(); }
+                case (ast::ty_i32) { llty = T_i32(); }
+                case (ast::ty_u32) { llty = T_i32(); }
+                case (ast::ty_i64) { llty = T_i64(); }
+                case (ast::ty_u64) { llty = T_i64(); }
+                case (ast::ty_f32) { llty = T_f32(); }
+                case (ast::ty_f64) { llty = T_f64(); }
             }
         }
         case (ty::ty_char) { llty = T_char(); }
@@ -2363,7 +2365,7 @@ fn make_cmp_glue(&@block_ctxt cx, ValueRef lhs0, ValueRef rhs0, &ty::t t,
     } else {
         // FIXME: compare obj, fn by pointer?
 
-        trans_fail(cx, none[common::span],
+        trans_fail(cx, none[span],
                    "attempt to compare values of type " +
                        ty_to_str(cx.fcx.lcx.ccx.tcx, t));
     }
@@ -2402,7 +2404,7 @@ fn compare_scalar_types(@block_ctxt cx, ValueRef lhs, ValueRef rhs, &ty::t t,
         }
         case (ty::ty_char) { ret f(unsigned_int); }
         case (ty::ty_type) {
-            trans_fail(cx, none[common::span],
+            trans_fail(cx, none[span],
                        "attempt to compare values of type type");
 
             // This is a bit lame, because we return a dummy block to the
@@ -2412,7 +2414,7 @@ fn compare_scalar_types(@block_ctxt cx, ValueRef lhs, ValueRef rhs, &ty::t t,
                      C_bool(false));
         }
         case (ty::ty_native(_)) {
-            trans_fail(cx, none[common::span],
+            trans_fail(cx, none[span],
                        "attempt to compare values of type native");
             ret rslt(new_sub_block_ctxt(cx, "after_fail_dummy"),
                      C_bool(false));
@@ -2752,7 +2754,7 @@ fn iter_structural_ty_full(&@block_ctxt cx, ValueRef av, ValueRef bv,
             ret iter_ivec(cx, av, bv, unit_tm.ty, f);
         }
         case (ty::ty_istr) {
-            auto unit_ty = ty::mk_mach(cx.fcx.lcx.ccx.tcx, common::ty_u8);
+            auto unit_ty = ty::mk_mach(cx.fcx.lcx.ccx.tcx, ast::ty_u8);
             ret iter_ivec(cx, av, bv, unit_ty, f);
         }
         case (_) {
@@ -2858,14 +2860,14 @@ fn iter_sequence(@block_ctxt cx, ValueRef v, &ty::t t, &val_and_ty_fn f) ->
             ret iter_sequence_body(cx, v, elt.ty, f, false, false);
         }
         case (ty::ty_str) {
-            auto et = ty::mk_mach(cx.fcx.lcx.ccx.tcx, common::ty_u8);
+            auto et = ty::mk_mach(cx.fcx.lcx.ccx.tcx, ast::ty_u8);
             ret iter_sequence_body(cx, v, et, f, true, false);
         }
         case (ty::ty_ivec(?elt)) {
             ret iter_sequence_body(cx, v, elt.ty, f, false, true);
         }
         case (ty::ty_istr) {
-            auto et = ty::mk_mach(cx.fcx.lcx.ccx.tcx, common::ty_u8);
+            auto et = ty::mk_mach(cx.fcx.lcx.ccx.tcx, ast::ty_u8);
             ret iter_sequence_body(cx, v, et, f, true, true);
         }
         case (_) {
@@ -3179,7 +3181,7 @@ fn duplicate_heap_parts_if_necessary(&@block_ctxt cx, ValueRef vptr,
       }
       case (ty::ty_istr) {
         ret ivec::duplicate_heap_part(cx, vptr,
-            ty::mk_mach(cx.fcx.lcx.ccx.tcx, common::ty_u8));
+            ty::mk_mach(cx.fcx.lcx.ccx.tcx, ast::ty_u8));
       }
       case (_) { ret rslt(cx, C_nil()); }
     }
@@ -3276,14 +3278,14 @@ fn trans_lit(&@crate_ctxt cx, &ast::lit lit, ast::node_id id) -> ValueRef {
             auto t = T_int();
             auto s = True;
             alt (tm) {
-                case (common::ty_u8) { t = T_i8(); s = False; }
-                case (common::ty_u16) { t = T_i16(); s = False; }
-                case (common::ty_u32) { t = T_i32(); s = False; }
-                case (common::ty_u64) { t = T_i64(); s = False; }
-                case (common::ty_i8) { t = T_i8(); }
-                case (common::ty_i16) { t = T_i16(); }
-                case (common::ty_i32) { t = T_i32(); }
-                case (common::ty_i64) { t = T_i64(); }
+                case (ast::ty_u8) { t = T_i8(); s = False; }
+                case (ast::ty_u16) { t = T_i16(); s = False; }
+                case (ast::ty_u32) { t = T_i32(); s = False; }
+                case (ast::ty_u64) { t = T_i64(); s = False; }
+                case (ast::ty_i8) { t = T_i8(); }
+                case (ast::ty_i16) { t = T_i16(); }
+                case (ast::ty_i32) { t = T_i32(); }
+                case (ast::ty_i64) { t = T_i64(); }
             }
             ret C_integral(t, i as uint, s);
         }
@@ -3291,8 +3293,8 @@ fn trans_lit(&@crate_ctxt cx, &ast::lit lit, ast::node_id id) -> ValueRef {
         case (ast::lit_mach_float(?tm, ?s)) {
             auto t = T_float();
             alt (tm) {
-                case (common::ty_f32) { t = T_f32(); }
-                case (common::ty_f64) { t = T_f64(); }
+                case (ast::ty_f32) { t = T_f32(); }
+                case (ast::ty_f64) { t = T_f64(); }
             }
             ret C_floating(s, t);
         }
@@ -4768,7 +4770,7 @@ fn trans_alt(&@block_ctxt cx, &@ast::expr expr, &vec[ast::arm] arms,
         this_cx = next_cx;
     }
     auto default_cx = this_cx;
-    trans_fail(default_cx, some[common::span](expr.span),
+    trans_fail(default_cx, some[span](expr.span),
                "non-exhaustive match failure");
     ret rslt(join_branches(cx, arm_results), C_nil());
 }
@@ -5028,7 +5030,7 @@ fn trans_index(&@block_ctxt cx, &span sp, &@ast::expr base, &@ast::expr idx,
     bcx.build.CondBr(bounds_check, next_cx.llbb, fail_cx.llbb);
     // fail: bad bounds check.
 
-    trans_fail(fail_cx, some[common::span](sp), "bounds check");
+    trans_fail(fail_cx, some[span](sp), "bounds check");
     auto body;
     alt (interior_len_and_data) {
         case (some(?lad)) { body = lad._1; }
@@ -6313,11 +6315,11 @@ fn trans_log(int lvl, &@block_ctxt cx, &@ast::expr e) -> result {
         let TypeRef tr;
         let bool is32bit = false;
         alt (ty::struct(cx.fcx.lcx.ccx.tcx, e_ty)) {
-            case (ty::ty_machine(util::common::ty_f32)) {
+            case (ty::ty_machine(ast::ty_f32)) {
                 tr = T_f32();
                 is32bit = true;
             }
-            case (ty::ty_machine(util::common::ty_f64)) { tr = T_f64(); }
+            case (ty::ty_machine(ast::ty_f64)) { tr = T_f64(); }
             case (_) { tr = T_float(); }
         }
         if (is32bit) {
@@ -6366,13 +6368,13 @@ fn trans_check_expr(&@block_ctxt cx, &@ast::expr e, &str s) -> result {
     auto cond_res = trans_expr(cx, e);
     auto expr_str = s + " " + expr_to_str(e) + " failed";
     auto fail_cx = new_sub_block_ctxt(cx, "fail");
-    trans_fail(fail_cx, some[common::span](e.span), expr_str);
+    trans_fail(fail_cx, some[span](e.span), expr_str);
     auto next_cx = new_sub_block_ctxt(cx, "next");
     cond_res.bcx.build.CondBr(cond_res.val, next_cx.llbb, fail_cx.llbb);
     ret rslt(next_cx, C_nil());
 }
 
-fn trans_fail_expr(&@block_ctxt cx, &option::t[common::span] sp_opt,
+fn trans_fail_expr(&@block_ctxt cx, &option::t[span] sp_opt,
                    &option::t[@ast::expr] fail_expr)
         -> result {
     auto bcx = cx;
@@ -6399,13 +6401,13 @@ fn trans_fail_expr(&@block_ctxt cx, &option::t[common::span] sp_opt,
     }
 }
  
-fn trans_fail(&@block_ctxt cx, &option::t[common::span] sp_opt, &str fail_str)
+fn trans_fail(&@block_ctxt cx, &option::t[span] sp_opt, &str fail_str)
    -> result {
     auto V_fail_str = C_cstr(cx.fcx.lcx.ccx, fail_str);
     ret trans_fail_value(cx, sp_opt, V_fail_str);
 }
 
-fn trans_fail_value(&@block_ctxt cx, &option::t[common::span] sp_opt,
+fn trans_fail_value(&@block_ctxt cx, &option::t[span] sp_opt,
                     &ValueRef V_fail_str)
         -> result {
     auto V_filename;
diff --git a/src/comp/middle/tstate/ann.rs b/src/comp/middle/tstate/ann.rs
index 882dc4a42f7..aa9267656e4 100644
--- a/src/comp/middle/tstate/ann.rs
+++ b/src/comp/middle/tstate/ann.rs
@@ -1,5 +1,4 @@
 
-import front::ast::ident;
 import std::vec;
 import tritv::*;
 
diff --git a/src/comp/middle/tstate/annotate.rs b/src/comp/middle/tstate/annotate.rs
index 3ed1a56928a..abffc3a97e3 100644
--- a/src/comp/middle/tstate/annotate.rs
+++ b/src/comp/middle/tstate/annotate.rs
@@ -3,11 +3,12 @@ import std::vec;
 import std::option;
 import std::option::some;
 import std::option::none;
-import front::ast::*;
-import util::common::istr;
-import util::common::uistr;
-import util::common::span;
-import util::common::new_str_hash;
+import syntax::ast::*;
+import syntax::walk;
+import syntax::codemap::span;
+import syntax::_std::istr;
+import syntax::_std::uistr;
+import syntax::_std::new_str_hash;
 import util::common::log_expr_err;
 import util::common::log_block_err;
 import util::common::log_item_err;
diff --git a/src/comp/middle/tstate/auxiliary.rs b/src/comp/middle/tstate/auxiliary.rs
index 9aa529c4e41..123f51e7a70 100644
--- a/src/comp/middle/tstate/auxiliary.rs
+++ b/src/comp/middle/tstate/auxiliary.rs
@@ -7,20 +7,17 @@ import std::option;
 import std::option::none;
 import std::option::some;
 import std::option::maybe;
-import front::ast;
-import front::ast::*;
+import syntax::ast::*;
+import syntax::codemap::span;
 import util::common;
-import util::common::span;
-import util::common::spanned;
-import util::common::respan;
 import util::common::log_block;
-import util::common::new_int_hash;
-import util::common::new_uint_hash;
+import syntax::_std::new_int_hash;
+import syntax::_std::new_uint_hash;
 import util::common::log_expr_err;
-import util::common::istr;
-import util::common::uistr;
+import syntax::_std::istr;
+import syntax::_std::uistr;
 import util::common::lit_eq;
-import pretty::pprust::path_to_str;
+import syntax::print::pprust::path_to_str;
 import tstate::ann::pre_and_post;
 import tstate::ann::pre_and_post_state;
 import tstate::ann::empty_ann;
@@ -42,8 +39,8 @@ import tstate::ann::clear_in_poststate;
 import tstate::ann::clear_in_poststate_;
 import tritv::*;
 
-import pretty::ppaux::constr_args_to_str;
-import pretty::ppaux::lit_to_str;
+import syntax::print::pprust::constr_args_to_str;
+import syntax::print::pprust::lit_to_str;
 
 
 /* logging funs */
@@ -188,10 +185,10 @@ same predicate are collapsed into one entry in the table, makes it
 easier to look up a specific instance.
 
 Both types are in constrast with the constraint type defined in
-front::ast, which is for predicate constraints only, and is what
+syntax::ast, which is for predicate constraints only, and is what
 gets generated by the parser. aux and ast share the same type
 to represent predicate *arguments* however. This type
-(constr_arg_general) is parameterized (see comments in front::ast).
+(constr_arg_general) is parameterized (see comments in syntax::ast).
 
 Both types store an ident and span, for error-logging purposes.
 */
@@ -507,7 +504,7 @@ fn constraints(&fn_ctxt fcx) -> vec[norm_constraint] {
 fn match_args(&fn_ctxt fcx, vec[pred_desc] occs, vec[@constr_arg_use] occ) ->
    uint {
     log "match_args: looking at " +
-        pretty::ppaux::constr_args_to_str(std::util::fst[ident, def_id], occ);
+        constr_args_to_str(std::util::fst[ident, def_id], occ);
     for (pred_desc pd in occs) {
         log "match_args: candidate " + pred_desc_to_str(pd);
         fn eq(&tup(ident, def_id) p, &tup(ident, def_id) q) -> bool {
@@ -594,8 +591,7 @@ fn expr_to_constr(ty::ctxt tcx, &@expr e) -> constr {
 
 fn pred_desc_to_str(&pred_desc p) -> str {
     ret "<" + uistr(p.node.bit_num) + ", " +
-        pretty::ppaux::constr_args_to_str(std::util::fst[ident, def_id],
-                                          p.node.args) + ">";
+        constr_args_to_str(std::util::fst[ident, def_id], p.node.args) + ">";
 }
 
 fn substitute_constr_args(&ty::ctxt cx, &vec[@expr] actuals,
@@ -609,7 +605,7 @@ fn substitute_constr_args(&ty::ctxt cx, &vec[@expr] actuals,
 
 type subst = vec[tup(arg, @expr)];
 
-fn substitute_arg(&ty::ctxt cx, &vec[@expr] actuals, @ast::constr_arg a) ->
+fn substitute_arg(&ty::ctxt cx, &vec[@expr] actuals, @constr_arg a) ->
    @constr_arg_use {
     auto num_actuals = vec::len(actuals);
     alt (a.node) {
diff --git a/src/comp/middle/tstate/bitvectors.rs b/src/comp/middle/tstate/bitvectors.rs
index c7e77881e85..3dea3cef30d 100644
--- a/src/comp/middle/tstate/bitvectors.rs
+++ b/src/comp/middle/tstate/bitvectors.rs
@@ -1,5 +1,6 @@
 
-import front::ast::*;
+import syntax::ast::*;
+import syntax::walk;
 import std::option::*;
 import std::vec;
 import std::vec::len;
diff --git a/src/comp/middle/tstate/ck.rs b/src/comp/middle/tstate/ck.rs
index 679ac234a7e..084a11aa5fd 100644
--- a/src/comp/middle/tstate/ck.rs
+++ b/src/comp/middle/tstate/ck.rs
@@ -1,25 +1,26 @@
 
-import front::ast;
-import front::ast::method;
-import front::ast::item;
-import front::ast::item_fn;
-import front::ast::_fn;
-import front::ast::obj_field;
-import front::ast::_obj;
-import front::ast::stmt;
-import front::ast::ident;
-import front::ast::fn_ident;
-import front::ast::node_id;
-import front::ast::def_id;
-import front::ast::local_def;
-import front::ast::ty_param;
-import front::ast::crate;
-import front::ast::return;
-import front::ast::noreturn;
-import front::ast::expr;
+import syntax::ast;
+import ast::method;
+import ast::item;
+import ast::item_fn;
+import ast::_fn;
+import ast::obj_field;
+import ast::_obj;
+import ast::stmt;
+import ast::ident;
+import ast::fn_ident;
+import ast::node_id;
+import ast::def_id;
+import ast::local_def;
+import ast::ty_param;
+import ast::crate;
+import ast::return;
+import ast::noreturn;
+import ast::expr;
+import syntax::walk;
+import syntax::codemap::span;
 import middle::ty::type_is_nil;
 import middle::ty::ret_ty_of_fn;
-import util::common::span;
 import tstate::ann::ts_ann;
 import tstate::ann::empty_poststate;
 import tstate::ann::true_precond;
@@ -43,7 +44,7 @@ import std::option::t;
 import std::option::some;
 import std::option::none;
 import aux::*;
-import pretty::pprust::ty_to_str;
+import syntax::print::pprust::ty_to_str;
 import util::common::log_stmt_err;
 import bitvectors::promises;
 import annotate::annotate_crate;
@@ -86,7 +87,7 @@ fn check_states_expr(&fn_ctxt fcx, &@expr e) {
         s +=
             "Unsatisfied precondition constraint (for example, " + diff +
                 ") for expression:\n";
-        s += pretty::pprust::expr_to_str(e);
+        s += syntax::print::pprust::expr_to_str(e);
         s += "\nPrecondition:\n";
         s += tritv_to_str(fcx, prec);
         s += "\nPrestate:\n";
@@ -115,7 +116,7 @@ fn check_states_stmt(&fn_ctxt fcx, &@stmt s) {
         ss +=
             "Unsatisfied precondition constraint (for example, " + diff +
                 ") for statement:\n";
-        ss += pretty::pprust::stmt_to_str(*s);
+        ss += syntax::print::pprust::stmt_to_str(*s);
         ss += "\nPrecondition:\n";
         ss += tritv_to_str(fcx, prec);
         ss += "\nPrestate: \n";
diff --git a/src/comp/middle/tstate/collect_locals.rs b/src/comp/middle/tstate/collect_locals.rs
index 2ec43efe0c9..e3b4f0421d4 100644
--- a/src/comp/middle/tstate/collect_locals.rs
+++ b/src/comp/middle/tstate/collect_locals.rs
@@ -1,13 +1,14 @@
 
 import std::vec;
 import std::vec::plus_option;
-import front::ast;
-import front::ast::*;
-import pretty::ppaux::fn_ident_to_string;
+import syntax::ast::*;
+import util::ppaux::fn_ident_to_string;
 import std::option::*;
-import middle::walk::walk_crate;
-import middle::walk::walk_fn;
-import middle::walk::ast_visitor;
+import syntax::walk;
+import syntax::visit;
+import walk::walk_crate;
+import walk::walk_fn;
+import walk::ast_visitor;
 import aux::cinit;
 import aux::ninit;
 import aux::npred;
@@ -20,11 +21,11 @@ import aux::constr_map;
 import aux::expr_to_constr;
 import aux::constraints_expr;
 import aux::node_id_to_def_strict;
-import util::common::new_int_hash;
+import syntax::_std::new_int_hash;
 import util::common::new_def_hash;
-import util::common::uistr;
-import util::common::span;
-import util::common::respan;
+import syntax::_std::uistr;
+import syntax::codemap::span;
+import syntax::ast::respan;
 
 type ctxt = rec(@mutable vec[aux::constr] cs, ty::ctxt tcx);
 
@@ -64,7 +65,7 @@ fn do_nothing(&_fn f, &vec[ty_param] tp, &span sp, &fn_ident i,
               node_id iid, &ctxt cx, &visit::vt[ctxt] v) {
 }
  
-fn find_locals(&ty::ctxt tcx, &_fn f, &vec[ast::ty_param] tps,
+fn find_locals(&ty::ctxt tcx, &_fn f, &vec[ty_param] tps,
                &span sp, &fn_ident i, node_id id)
     -> ctxt {
     let ctxt cx = rec(cs=@mutable vec::alloc(0u), tcx=tcx);
@@ -81,7 +82,7 @@ fn find_locals(&ty::ctxt tcx, &_fn f, &vec[ast::ty_param] tps,
 
 fn add_constraint(&ty::ctxt tcx, aux::constr c, uint next, constr_map tbl) ->
    uint {
-    log aux::constraint_to_str(tcx, c) + " |-> " + util::common::uistr(next);
+    log aux::constraint_to_str(tcx, c) + " |-> " + uistr(next);
     alt (c.node.c) {
         case (ninit(?i)) { tbl.insert(c.node.id, cinit(next, c.span, i)); }
         case (npred(?p, ?args)) {
@@ -115,7 +116,7 @@ fn add_constraint(&ty::ctxt tcx, aux::constr c, uint next, constr_map tbl) ->
 
 /* builds a table mapping each local var defined in f
    to a bit number in the precondition/postcondition vectors */
-fn mk_fn_info(&crate_ctxt ccx, &_fn f, &vec[ast::ty_param] tp,
+fn mk_fn_info(&crate_ctxt ccx, &_fn f, &vec[ty_param] tp,
               &span f_sp, &fn_ident f_name,
               node_id id) {
     auto res_map = @new_int_hash[constraint]();
diff --git a/src/comp/middle/tstate/pre_post_conditions.rs b/src/comp/middle/tstate/pre_post_conditions.rs
index 25d6fb98a92..9ce0d7ce5eb 100644
--- a/src/comp/middle/tstate/pre_post_conditions.rs
+++ b/src/comp/middle/tstate/pre_post_conditions.rs
@@ -65,10 +65,11 @@ import bitvectors::declare_var;
 import bitvectors::gen_poststate;
 import bitvectors::relax_precond_block;
 import bitvectors::gen;
-import front::ast::*;
-import util::common::new_int_hash;
+import syntax::ast::*;
+import syntax::_std::new_int_hash;
 import util::common::new_def_hash;
-import util::common::uistr;
+import syntax::_std::istr;
+import syntax::_std::uistr;
 import util::common::log_expr;
 import util::common::log_fn;
 import util::common::elt_exprs;
@@ -79,9 +80,8 @@ import util::common::log_stmt_err;
 import util::common::log_expr_err;
 import util::common::log_block_err;
 import util::common::log_block;
-import util::common::span;
-import util::common::istr;
-import pretty::ppaux::fn_ident_to_string;
+import syntax::codemap::span;
+import util::ppaux::fn_ident_to_string;
 
 fn find_pre_post_mod(&_mod m) -> _mod {
     log "implement find_pre_post_mod!";
diff --git a/src/comp/middle/tstate/states.rs b/src/comp/middle/tstate/states.rs
index 4e4c3a961d7..ff999c1aa1c 100644
--- a/src/comp/middle/tstate/states.rs
+++ b/src/comp/middle/tstate/states.rs
@@ -75,13 +75,12 @@ import bitvectors::gen_poststate;
 import bitvectors::kill_poststate;
 import bitvectors::clear_in_poststate_ident;
 import bitvectors::intersect_states;
-import front::ast;
-import front::ast::*;
+import syntax::ast::*;
 import middle::ty::expr_ty;
 import middle::ty::type_is_nil;
 import middle::ty::type_is_bot;
 import util::common::new_def_hash;
-import util::common::uistr;
+import syntax::_std::uistr;
 import util::common::log_expr;
 import util::common::log_block;
 import util::common::log_block_err;
@@ -171,7 +170,7 @@ fn find_pre_post_state_call(&fn_ctxt fcx, &prestate pres, &@expr a,
           expr_poststate(fcx.ccx, a), id, bs, cf) || changed;
 }
 
-fn find_pre_post_state_exprs(&fn_ctxt fcx, &prestate pres, ast::node_id id,
+fn find_pre_post_state_exprs(&fn_ctxt fcx, &prestate pres, node_id id,
                              &vec[@expr] es, controlflow cf) -> bool {
     auto rs = seq_states(fcx, pres, es);
     auto changed = rs._0 | set_prestate_ann(fcx.ccx, id, pres);
@@ -229,7 +228,7 @@ fn gen_if_local(&fn_ctxt fcx, &poststate p, &@expr e) -> bool {
 }
 
 fn join_then_else(&fn_ctxt fcx, &@expr antec, &block conseq,
-                  &option::t[@expr] maybe_alt, ast::node_id id, &if_ty chk,
+                  &option::t[@expr] maybe_alt, node_id id, &if_ty chk,
                   &prestate pres) -> bool {
     auto changed = set_prestate_ann(fcx.ccx, id, pres) |
         find_pre_post_state_expr(fcx, pres, antec);
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs
index 254fd130681..760a9b2fa94 100644
--- a/src/comp/middle/ty.rs
+++ b/src/comp/middle/ty.rs
@@ -13,18 +13,20 @@ import std::option::none;
 import std::option::some;
 import std::smallintmap;
 import driver::session;
-import front::ast;
-import front::ast::def_id;
-import front::ast::constr_arg_general;
-import front::ast::mutability;
-import front::ast::controlflow;
-import front::ast::path_to_str;
+import syntax::ast;
+import ast::def_id;
+import ast::constr_arg_general;
+import ast::mutability;
+import ast::controlflow;
+import ast::path_to_str;
+import ast::spanned;
+import syntax::codemap::span;
 import metadata::creader;
 import metadata::decoder;
 import util::common::*;
-import util::data::interner;
-import pretty::ppaux::ty_to_str;
-import pretty::ppaux::mode_str_1;
+import syntax::util::interner;
+import util::ppaux::ty_to_str;
+import util::ppaux::mode_str_1;
 
 
 export node_id_to_monotype;
@@ -251,7 +253,7 @@ tag sty {
     ty_int;
     ty_float;
     ty_uint;
-    ty_machine(ty_mach);
+    ty_machine(ast::ty_mach);
     ty_char;
     ty_str;
     ty_istr;
@@ -360,16 +362,16 @@ fn populate_type_store(&ctxt cx) {
     intern(cx, ty_int, none[str]);
     intern(cx, ty_float, none[str]);
     intern(cx, ty_uint, none[str]);
-    intern(cx, ty_machine(ty_i8), none[str]);
-    intern(cx, ty_machine(ty_i16), none[str]);
-    intern(cx, ty_machine(ty_i32), none[str]);
-    intern(cx, ty_machine(ty_i64), none[str]);
-    intern(cx, ty_machine(ty_u8), none[str]);
-    intern(cx, ty_machine(ty_u16), none[str]);
-    intern(cx, ty_machine(ty_u32), none[str]);
-    intern(cx, ty_machine(ty_u64), none[str]);
-    intern(cx, ty_machine(ty_f32), none[str]);
-    intern(cx, ty_machine(ty_f64), none[str]);
+    intern(cx, ty_machine(ast::ty_i8), none[str]);
+    intern(cx, ty_machine(ast::ty_i16), none[str]);
+    intern(cx, ty_machine(ast::ty_i32), none[str]);
+    intern(cx, ty_machine(ast::ty_i64), none[str]);
+    intern(cx, ty_machine(ast::ty_u8), none[str]);
+    intern(cx, ty_machine(ast::ty_u16), none[str]);
+    intern(cx, ty_machine(ast::ty_u32), none[str]);
+    intern(cx, ty_machine(ast::ty_u64), none[str]);
+    intern(cx, ty_machine(ast::ty_f32), none[str]);
+    intern(cx, ty_machine(ast::ty_f64), none[str]);
     intern(cx, ty_char, none[str]);
     intern(cx, ty_str, none[str]);
     intern(cx, ty_istr, none[str]);
@@ -534,18 +536,18 @@ fn mk_float(&ctxt cx) -> t { ret idx_float; }
 
 fn mk_uint(&ctxt cx) -> t { ret idx_uint; }
 
-fn mk_mach(&ctxt cx, &ty_mach tm) -> t {
+fn mk_mach(&ctxt cx, &ast::ty_mach tm) -> t {
     alt (tm) {
-        case (ty_u8) { ret idx_u8; }
-        case (ty_u16) { ret idx_u16; }
-        case (ty_u32) { ret idx_u32; }
-        case (ty_u64) { ret idx_u64; }
-        case (ty_i8) { ret idx_i8; }
-        case (ty_i16) { ret idx_i16; }
-        case (ty_i32) { ret idx_i32; }
-        case (ty_i64) { ret idx_i64; }
-        case (ty_f32) { ret idx_f32; }
-        case (ty_f64) { ret idx_f64; }
+        case (ast::ty_u8) { ret idx_u8; }
+        case (ast::ty_u16) { ret idx_u16; }
+        case (ast::ty_u32) { ret idx_u32; }
+        case (ast::ty_u64) { ret idx_u64; }
+        case (ast::ty_i8) { ret idx_i8; }
+        case (ast::ty_i16) { ret idx_i16; }
+        case (ast::ty_i32) { ret idx_i32; }
+        case (ast::ty_i64) { ret idx_i64; }
+        case (ast::ty_f32) { ret idx_f32; }
+        case (ast::ty_f64) { ret idx_f64; }
     }
 }
 
@@ -938,8 +940,8 @@ fn sequence_is_interior(&ctxt cx, &t ty) -> bool {
 
 fn sequence_element_type(&ctxt cx, &t ty) -> t {
     alt (struct(cx, ty)) {
-        case (ty_str) { ret mk_mach(cx, ty_u8); }
-        case (ty_istr) { ret mk_mach(cx, ty_u8); }
+        case (ty_str) { ret mk_mach(cx, ast::ty_u8); }
+        case (ty_istr) { ret mk_mach(cx, ast::ty_u8); }
         case (ty_vec(?mt)) { ret mt.ty; }
         case (ty_ivec(?mt)) { ret mt.ty; }
         case (_) {
@@ -1135,14 +1137,14 @@ fn type_is_integral(&ctxt cx, &t ty) -> bool {
         case (ty_uint) { ret true; }
         case (ty_machine(?m)) {
             alt (m) {
-                case (ty_i8) { ret true; }
-                case (ty_i16) { ret true; }
-                case (ty_i32) { ret true; }
-                case (ty_i64) { ret true; }
-                case (ty_u8) { ret true; }
-                case (ty_u16) { ret true; }
-                case (ty_u32) { ret true; }
-                case (ty_u64) { ret true; }
+                case (ast::ty_i8) { ret true; }
+                case (ast::ty_i16) { ret true; }
+                case (ast::ty_i32) { ret true; }
+                case (ast::ty_i64) { ret true; }
+                case (ast::ty_u8) { ret true; }
+                case (ast::ty_u16) { ret true; }
+                case (ast::ty_u32) { ret true; }
+                case (ast::ty_u64) { ret true; }
                 case (_) { ret false; }
             }
         }
@@ -1155,8 +1157,8 @@ fn type_is_fp(&ctxt cx, &t ty) -> bool {
     alt (struct(cx, ty)) {
         case (ty_machine(?tm)) {
             alt (tm) {
-                case (ty_f32) { ret true; }
-                case (ty_f64) { ret true; }
+                case (ast::ty_f32) { ret true; }
+                case (ast::ty_f64) { ret true; }
                 case (_) { ret false; }
             }
         }
@@ -1170,10 +1172,10 @@ fn type_is_signed(&ctxt cx, &t ty) -> bool {
         case (ty_int) { ret true; }
         case (ty_machine(?tm)) {
             alt (tm) {
-                case (ty_i8) { ret true; }
-                case (ty_i16) { ret true; }
-                case (ty_i32) { ret true; }
-                case (ty_i64) { ret true; }
+                case (ast::ty_i8) { ret true; }
+                case (ast::ty_i16) { ret true; }
+                case (ast::ty_i32) { ret true; }
+                case (ast::ty_i64) { ret true; }
                 case (_) { ret false; }
             }
         }
@@ -1322,16 +1324,16 @@ fn hash_type_structure(&sty st) -> uint {
         case (ty_uint) { ret 4u; }
         case (ty_machine(?tm)) {
             alt (tm) {
-                case (ty_i8) { ret 5u; }
-                case (ty_i16) { ret 6u; }
-                case (ty_i32) { ret 7u; }
-                case (ty_i64) { ret 8u; }
-                case (ty_u8) { ret 9u; }
-                case (ty_u16) { ret 10u; }
-                case (ty_u32) { ret 11u; }
-                case (ty_u64) { ret 12u; }
-                case (ty_f32) { ret 13u; }
-                case (ty_f64) { ret 14u; }
+                case (ast::ty_i8) { ret 5u; }
+                case (ast::ty_i16) { ret 6u; }
+                case (ast::ty_i32) { ret 7u; }
+                case (ast::ty_i64) { ret 8u; }
+                case (ast::ty_u8) { ret 9u; }
+                case (ast::ty_u16) { ret 10u; }
+                case (ast::ty_u32) { ret 11u; }
+                case (ast::ty_u64) { ret 12u; }
+                case (ast::ty_f32) { ret 13u; }
+                case (ast::ty_f64) { ret 14u; }
             }
         }
         case (ty_char) { ret 15u; }
@@ -2644,7 +2646,7 @@ mod unify {
             alt (smallintmap::find[t](vb.types, i)) {
                 case (none[t]) { typespec = ""; }
                 case (some[t](?typ)) {
-                    typespec = " =" + pretty::ppaux::ty_to_str(tcx, typ);
+                    typespec = " =" + ty_to_str(tcx, typ);
                 }
             }
             log_err #fmt("set %u:%s%s", i, typespec, sets);
@@ -2948,17 +2950,17 @@ fn is_binopable(&ctxt cx, t ty, ast::binop op) -> bool {
             case (ty_bool) { tycat_bool }
             case (ty_int) { tycat_int }
             case (ty_uint) { tycat_int }
-            case (ty_machine(ty_i8)) { tycat_int }
-            case (ty_machine(ty_i16)) { tycat_int }
-            case (ty_machine(ty_i32)) { tycat_int }
-            case (ty_machine(ty_i64)) { tycat_int }
-            case (ty_machine(ty_u8)) { tycat_int }
-            case (ty_machine(ty_u16)) { tycat_int }
-            case (ty_machine(ty_u32)) { tycat_int }
-            case (ty_machine(ty_u64)) { tycat_int }
+            case (ty_machine(ast::ty_i8)) { tycat_int }
+            case (ty_machine(ast::ty_i16)) { tycat_int }
+            case (ty_machine(ast::ty_i32)) { tycat_int }
+            case (ty_machine(ast::ty_i64)) { tycat_int }
+            case (ty_machine(ast::ty_u8)) { tycat_int }
+            case (ty_machine(ast::ty_u16)) { tycat_int }
+            case (ty_machine(ast::ty_u32)) { tycat_int }
+            case (ty_machine(ast::ty_u64)) { tycat_int }
             case (ty_float) { tycat_float }
-            case (ty_machine(ty_f32)) { tycat_float }
-            case (ty_machine(ty_f64)) { tycat_float }
+            case (ty_machine(ast::ty_f32)) { tycat_float }
+            case (ty_machine(ast::ty_f64)) { tycat_float }
             case (ty_char) { tycat_int }
             case (ty_ptr(_)) { tycat_int }
             case (ty_str) { tycat_str }
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs
index 785393e13c9..5c4e4f1572b 100644
--- a/src/comp/middle/typeck.rs
+++ b/src/comp/middle/typeck.rs
@@ -1,14 +1,15 @@
 
-import front::ast;
-import front::ast::mutability;
-import front::ast::local_def;
-import front::ast::path_to_str;
+import syntax::ast;
+import ast::mutability;
+import ast::local_def;
+import ast::path_to_str;
+import ast::respan;
+import syntax::walk;
 import metadata::decoder;
 import driver::session;
 import util::common;
-import util::common::span;
-import util::common::respan;
-import util::common::new_int_hash;
+import syntax::codemap::span;
+import syntax::_std::new_int_hash;
 import util::common::new_def_hash;
 import util::common::log_expr_err;
 import middle::ty;
@@ -24,7 +25,7 @@ import middle::ty::mo_alias;
 import middle::ty::node_type_table;
 import middle::ty::pat_ty;
 import middle::ty::ty_param_substs_opt_and_ty;
-import pretty::ppaux::ty_to_str;
+import util::ppaux::ty_to_str;
 import middle::ty::ty_param_count_and_ty;
 import middle::ty::ty_nil;
 import middle::ty::unify::ures_ok;
@@ -537,7 +538,7 @@ mod collect {
             }
             case (_) {
                 cx.tcx.sess.fatal("internal error " +
-                                  util::common::istr(id._1));
+                                  syntax::_std::istr(id._1));
             }
         }
         ret tpt;
@@ -1375,7 +1376,7 @@ fn require_pure_call(@crate_ctxt ccx, &ast::purity caller_purity,
 
 fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
     // fcx.ccx.tcx.sess.span_warn(expr.span, "typechecking expr " +
-    //                                pretty::pprust::expr_to_str(expr));
+    //                            syntax::print::pprust::expr_to_str(expr));
 
     // A generic function to factor out common logic from call and bind
     // expressions.
@@ -1545,7 +1546,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
     }
 
     // Checks the compatibility 
-    fn check_binop_type_compat(&@fn_ctxt fcx, common::span span,
+    fn check_binop_type_compat(&@fn_ctxt fcx, span span,
                                ty::t ty, ast::binop binop) {
         auto resolved_t = resolve_type_vars_if_possible(fcx, ty);
         if (!ty::is_binopable(fcx.ccx.tcx, resolved_t, binop)) {
@@ -1794,11 +1795,11 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
             alt (structure_of(fcx, expr.span, ety)) {
                 case (ty::ty_vec(?vec_elt_ty)) { elt_ty = vec_elt_ty.ty; }
                 case (ty::ty_str) {
-                    elt_ty = ty::mk_mach(fcx.ccx.tcx, util::common::ty_u8);
+                    elt_ty = ty::mk_mach(fcx.ccx.tcx, ast::ty_u8);
                 }
                 case (ty::ty_ivec(?vec_elt_ty)) { elt_ty = vec_elt_ty.ty; }
                 case (ty::ty_istr) {
-                    elt_ty = ty::mk_mach(fcx.ccx.tcx, util::common::ty_u8);
+                    elt_ty = ty::mk_mach(fcx.ccx.tcx, ast::ty_u8);
                 }
                 case (_) {
                     fcx.ccx.tcx.sess.span_fatal(expr.span,
@@ -2150,11 +2151,11 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
                     write::ty_only_fixup(fcx, id, mt.ty);
                 }
                 case (ty::ty_str) {
-                    auto typ = ty::mk_mach(fcx.ccx.tcx, common::ty_u8);
+                    auto typ = ty::mk_mach(fcx.ccx.tcx, ast::ty_u8);
                     write::ty_only_fixup(fcx, id, typ);
                 }
                 case (ty::ty_istr) {
-                    auto typ = ty::mk_mach(fcx.ccx.tcx, common::ty_u8);
+                    auto typ = ty::mk_mach(fcx.ccx.tcx, ast::ty_u8);
                     write::ty_only_fixup(fcx, id, typ);
                 }
                 case (_) {
diff --git a/src/comp/pretty/ppaux.rs b/src/comp/pretty/ppaux.rs
deleted file mode 100644
index ea4136182ba..00000000000
--- a/src/comp/pretty/ppaux.rs
+++ /dev/null
@@ -1,433 +0,0 @@
-
-import std::io;
-import std::vec;
-import std::str;
-import std::option;
-import std::option::none;
-import std::option::some;
-import middle::ty;
-import middle::ty::*;
-import front::lexer;
-import front::ast;
-import pp::word;
-import pp::eof;
-import pp::zerobreak;
-import pp::hardbreak;
-import front::codemap;
-import front::codemap::codemap;
-import util::common::istr;
-import util::common::uistr;
-import util::common::ty_mach_to_str;
-
-fn mode_str(&ty::mode m) -> str {
-    alt (m) {
-        case (mo_val) { "" }
-        case (mo_alias(false)) { "&" }
-        case (mo_alias(true)) { "&mutable " }
-    }
-}
-
-fn mode_str_1(&ty::mode m) -> str {
-    alt (m) {
-        case (mo_val) { "val" }
-        case (_)      { mode_str(m) }
-    }
-}
-
-fn fn_ident_to_string(ast::node_id id, &ast::fn_ident i) -> str {
-    ret alt (i) {
-        case (none) { "anon" + istr(id) }
-        case (some(?s)) { s }
-    };
-}
-
-fn ty_to_str(&ctxt cx, &t typ) -> str {
-    fn fn_input_to_str(&ctxt cx, &rec(middle::ty::mode mode, t ty) input) ->
-       str {
-        auto s = mode_str(input.mode);
-        ret s + ty_to_str(cx, input.ty);
-    }
-    fn fn_to_str(&ctxt cx, ast::proto proto, option::t[ast::ident] ident,
-                 &arg[] inputs, t output, ast::controlflow cf,
-                 &vec[@constr_def] constrs) -> str {
-        auto s;
-        alt (proto) {
-            case (ast::proto_iter) { s = "iter"; }
-            case (ast::proto_fn) { s = "fn"; }
-        }
-        alt (ident) { case (some(?i)) { s += " "; s += i; } case (_) { } }
-        s += "(";
-        auto strs = [];
-        for (arg a in inputs) { strs += [fn_input_to_str(cx, a)]; }
-        s += str::connect(strs, ", ");
-        s += ")";
-        if (struct(cx, output) != ty_nil) {
-            alt (cf) {
-                case (ast::noreturn) { s += " -> !"; }
-                case (ast::return) { s += " -> " + ty_to_str(cx, output); }
-            }
-        }
-        s += constrs_str(constrs);
-        ret s;
-    }
-    fn method_to_str(&ctxt cx, &method m) -> str {
-        ret fn_to_str(cx, m.proto, some[ast::ident](m.ident), m.inputs,
-                      m.output, m.cf, m.constrs) + ";";
-    }
-    fn field_to_str(&ctxt cx, &field f) -> str {
-        ret mt_to_str(cx, f.mt) + " " + f.ident;
-    }
-    fn mt_to_str(&ctxt cx, &mt m) -> str {
-        auto mstr;
-        alt (m.mut) {
-            case (ast::mut) { mstr = "mutable "; }
-            case (ast::imm) { mstr = ""; }
-            case (ast::maybe_mut) { mstr = "mutable? "; }
-        }
-        ret mstr + ty_to_str(cx, m.ty);
-    }
-    alt (cname(cx, typ)) { case (some(?cs)) { ret cs; } case (_) { } }
-    auto s = "";
-    alt (struct(cx, typ)) {
-        case (ty_native(_)) { s += "native"; }
-        case (ty_nil) { s += "()"; }
-        case (ty_bot) { s += "_|_"; }
-        case (ty_bool) { s += "bool"; }
-        case (ty_int) { s += "int"; }
-        case (ty_float) { s += "float"; }
-        case (ty_uint) { s += "uint"; }
-        case (ty_machine(?tm)) { s += ty_mach_to_str(tm); }
-        case (ty_char) { s += "char"; }
-        case (ty_str) { s += "str"; }
-        case (ty_istr) { s += "istr"; }
-        case (ty_box(?tm)) { s += "@" + mt_to_str(cx, tm); }
-        case (ty_vec(?tm)) { s += "vec[" + mt_to_str(cx, tm) + "]"; }
-        case (ty_ivec(?tm)) { s += "ivec[" + mt_to_str(cx, tm) + "]"; }
-        case (ty_port(?t)) { s += "port[" + ty_to_str(cx, t) + "]"; }
-        case (ty_chan(?t)) { s += "chan[" + ty_to_str(cx, t) + "]"; }
-        case (ty_type) { s += "type"; }
-        case (ty_task) { s += "task"; }
-        case (ty_tup(?elems)) {
-            let vec[str] strs = [];
-            for (mt tm in elems) { strs += [mt_to_str(cx, tm)]; }
-            s += "tup(" + str::connect(strs, ",") + ")";
-        }
-        case (ty_rec(?elems)) {
-            let vec[str] strs = [];
-            for (field fld in elems) { strs += [field_to_str(cx, fld)]; }
-            s += "rec(" + str::connect(strs, ",") + ")";
-        }
-        case (ty_tag(?id, ?tps)) {
-            // The user should never see this if the cname is set properly!
-
-            s += "<tag#" + istr(id._0) + ":" + istr(id._1) + ">";
-            if (vec::len[t](tps) > 0u) {
-                auto f = bind ty_to_str(cx, _);
-                auto strs = vec::map[t, str](f, tps);
-                s += "[" + str::connect(strs, ",") + "]";
-            }
-        }
-        case (ty_fn(?proto, ?inputs, ?output, ?cf, ?constrs)) {
-            s += fn_to_str(cx, proto, none, inputs, output, cf, constrs);
-        }
-        case (ty_native_fn(_, ?inputs, ?output)) {
-            s += fn_to_str(cx, ast::proto_fn, none, inputs, output,
-                           ast::return, []);
-        }
-        case (ty_obj(?meths)) {
-            auto f = bind method_to_str(cx, _);
-            auto m = vec::map[method, str](f, meths);
-            s += "obj {\n\t" + str::connect(m, "\n\t") + "\n}";
-        }
-        case (ty_res(?id, _, _)) {
-            s += "<resource#" + istr(id._0) + ":" + istr(id._1) + ">";
-        }
-        case (ty_var(?v)) { s += "<T" + istr(v) + ">"; }
-        case (ty_param(?id)) {
-            s += "'" + str::unsafe_from_bytes([('a' as u8) + (id as u8)]);
-        }
-        case (_) { s += ty_to_short_str(cx, typ); }
-    }
-    ret s;
-}
-
-fn ty_to_short_str(&ctxt cx, t typ) -> str {
-    auto f = def_to_str;
-    auto ecx = @rec(ds=f, tcx=cx, abbrevs=metadata::tyencode::ac_no_abbrevs);
-    auto s = metadata::tyencode::ty_str(ecx, typ);
-    if (str::byte_len(s) >= 32u) { s = str::substr(s, 0u, 32u); }
-    ret s;
-}
-
-fn constr_arg_to_str[T](fn(&T) -> str  f, &ast::constr_arg_general_[T] c) ->
-   str {
-    alt (c) {
-        case (ast::carg_base) { ret "*"; }
-        case (ast::carg_ident(?i)) { ret f(i); }
-        case (ast::carg_lit(?l)) { ret lit_to_str(l); }
-    }
-}
-
-fn constr_arg_to_str_1(&front::ast::constr_arg_general_[str] c) -> str {
-    alt (c) {
-        case (ast::carg_base) { ret "*"; }
-        case (ast::carg_ident(?i)) { ret i; }
-        case (ast::carg_lit(?l)) { ret lit_to_str(l); }
-    }
-}
-
-fn constr_args_to_str[T](fn(&T) -> str  f,
-                         &vec[@ast::constr_arg_general[T]] args) -> str {
-    auto comma = false;
-    auto s = "(";
-    for (@ast::constr_arg_general[T] a in args) {
-        if (comma) { s += ", "; } else { comma = true; }
-        s += constr_arg_to_str[T](f, a.node);
-    }
-    s += ")";
-    ret s;
-}
-
-fn print_literal(&ps s, &@front::ast::lit lit) {
-    maybe_print_comment(s, lit.span.lo);
-    alt (next_lit(s)) {
-        case (some(?lt)) {
-            if (lt.pos == lit.span.lo) {
-                word(s.s, lt.lit);
-                s.cur_lit += 1u;
-                ret;
-            }
-        }
-        case (_) { }
-    }
-    alt (lit.node) {
-        case (ast::lit_str(?st, ?kind)) {
-            if (kind == ast::sk_unique) { word(s.s, "~"); }
-            print_string(s, st);
-        }
-        case (ast::lit_char(?ch)) {
-            word(s.s,
-                 "'" + escape_str(str::from_bytes([ch as u8]), '\'') + "'");
-        }
-        case (ast::lit_int(?val)) { word(s.s, istr(val)); }
-        case (ast::lit_uint(?val)) { word(s.s, uistr(val) + "u"); }
-        case (ast::lit_float(?fstr)) { word(s.s, fstr); }
-        case (ast::lit_mach_int(?mach, ?val)) {
-            word(s.s, istr(val as int));
-            word(s.s, ty_mach_to_str(mach));
-        }
-        case (ast::lit_mach_float(?mach, ?val)) {
-            // val is already a str
-
-            word(s.s, val);
-            word(s.s, ty_mach_to_str(mach));
-        }
-        case (ast::lit_nil) { word(s.s, "()"); }
-        case (ast::lit_bool(?val)) {
-            if (val) { word(s.s, "true"); } else { word(s.s, "false"); }
-        }
-    }
-}
-
-fn lit_to_str(&@front::ast::lit l) -> str { be to_str(l, print_literal); }
-
-fn next_lit(&ps s) -> option::t[lexer::lit] {
-    alt (s.literals) {
-        case (some(?lits)) {
-            if (s.cur_lit < vec::len(lits)) {
-                ret some(lits.(s.cur_lit));
-            } else { ret none[lexer::lit]; }
-        }
-        case (_) { ret none[lexer::lit]; }
-    }
-}
-
-fn maybe_print_comment(&ps s, uint pos) {
-    while (true) {
-        alt (next_comment(s)) {
-            case (some(?cmnt)) {
-                if (cmnt.pos < pos) {
-                    print_comment(s, cmnt);
-                    s.cur_cmnt += 1u;
-                } else { break; }
-            }
-            case (_) { break; }
-        }
-    }
-}
-
-fn print_comment(&ps s, lexer::cmnt cmnt) {
-    alt (cmnt.style) {
-        case (lexer::mixed) {
-            assert (vec::len(cmnt.lines) == 1u);
-            zerobreak(s.s);
-            word(s.s, cmnt.lines.(0));
-            zerobreak(s.s);
-        }
-        case (lexer::isolated) {
-            pprust::hardbreak_if_not_bol(s);
-            for (str line in cmnt.lines) { word(s.s, line); hardbreak(s.s); }
-        }
-        case (lexer::trailing) {
-            word(s.s, " ");
-            if (vec::len(cmnt.lines) == 1u) {
-                word(s.s, cmnt.lines.(0));
-                hardbreak(s.s);
-            } else {
-                ibox(s, 0u);
-                for (str line in cmnt.lines) {
-                    word(s.s, line);
-                    hardbreak(s.s);
-                }
-                end(s);
-            }
-        }
-        case (lexer::blank_line) {
-            // We need to do at least one, possibly two hardbreaks.
-            pprust::hardbreak_if_not_bol(s);
-            hardbreak(s.s);
-        }
-    }
-}
-
-fn print_string(&ps s, &str st) {
-    word(s.s, "\"");
-    word(s.s, escape_str(st, '"'));
-    word(s.s, "\"");
-}
-
-fn escape_str(str st, char to_escape) -> str {
-    let str out = "";
-    auto len = str::byte_len(st);
-    auto i = 0u;
-    while (i < len) {
-        alt (st.(i) as char) {
-            case ('\n') { out += "\\n"; }
-            case ('\t') { out += "\\t"; }
-            case ('\r') { out += "\\r"; }
-            case ('\\') { out += "\\\\"; }
-            case (?cur) {
-                if (cur == to_escape) { out += "\\"; }
-                // FIXME some (or all?) non-ascii things should be escaped
-
-                str::push_char(out, cur);
-            }
-        }
-        i += 1u;
-    }
-    ret out;
-}
-
-fn to_str[T](&T t, fn(&ps, &T)  f) -> str {
-    auto writer = io::string_writer();
-    auto s = rust_printer(writer.get_writer());
-    f(s, t);
-    eof(s.s);
-    ret writer.get_str();
-}
-
-fn next_comment(&ps s) -> option::t[lexer::cmnt] {
-    alt (s.comments) {
-        case (some(?cmnts)) {
-            if (s.cur_cmnt < vec::len(cmnts)) {
-                ret some(cmnts.(s.cur_cmnt));
-            } else { ret none[lexer::cmnt]; }
-        }
-        case (_) { ret none[lexer::cmnt]; }
-    }
-}
-
-// The ps is stored here to prevent recursive type.
-// FIXME use a nominal tag instead
-tag ann_node {
-    node_block(ps, ast::block);
-    node_item(ps, @ast::item);
-    node_expr(ps, @ast::expr);
-    node_pat(ps, @ast::pat);
-}
-type pp_ann = rec(fn(&ann_node node) pre,
-                  fn(&ann_node node) post);
-
-fn no_ann() -> pp_ann {
-    fn ignore(&ann_node node) {}
-    ret rec(pre=ignore, post=ignore);
-}
-
-type ps =
-    @rec(pp::printer s,
-         option::t[codemap] cm,
-         option::t[vec[lexer::cmnt]] comments,
-         option::t[vec[lexer::lit]] literals,
-         mutable uint cur_cmnt,
-         mutable uint cur_lit,
-         mutable vec[pp::breaks] boxes,
-         pp_ann ann);
-
-fn ibox(&ps s, uint u) {
-    vec::push(s.boxes, pp::inconsistent);
-    pp::ibox(s.s, u);
-}
-
-fn end(&ps s) { vec::pop(s.boxes); pp::end(s.s); }
-
-fn rust_printer(io::writer writer) -> ps {
-    let vec[pp::breaks] boxes = [];
-    ret @rec(s=pp::mk_printer(writer, default_columns),
-             cm=none[codemap],
-             comments=none[vec[lexer::cmnt]],
-             literals=none[vec[lexer::lit]],
-             mutable cur_cmnt=0u,
-             mutable cur_lit=0u,
-             mutable boxes=boxes,
-             ann=no_ann());
-}
-
-const uint indent_unit = 4u;
-
-const uint default_columns = 78u;
-
-
-// needed b/c constr_args_to_str needs
-// something that takes an alias
-// (argh)
-fn uint_to_str(&uint i) -> str { ret uistr(i); }
-
-fn constr_to_str(&@constr_def c) -> str {
-    ret ast::path_to_str(c.node.path) +
-            constr_args_to_str(uint_to_str, c.node.args);
-}
-
-fn ast_constr_to_str(&@front::ast::constr c) -> str {
-    ret ast::path_to_str(c.node.path) +
-            constr_args_to_str(uint_to_str, c.node.args);
-}
-
-fn constrs_str(&vec[@constr_def] constrs) -> str {
-    auto s = "";
-    auto colon = true;
-    for (@constr_def c in constrs) {
-        if (colon) { s += " : "; colon = false; } else { s += ", "; }
-        s += constr_to_str(c);
-    }
-    ret s;
-}
-
-fn ast_constrs_str(&vec[@ast::constr] constrs) -> str {
-    auto s = "";
-    auto colon = true;
-    for (@ast::constr c in constrs) {
-        if (colon) { s += " : "; colon = false; } else { s += ", "; }
-        s += ast_constr_to_str(c);
-    }
-    ret s;
-}
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
-// End:
-//
diff --git a/src/comp/rustc.rc b/src/comp/rustc.rc
index 0fb9f233255..d79c221013a 100644
--- a/src/comp/rustc.rc
+++ b/src/comp/rustc.rc
@@ -17,8 +17,6 @@ use std (name = "std",
 mod middle {
     mod trans;
     mod ty;
-    mod walk;
-    mod visit;
     mod ast_map;
     mod resolve;
     mod typeck;
@@ -38,25 +36,36 @@ mod middle {
 }
 
 
-mod pretty {
-    mod pprust;
-    mod pp;
-    mod ppaux;
+mod syntax {
+    mod _std; // FIXME remove
+    mod ast;
+    mod fold;
+    mod walk;
+    mod visit;
+    mod codemap;
+    mod parse {
+        mod lexer;
+        mod parser;
+        mod token;
+        mod eval;
+    }
+    mod ext {
+        mod base;
+        mod fmt;
+        mod env;
+        mod simplext;
+    }
+    mod print {
+        mod pprust;
+        mod pp;
+    }
+    mod util {
+        mod interner;
+    }
 }
 
 mod front {
-    mod ast;
     mod attr;
-    mod ext;
-    mod extfmt;
-    mod extenv;
-    mod extsimplext;
-    mod fold;
-    mod codemap;
-    mod lexer;
-    mod parser;
-    mod token;
-    mod eval;
     mod config;
 }
 
@@ -88,11 +97,9 @@ mod driver {
 
 mod util {
     mod common;
-    mod data;
+    mod ppaux;
 }
 
-auth front::creader::load_crate = unsafe;
-auth front::creader::get_metadata_section = unsafe;
 auth middle::metadata = unsafe;
 auth middle::trans = unsafe;
 auth lib::llvm = unsafe;
diff --git a/src/comp/syntax/_std.rs b/src/comp/syntax/_std.rs
new file mode 100644
index 00000000000..fb4d1449a99
--- /dev/null
+++ b/src/comp/syntax/_std.rs
@@ -0,0 +1,29 @@
+// FIXME all this stuff should be in the standard lib, and in fact is,
+// but due to the way our snapshots currently work, rustc can't use it
+// until after the next snapshot.
+
+fn new_str_hash[V]() -> std::map::hashmap[str, V] {
+    let std::map::hashfn[str] hasher = std::str::hash;
+    let std::map::eqfn[str] eqer = std::str::eq;
+    ret std::map::mk_hashmap[str, V](hasher, eqer);
+}
+
+fn new_int_hash[V]() -> std::map::hashmap[int, V] {
+    fn hash_int(&int x) -> uint { ret x as uint; }
+    fn eq_int(&int a, &int b) -> bool { ret a == b; }
+    auto hasher = hash_int;
+    auto eqer = eq_int;
+    ret std::map::mk_hashmap[int, V](hasher, eqer);
+}
+
+fn new_uint_hash[V]() -> std::map::hashmap[uint, V] {
+    fn hash_uint(&uint x) -> uint { ret x; }
+    fn eq_uint(&uint a, &uint b) -> bool { ret a == b; }
+    auto hasher = hash_uint;
+    auto eqer = eq_uint;
+    ret std::map::mk_hashmap[uint, V](hasher, eqer);
+}
+
+fn istr(int i) -> str { ret std::int::to_str(i, 10u); }
+
+fn uistr(uint i) -> str { ret std::uint::to_str(i, 10u); }
diff --git a/src/comp/front/ast.rs b/src/comp/syntax/ast.rs
index 600a76c0738..0b05d2122d5 100644
--- a/src/comp/front/ast.rs
+++ b/src/comp/syntax/ast.rs
@@ -2,10 +2,11 @@
 import std::option;
 import std::str;
 import std::vec;
-import util::common::span;
-import util::common::spanned;
-import util::common::ty_mach;
-import util::common::filename;
+import codemap::span;
+import codemap::filename;
+
+type spanned[T] = rec(T node, span span);
+fn respan[T](&span sp, &T t) -> spanned[T] { ret rec(node=t, span=sp); }
 
 type ident = str;
 // Functions may or may not have names.
@@ -342,6 +343,34 @@ type ty_arg = spanned[ty_arg_];
 
 type ty_method = spanned[ty_method_];
 
+tag ty_mach {
+    ty_i8;
+    ty_i16;
+    ty_i32;
+    ty_i64;
+    ty_u8;
+    ty_u16;
+    ty_u32;
+    ty_u64;
+    ty_f32;
+    ty_f64;
+}
+
+fn ty_mach_to_str(ty_mach tm) -> str {
+    alt (tm) {
+        case (ty_u8) { ret "u8"; }
+        case (ty_u16) { ret "u16"; }
+        case (ty_u32) { ret "u32"; }
+        case (ty_u64) { ret "u64"; }
+        case (ty_i8) { ret "i8"; }
+        case (ty_i16) { ret "i16"; }
+        case (ty_i32) { ret "i32"; }
+        case (ty_i64) { ret "i64"; }
+        case (ty_f32) { ret "f32"; }
+        case (ty_f64) { ret "f64"; }
+    }
+}
+
 type ty = spanned[ty_];
 
 tag ty_ {
@@ -357,7 +386,7 @@ tag ty_ {
     ty_int;
     ty_uint;
     ty_float;
-    ty_machine(util::common::ty_mach);
+    ty_machine(ty_mach);
     ty_char;
     ty_str;
     ty_istr; // interior string
@@ -604,7 +633,7 @@ fn ternary_to_if(&@expr e) -> @ast::expr {
 fn path_to_str(&ast::path pth) -> str {
     auto result = str::connect(pth.node.idents, "::");
     if (vec::len[@ast::ty](pth.node.types) > 0u) {
-        fn f(&@ast::ty t) -> str { ret pretty::pprust::ty_to_str(*t); }
+        fn f(&@ast::ty t) -> str { ret print::pprust::ty_to_str(*t); }
         result += "[";
         result += str::connect(vec::map(f, pth.node.types), ",");
         result += "]";
diff --git a/src/comp/syntax/codemap.rs b/src/comp/syntax/codemap.rs
new file mode 100644
index 00000000000..b1f0e7ea5fd
--- /dev/null
+++ b/src/comp/syntax/codemap.rs
@@ -0,0 +1,96 @@
+
+import std::vec;
+import std::term;
+import std::io;
+import std::option;
+import std::option::some;
+import std::option::none;
+
+type filename = str;
+
+/* A codemap is a thing that maps uints to file/line/column positions
+ * in a crate. This to make it possible to represent the positions
+ * with single-word things, rather than passing records all over the
+ * compiler.
+ */
+type filemap = @rec(filename name, uint start_pos, mutable vec[uint] lines);
+
+type codemap = @rec(mutable vec[filemap] files);
+
+type loc = rec(filename filename, uint line, uint col);
+
+fn new_codemap() -> codemap {
+    let vec[filemap] files = [];
+    ret @rec(mutable files=files);
+}
+
+fn new_filemap(filename filename, uint start_pos) -> filemap {
+    ret @rec(name=filename, start_pos=start_pos, mutable lines=[0u]);
+}
+
+fn next_line(filemap file, uint pos) { vec::push[uint](file.lines, pos); }
+
+fn lookup_pos(codemap map, uint pos) -> loc {
+    auto a = 0u;
+    auto b = vec::len[filemap](map.files);
+    while (b - a > 1u) {
+        auto m = (a + b) / 2u;
+        if (map.files.(m).start_pos > pos) { b = m; } else { a = m; }
+    }
+    auto f = map.files.(a);
+    a = 0u;
+    b = vec::len[uint](f.lines);
+    while (b - a > 1u) {
+        auto m = (a + b) / 2u;
+        if (f.lines.(m) > pos) { b = m; } else { a = m; }
+    }
+    ret rec(filename=f.name, line=a + 1u, col=pos - f.lines.(a));
+}
+
+type span = rec(uint lo, uint hi);
+
+fn span_to_str(&span sp, &codemap cm) -> str {
+    auto lo = lookup_pos(cm, sp.lo);
+    auto hi = lookup_pos(cm, sp.hi);
+    ret #fmt("%s:%u:%u:%u:%u", lo.filename, lo.line, lo.col, hi.line, hi.col);
+}
+
+fn emit_diagnostic(&option::t[span] sp, &str msg, &str kind, u8 color,
+                   &codemap cm) {
+    auto ss = "<input>:0:0:0:0";
+    alt (sp) {
+        case (some(?ssp)) { ss = span_to_str(ssp, cm); }
+        case (none) { }
+    }
+    io::stdout().write_str(ss + ": ");
+    if (term::color_supported()) {
+        term::fg(io::stdout().get_buf_writer(), color);
+    }
+    io::stdout().write_str(#fmt("%s:", kind));
+    if (term::color_supported()) {
+        term::reset(io::stdout().get_buf_writer());
+    }
+    io::stdout().write_str(#fmt(" %s\n", msg));
+}
+
+fn emit_warning(&option::t[span] sp, &str msg, &codemap cm) {
+    emit_diagnostic(sp, msg, "warning", 11u8, cm);
+}
+fn emit_error(&option::t[span] sp, &str msg, &codemap cm) {
+    emit_diagnostic(sp, msg, "error", 9u8, cm);
+}
+fn emit_note(&option::t[span] sp, &str msg, &codemap cm) {
+    emit_diagnostic(sp, msg, "note", 10u8, cm);
+}
+
+
+//
+// Local Variables:
+// mode: rust
+// fill-column: 78;
+// indent-tabs-mode: nil
+// c-basic-offset: 4
+// buffer-file-coding-system: utf-8-unix
+// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
+// End:
+//
diff --git a/src/comp/front/ext.rs b/src/comp/syntax/ext/base.rs
index e4562f2f640..719e96f5fe6 100644
--- a/src/comp/front/ext.rs
+++ b/src/comp/syntax/ext/base.rs
@@ -1,10 +1,10 @@
 import std::vec;
 import std::option;
 import std::map::hashmap;
-import driver::session::session;
-import front::parser::parser;
-import util::common::span;
-import util::common::new_str_hash;
+import parse::parser::parse_sess;
+import codemap::span;
+import syntax::_std::new_str_hash;
+import codemap;
 
 type syntax_expander = 
     fn(&ext_ctxt, span, &vec[@ast::expr], option::t[str]) -> @ast::expr;
@@ -20,10 +20,10 @@ tag syntax_extension {
 // AST nodes into full ASTs
 fn syntax_expander_table() -> hashmap[str, syntax_extension] {
     auto syntax_expanders = new_str_hash[syntax_extension]();
-    syntax_expanders.insert("fmt", normal(extfmt::expand_syntax_ext));
-    syntax_expanders.insert("env", normal(extenv::expand_syntax_ext));
+    syntax_expanders.insert("fmt", normal(ext::fmt::expand_syntax_ext));
+    syntax_expanders.insert("env", normal(ext::env::expand_syntax_ext));
     syntax_expanders.insert("macro",    
-                            macro_defining(extsimplext::add_new_extension));
+                            macro_defining(ext::simplext::add_new_extension));
     ret syntax_expanders;
 }
 
@@ -39,18 +39,18 @@ type ext_ctxt =
         span_msg_fn span_unimpl,
         next_id_fn next_id);
 
-fn mk_ctxt(parser parser) -> ext_ctxt {
-    auto sess = parser.get_session();
-    fn ext_span_fatal_(session sess, span sp, str msg) -> ! {
-        sess.span_fatal(sp, msg);
+fn mk_ctxt(&parse_sess sess) -> ext_ctxt {
+    fn ext_span_fatal_(&codemap::codemap cm, span sp, str msg) -> ! {
+        codemap::emit_error(option::some(sp), msg, cm);
+        fail;
     }
-    auto ext_span_fatal = bind ext_span_fatal_(sess, _, _);
-    fn ext_span_unimpl_(session sess, span sp, str msg) -> ! {
-        sess.span_unimpl(sp, msg);
+    auto ext_span_fatal = bind ext_span_fatal_(sess.cm, _, _);
+    fn ext_span_unimpl_(&codemap::codemap cm, span sp, str msg) -> ! {
+        codemap::emit_error(option::some(sp), "unimplemented " + msg, cm);
+        fail;
     }
-    auto ext_span_unimpl = bind ext_span_unimpl_(sess, _, _);
-    fn ext_next_id_(parser parser) -> ast::node_id { parser.get_id() }
-    auto ext_next_id = bind ext_next_id_(parser);
+    auto ext_span_unimpl = bind ext_span_unimpl_(sess.cm, _, _);
+    auto ext_next_id = bind parse::parser::next_node_id(sess);
     ret rec(span_fatal=ext_span_fatal,
             span_unimpl=ext_span_unimpl,
             next_id=ext_next_id);
diff --git a/src/comp/front/extenv.rs b/src/comp/syntax/ext/env.rs
index acfb93e1cdc..7b12c045898 100644
--- a/src/comp/front/extenv.rs
+++ b/src/comp/syntax/ext/env.rs
@@ -5,15 +5,14 @@
  * should all get sucked into either the compiler syntax extension plugin
  * interface.
  */
-import util::common;
 import std::str;
 import std::vec;
 import std::option;
 import std::generic_os;
-import ext::*;
+import base::*;
 export expand_syntax_ext;
 
-fn expand_syntax_ext(&ext_ctxt cx, common::span sp, &vec[@ast::expr] args,
+fn expand_syntax_ext(&ext_ctxt cx, codemap::span sp, &vec[@ast::expr] args,
                      option::t[str] body) -> @ast::expr {
     if (vec::len[@ast::expr](args) != 1u) {
         cx.span_fatal(sp, "malformed #env call");
@@ -28,12 +27,12 @@ fn expand_syntax_ext(&ext_ctxt cx, common::span sp, &vec[@ast::expr] args,
     }
 }
 
-fn make_new_lit(&ext_ctxt cx, common::span sp, ast::lit_ lit) -> @ast::expr {
+fn make_new_lit(&ext_ctxt cx, codemap::span sp, ast::lit_ lit) -> @ast::expr {
     auto sp_lit = @rec(node=lit, span=sp);
     ret @rec(id=cx.next_id(), node=ast::expr_lit(sp_lit), span=sp);
 }
 
-fn make_new_str(&ext_ctxt cx, common::span sp, str s) -> @ast::expr {
+fn make_new_str(&ext_ctxt cx, codemap::span sp, str s) -> @ast::expr {
     ret make_new_lit(cx, sp, ast::lit_str(s, ast::sk_rc));
 }
 //
diff --git a/src/comp/front/extfmt.rs b/src/comp/syntax/ext/fmt.rs
index 0696e0d2c69..1ea2d694374 100644
--- a/src/comp/front/extfmt.rs
+++ b/src/comp/syntax/ext/fmt.rs
@@ -5,17 +5,17 @@
  * should all get sucked into either the standard library extfmt module or the
  * compiler syntax extension plugin interface.
  */
-import util::common;
 import std::str;
 import std::vec;
 import std::option;
 import std::option::none;
 import std::option::some;
 import std::extfmt::ct::*;
-import ext::*;
+import base::*;
+import codemap::span;
 export expand_syntax_ext;
 
-fn expand_syntax_ext(&ext_ctxt cx, common::span sp, &vec[@ast::expr] args,
+fn expand_syntax_ext(&ext_ctxt cx, span sp, &vec[@ast::expr] args,
                      option::t[str] body) -> @ast::expr {
     if (vec::len[@ast::expr](args) == 0u) {
         cx.span_fatal(sp, "#fmt requires a format string");
@@ -25,7 +25,7 @@ fn expand_syntax_ext(&ext_ctxt cx, common::span sp, &vec[@ast::expr] args,
     auto fmtspan = args.(0).span;
     log "Format string:";
     log fmt;
-    fn parse_fmt_err_(&ext_ctxt cx, common::span sp, str msg) -> ! {
+    fn parse_fmt_err_(&ext_ctxt cx, span sp, str msg) -> ! {
         cx.span_fatal(sp, msg);
     }
     auto parse_fmt_err = bind parse_fmt_err_(cx, fmtspan, _);
@@ -36,31 +36,31 @@ fn expand_syntax_ext(&ext_ctxt cx, common::span sp, &vec[@ast::expr] args,
 // FIXME: A lot of these functions for producing expressions can probably
 // be factored out in common with other code that builds expressions.
 // FIXME: Cleanup the naming of these functions
-fn pieces_to_expr(&ext_ctxt cx, common::span sp, vec[piece] pieces,
+fn pieces_to_expr(&ext_ctxt cx, span sp, vec[piece] pieces,
                   vec[@ast::expr] args) -> @ast::expr {
-    fn make_new_lit(&ext_ctxt cx, common::span sp, ast::lit_ lit) ->
+    fn make_new_lit(&ext_ctxt cx, span sp, ast::lit_ lit) ->
        @ast::expr {
         auto sp_lit = @rec(node=lit, span=sp);
         ret @rec(id=cx.next_id(), node=ast::expr_lit(sp_lit), span=sp);
     }
-    fn make_new_str(&ext_ctxt cx, common::span sp, str s) -> @ast::expr {
+    fn make_new_str(&ext_ctxt cx, span sp, str s) -> @ast::expr {
         auto lit = ast::lit_str(s, ast::sk_rc);
         ret make_new_lit(cx, sp, lit);
     }
-    fn make_new_int(&ext_ctxt cx, common::span sp, int i) -> @ast::expr {
+    fn make_new_int(&ext_ctxt cx, span sp, int i) -> @ast::expr {
         auto lit = ast::lit_int(i);
         ret make_new_lit(cx, sp, lit);
     }
-    fn make_new_uint(&ext_ctxt cx, common::span sp, uint u) -> @ast::expr {
+    fn make_new_uint(&ext_ctxt cx, span sp, uint u) -> @ast::expr {
         auto lit = ast::lit_uint(u);
         ret make_new_lit(cx, sp, lit);
     }
-    fn make_add_expr(&ext_ctxt cx, common::span sp, @ast::expr lhs,
+    fn make_add_expr(&ext_ctxt cx, span sp, @ast::expr lhs,
                      @ast::expr rhs) -> @ast::expr {
         auto binexpr = ast::expr_binary(ast::add, lhs, rhs);
         ret @rec(id=cx.next_id(), node=binexpr, span=sp);
     }
-    fn make_path_expr(&ext_ctxt cx, common::span sp, vec[ast::ident] idents)
+    fn make_path_expr(&ext_ctxt cx, span sp, vec[ast::ident] idents)
        -> @ast::expr {
         let vec[@ast::ty] types = [];
         auto path = rec(idents=idents, types=types);
@@ -68,18 +68,18 @@ fn pieces_to_expr(&ext_ctxt cx, common::span sp, vec[piece] pieces,
         auto pathexpr = ast::expr_path(sp_path);
         ret @rec(id=cx.next_id(), node=pathexpr, span=sp);
     }
-    fn make_vec_expr(&ext_ctxt cx, common::span sp, vec[@ast::expr] exprs) ->
+    fn make_vec_expr(&ext_ctxt cx, span sp, vec[@ast::expr] exprs) ->
        @ast::expr {
         auto vecexpr = ast::expr_vec(exprs, ast::imm, ast::sk_rc);
         ret @rec(id=cx.next_id(), node=vecexpr, span=sp);
     }
-    fn make_call(&ext_ctxt cx, common::span sp, vec[ast::ident] fn_path,
+    fn make_call(&ext_ctxt cx, span sp, vec[ast::ident] fn_path,
                  vec[@ast::expr] args) -> @ast::expr {
         auto pathexpr = make_path_expr(cx, sp, fn_path);
         auto callexpr = ast::expr_call(pathexpr, args);
         ret @rec(id=cx.next_id(), node=callexpr, span=sp);
     }
-    fn make_rec_expr(&ext_ctxt cx, common::span sp,
+    fn make_rec_expr(&ext_ctxt cx, span sp,
                      vec[tup(ast::ident, @ast::expr)] fields) -> @ast::expr {
         let vec[ast::field] astfields = [];
         for (tup(ast::ident, @ast::expr) field in fields) {
@@ -98,7 +98,7 @@ fn pieces_to_expr(&ext_ctxt cx, common::span sp, vec[piece] pieces,
 
         ret ["std", "extfmt", "rt", ident];
     }
-    fn make_rt_path_expr(&ext_ctxt cx, common::span sp, str ident) ->
+    fn make_rt_path_expr(&ext_ctxt cx, span sp, str ident) ->
        @ast::expr {
         auto path = make_path_vec(ident);
         ret make_path_expr(cx, sp, path);
@@ -106,9 +106,9 @@ fn pieces_to_expr(&ext_ctxt cx, common::span sp, vec[piece] pieces,
     // Produces an AST expression that represents a RT::conv record,
     // which tells the RT::conv* functions how to perform the conversion
 
-    fn make_rt_conv_expr(&ext_ctxt cx, common::span sp, &conv cnv) ->
+    fn make_rt_conv_expr(&ext_ctxt cx, span sp, &conv cnv) ->
        @ast::expr {
-        fn make_flags(&ext_ctxt cx, common::span sp, vec[flag] flags) ->
+        fn make_flags(&ext_ctxt cx, span sp, vec[flag] flags) ->
            @ast::expr {
             let vec[@ast::expr] flagexprs = [];
             for (flag f in flags) {
@@ -133,7 +133,7 @@ fn pieces_to_expr(&ext_ctxt cx, common::span sp, vec[piece] pieces,
             }
             ret make_vec_expr(cx, sp, flagexprs);
         }
-        fn make_count(&ext_ctxt cx, common::span sp, &count cnt) ->
+        fn make_count(&ext_ctxt cx, span sp, &count cnt) ->
            @ast::expr {
             alt (cnt) {
                 case (count_implied) {
@@ -150,7 +150,7 @@ fn pieces_to_expr(&ext_ctxt cx, common::span sp, vec[piece] pieces,
                 }
             }
         }
-        fn make_ty(&ext_ctxt cx, common::span sp, &ty t) -> @ast::expr {
+        fn make_ty(&ext_ctxt cx, span sp, &ty t) -> @ast::expr {
             auto rt_type;
             alt (t) {
                 case (ty_hex(?c)) {
@@ -165,7 +165,7 @@ fn pieces_to_expr(&ext_ctxt cx, common::span sp, vec[piece] pieces,
             }
             ret make_rt_path_expr(cx, sp, rt_type);
         }
-        fn make_conv_rec(&ext_ctxt cx, common::span sp, @ast::expr flags_expr,
+        fn make_conv_rec(&ext_ctxt cx, span sp, @ast::expr flags_expr,
                          @ast::expr width_expr, @ast::expr precision_expr,
                          @ast::expr ty_expr) -> @ast::expr {
             ret make_rec_expr(cx, sp,
@@ -181,7 +181,7 @@ fn pieces_to_expr(&ext_ctxt cx, common::span sp, vec[piece] pieces,
         ret make_conv_rec(cx, sp, rt_conv_flags, rt_conv_width,
                           rt_conv_precision, rt_conv_ty);
     }
-    fn make_conv_call(&ext_ctxt cx, common::span sp, str conv_type, &conv cnv,
+    fn make_conv_call(&ext_ctxt cx, span sp, str conv_type, &conv cnv,
                       @ast::expr arg) -> @ast::expr {
         auto fname = "conv_" + conv_type;
         auto path = make_path_vec(fname);
@@ -189,7 +189,7 @@ fn pieces_to_expr(&ext_ctxt cx, common::span sp, vec[piece] pieces,
         auto args = [cnv_expr, arg];
         ret make_call(cx, arg.span, path, args);
     }
-    fn make_new_conv(&ext_ctxt cx, common::span sp, conv cnv, @ast::expr arg)
+    fn make_new_conv(&ext_ctxt cx, span sp, conv cnv, @ast::expr arg)
        -> @ast::expr {
         // FIXME: Extract all this validation into extfmt::ct
 
diff --git a/src/comp/front/extsimplext.rs b/src/comp/syntax/ext/simplext.rs
index 3de737f0d53..e214524f0b7 100644
--- a/src/comp/front/extsimplext.rs
+++ b/src/comp/syntax/ext/simplext.rs
@@ -1,6 +1,6 @@
 use std;
 
-import util::common::span;
+import codemap::span;
 import std::vec;
 import std::option;
 import vec::map;
@@ -8,11 +8,11 @@ import vec::len;
 import option::some;
 import option::none;
 
-import ext::syntax_extension;
-import ext::ext_ctxt;
-import ext::normal;
-import ext::expr_to_str;
-import ext::expr_to_ident;
+import base::syntax_extension;
+import base::ext_ctxt;
+import base::normal;
+import base::expr_to_str;
+import base::expr_to_ident;
 
 import fold::*;
 import ast::ident;
diff --git a/src/comp/front/fold.rs b/src/comp/syntax/fold.rs
index 0fc884d67c3..5cf447a862c 100644
--- a/src/comp/front/fold.rs
+++ b/src/comp/syntax/fold.rs
@@ -1,4 +1,4 @@
-import util::common::span;
+import syntax::codemap::span;
 import ast::*;
 
 import std::vec;
diff --git a/src/comp/front/eval.rs b/src/comp/syntax/parse/eval.rs
index 95b9a85c09f..89f6ac536c3 100644
--- a/src/comp/front/eval.rs
+++ b/src/comp/syntax/parse/eval.rs
@@ -4,11 +4,12 @@ import std::str;
 import std::option;
 import std::option::some;
 import std::option::none;
-import driver::session;
-import front::parser::parser;
-import front::parser::new_parser;
-import front::parser::parse_inner_attrs_and_next;
-import front::parser::parse_mod_items;
+import syntax::ast;
+import syntax::parse::token;
+import syntax::parse::parser::parser;
+import syntax::parse::parser::new_parser;
+import syntax::parse::parser::parse_inner_attrs_and_next;
+import syntax::parse::parser::parse_mod_items;
 
 export eval_crate_directives_to_mod;
 export mode_parse;
@@ -19,9 +20,8 @@ type ctx =
     @rec(parser p,
          eval_mode mode,
          mutable vec[str] deps,
-         session::session sess,
+         parser::parse_sess sess,
          mutable uint chpos,
-         mutable int next_id,
          ast::crate_cfg cfg);
 
 fn eval_crate_directives(ctx cx, vec[@ast::crate_directive] cdirs,
@@ -50,8 +50,9 @@ fn eval_crate_directive_block(ctx cx, &ast::block blk, str prefix,
                 eval_crate_directive(cx, cdir, prefix, view_items, items);
             }
             case (_) {
-                cx.sess.span_fatal(s.span,
-                                 "unsupported stmt in crate-directive block");
+                codemap::emit_warning
+                   (some(s.span), "unsupported stmt in crate-directive block",
+                    cx.sess.cm);
             }
         }
     }
@@ -74,19 +75,17 @@ fn eval_crate_directive(ctx cx, @ast::crate_directive cdir, str prefix,
             };
             if (cx.mode == mode_depend) { cx.deps += [full_path]; ret; }
             auto p0 =
-                new_parser(cx.sess, cx.cfg, full_path, cx.chpos,
-                           cx.next_id);
+                new_parser(cx.sess, cx.cfg, full_path, cx.chpos);
             auto inner_attrs = parse_inner_attrs_and_next(p0);
             auto mod_attrs = attrs + inner_attrs._0;
             auto first_item_outer_attrs = inner_attrs._1;
             auto m0 = parse_mod_items(p0, token::EOF, first_item_outer_attrs);
 
-            auto i = front::parser::mk_item(p0, cdir.span.lo, cdir.span.hi,
-                                            id, ast::item_mod(m0),
-                                            mod_attrs);
+            auto i = syntax::parse::parser::mk_item
+                (p0, cdir.span.lo, cdir.span.hi, id, ast::item_mod(m0),
+                 mod_attrs);
             // Thread defids and chpos through the parsers
             cx.chpos = p0.get_chpos();
-            cx.next_id = p0.next_id();
             vec::push[@ast::item](items, i);
         }
         case (ast::cdir_dir_mod(?id, ?dir_opt, ?cdirs, ?attrs)) {
@@ -100,10 +99,10 @@ fn eval_crate_directive(ctx cx, @ast::crate_directive cdir, str prefix,
             auto m0 = eval_crate_directives_to_mod(cx, cdirs, full_path);
             auto i = @rec(ident=id,
                           attrs=attrs,
-                          id=cx.next_id,
+                          id=cx.sess.next_id,
                           node=ast::item_mod(m0),
                           span=cdir.span);
-            cx.next_id += 1;
+            cx.sess.next_id += 1;
             vec::push[@ast::item](items, i);
         }
         case (ast::cdir_view_item(?vi)) {
diff --git a/src/comp/front/lexer.rs b/src/comp/syntax/parse/lexer.rs
index d6bc3723bf3..ffc83bcbbea 100644
--- a/src/comp/front/lexer.rs
+++ b/src/comp/syntax/parse/lexer.rs
@@ -8,11 +8,9 @@ import std::map::hashmap;
 import std::option;
 import std::option::some;
 import std::option::none;
-import driver::session::session;
-import util::common;
-import util::common::*;
-import util::data::interner;
-import util::data::interner::intern;
+import util::interner;
+import util::interner::intern;
+import codemap;
 
 type reader =
     obj {
@@ -31,9 +29,9 @@ type reader =
         fn err(str) ;
     };
 
-fn new_reader(session sess, io::reader rdr, codemap::filemap filemap,
+fn new_reader(&codemap::codemap cm, io::reader rdr, codemap::filemap filemap,
               @interner::interner[str] itr) -> reader {
-    obj reader(session sess,
+    obj reader(codemap::codemap cm,
                str file,
                uint len,
                mutable uint col,
@@ -75,12 +73,14 @@ fn new_reader(session sess, io::reader rdr, codemap::filemap filemap,
         fn get_interner() -> @interner::interner[str] { ret itr; }
         fn get_col() -> uint { ret col; }
         fn get_filemap() -> codemap::filemap { ret fm; }
-        fn err(str m) { sess.span_fatal(rec(lo=chpos, hi=chpos), m); }
+        fn err(str m) {
+            codemap::emit_error(some(rec(lo=chpos, hi=chpos)), m, cm);
+        }
     }
     auto file = str::unsafe_from_bytes(rdr.read_whole_stream());
     let vec[str] strs = [];
     auto rd =
-        reader(sess, file, str::byte_len(file), 0u, 0u, -1 as char,
+        reader(cm, file, str::byte_len(file), 0u, 0u, -1 as char,
                filemap.start_pos, filemap.start_pos, strs, filemap, itr);
     rd.init();
     ret rd;
@@ -101,6 +101,25 @@ fn is_whitespace(char c) -> bool {
     ret c == ' ' || c == '\t' || c == '\r' || c == '\n';
 }
 
+fn may_begin_ident(char c) -> bool { ret is_alpha(c) || c == '_'; }
+
+fn in_range(char c, char lo, char hi) -> bool { ret lo <= c && c <= hi; }
+
+fn is_alpha(char c) -> bool {
+    ret in_range(c, 'a', 'z') || in_range(c, 'A', 'Z');
+}
+
+fn is_dec_digit(char c) -> bool { ret in_range(c, '0', '9'); }
+
+fn is_alnum(char c) -> bool { ret is_alpha(c) || is_dec_digit(c); }
+
+fn is_hex_digit(char c) -> bool {
+    ret in_range(c, '0', '9') || in_range(c, 'a', 'f') ||
+            in_range(c, 'A', 'F');
+}
+
+fn is_bin_digit(char c) -> bool { ret c == '0' || c == '1'; }
+
 fn consume_whitespace_and_comments(&reader rdr) {
     while (is_whitespace(rdr.curr())) { rdr.bump(); }
     be consume_any_line_comment(rdr);
@@ -218,30 +237,30 @@ fn scan_number(char c, &reader rdr) -> token::token {
         if (c == '8') {
             rdr.bump();
             if (signed) {
-                ret token::LIT_MACH_INT(common::ty_i8, accum_int);
-            } else { ret token::LIT_MACH_INT(common::ty_u8, accum_int); }
+                ret token::LIT_MACH_INT(ast::ty_i8, accum_int);
+            } else { ret token::LIT_MACH_INT(ast::ty_u8, accum_int); }
         }
         n = rdr.next();
         if (c == '1' && n == '6') {
             rdr.bump();
             rdr.bump();
             if (signed) {
-                ret token::LIT_MACH_INT(common::ty_i16, accum_int);
-            } else { ret token::LIT_MACH_INT(common::ty_u16, accum_int); }
+                ret token::LIT_MACH_INT(ast::ty_i16, accum_int);
+            } else { ret token::LIT_MACH_INT(ast::ty_u16, accum_int); }
         }
         if (c == '3' && n == '2') {
             rdr.bump();
             rdr.bump();
             if (signed) {
-                ret token::LIT_MACH_INT(common::ty_i32, accum_int);
-            } else { ret token::LIT_MACH_INT(common::ty_u32, accum_int); }
+                ret token::LIT_MACH_INT(ast::ty_i32, accum_int);
+            } else { ret token::LIT_MACH_INT(ast::ty_u32, accum_int); }
         }
         if (c == '6' && n == '4') {
             rdr.bump();
             rdr.bump();
             if (signed) {
-                ret token::LIT_MACH_INT(common::ty_i64, accum_int);
-            } else { ret token::LIT_MACH_INT(common::ty_u64, accum_int); }
+                ret token::LIT_MACH_INT(ast::ty_i64, accum_int);
+            } else { ret token::LIT_MACH_INT(ast::ty_u64, accum_int); }
         }
         if (signed) {
             ret token::LIT_INT(accum_int);
@@ -272,13 +291,13 @@ fn scan_number(char c, &reader rdr) -> token::token {
             if (c == '3' && n == '2') {
                 rdr.bump();
                 rdr.bump();
-                ret token::LIT_MACH_FLOAT(util::common::ty_f32,
+                ret token::LIT_MACH_FLOAT(ast::ty_f32,
                                           intern(*rdr.get_interner(),
                                                  float_str));
             } else if (c == '6' && n == '4') {
                 rdr.bump();
                 rdr.bump();
-                ret token::LIT_MACH_FLOAT(util::common::ty_f64,
+                ret token::LIT_MACH_FLOAT(ast::ty_f64,
                                           intern(*rdr.get_interner(),
                                                  float_str));
                 /* FIXME: if this is out of range for either a 32-bit or
@@ -694,11 +713,11 @@ fn is_lit(&token::token t) -> bool {
 
 type lit = rec(str lit, uint pos);
 
-fn gather_comments_and_literals(session sess, str path) ->
+fn gather_comments_and_literals(&codemap::codemap cm, str path) ->
    rec(vec[cmnt] cmnts, vec[lit] lits) {
     auto srdr = io::file_reader(path);
     auto itr = @interner::mk[str](str::hash, str::eq);
-    auto rdr = new_reader(sess, srdr, codemap::new_filemap(path, 0u), itr);
+    auto rdr = new_reader(cm, srdr, codemap::new_filemap(path, 0u), itr);
     let vec[cmnt] comments = [];
     let vec[lit] literals = [];
     let bool first_read = true;
diff --git a/src/comp/front/parser.rs b/src/comp/syntax/parse/parser.rs
index ce68be6b246..48213c1f1ac 100644
--- a/src/comp/front/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -10,32 +10,37 @@ import std::either::left;
 import std::either::right;
 import std::map::hashmap;
 import token::can_begin_expr;
-import driver::session;
-import util::common;
-import util::common::filename;
-import util::common::span;
-import util::common::new_str_hash;
-import util::data::interner;
-import util::common::a_bang;
-import util::common::a_ty;
+import ex=ext::base;
+import codemap::span;
+import _std::new_str_hash;
+import util::interner;
 
 tag restriction { UNRESTRICTED; RESTRICT_NO_CALL_EXPRS; }
 
 tag file_type { CRATE_FILE; SOURCE_FILE; }
 
-type ty_or_bang = util::common::ty_or_bang[@ast::ty];
+tag ty_or_bang { a_ty(@ast::ty); a_bang; }
+
+type parse_sess = @rec(codemap::codemap cm,
+                       mutable ast::node_id next_id);
+
+fn next_node_id(&parse_sess sess) -> ast::node_id {
+    auto rv = sess.next_id;
+    sess.next_id += 1;
+    ret rv;
+}
 
 type parser =
     obj {
         fn peek() -> token::token ;
         fn bump() ;
         fn fatal(str) -> !  ;
+        fn warn(str);
         fn restrict(restriction) ;
         fn get_restriction() -> restriction ;
         fn get_file_type() -> file_type ;
         fn get_cfg() -> ast::crate_cfg;
-        fn get_session() -> session::session ;
-        fn get_span() -> common::span ;
+        fn get_span() -> span ;
         fn get_lo_pos() -> uint ;
         fn get_hi_pos() -> uint ;
         fn get_last_lo_pos() -> uint ;
@@ -44,15 +49,15 @@ type parser =
         fn get_reader() -> lexer::reader ;
         fn get_filemap() -> codemap::filemap ;
         fn get_bad_expr_words() -> hashmap[str, ()] ;
-        fn get_syntax_expanders() -> hashmap[str, ext::syntax_extension] ;
+        fn get_syntax_expanders() -> hashmap[str, ex::syntax_extension] ;
         fn get_chpos() -> uint ;
         fn get_id() -> ast::node_id ;
-        fn next_id() -> ast::node_id ;
+        fn get_sess() -> parse_sess;
     };
 
-fn new_parser(session::session sess, ast::crate_cfg cfg,
-              str path, uint pos, ast::node_id next_id) -> parser {
-    obj stdio_parser(session::session sess,
+fn new_parser(parse_sess sess, ast::crate_cfg cfg,
+              str path, uint pos) -> parser {
+    obj stdio_parser(parse_sess sess,
                      ast::crate_cfg cfg,
                      file_type ftype,
                      mutable token::token tok,
@@ -62,9 +67,8 @@ fn new_parser(session::session sess, ast::crate_cfg cfg,
                      mutable restriction restr,
                      lexer::reader rdr,
                      vec[op_spec] precs,
-                     mutable ast::node_id next_id_var,
                      hashmap[str, ()] bad_words,
-                     hashmap[str, ext::syntax_extension] syntax_expanders) {
+                     hashmap[str, ex::syntax_extension] syntax_expanders) {
         fn peek() -> token::token { ret tok; }
         fn bump() {
             // log rdr.get_filename()
@@ -75,11 +79,16 @@ fn new_parser(session::session sess, ast::crate_cfg cfg,
             lo = rdr.get_mark_chpos();
             hi = rdr.get_chpos();
         }
-        fn fatal(str m) -> ! { sess.span_fatal(rec(lo=lo, hi=hi), m); }
+        fn fatal(str m) -> ! {
+            codemap::emit_error(some(self.get_span()), m, sess.cm);
+            fail;
+        }
+        fn warn(str m) {
+            codemap::emit_warning(some(self.get_span()), m, sess.cm);
+        }
         fn restrict(restriction r) { restr = r; }
         fn get_restriction() -> restriction { ret restr; }
-        fn get_session() -> session::session { ret sess; }
-        fn get_span() -> common::span { ret rec(lo=lo, hi=hi); }
+        fn get_span() -> span { ret rec(lo=lo, hi=hi); }
         fn get_lo_pos() -> uint { ret lo; }
         fn get_hi_pos() -> uint { ret hi; }
         fn get_last_lo_pos() -> uint { ret last_lo; }
@@ -92,33 +101,29 @@ fn new_parser(session::session sess, ast::crate_cfg cfg,
         fn get_reader() -> lexer::reader { ret rdr; }
         fn get_filemap() -> codemap::filemap { ret rdr.get_filemap(); }
         fn get_bad_expr_words() -> hashmap[str, ()] { ret bad_words; }
-        fn get_syntax_expanders() -> hashmap[str, ext::syntax_extension] {
+        fn get_syntax_expanders() -> hashmap[str, ex::syntax_extension] {
             ret syntax_expanders;
         }
         fn get_chpos() -> uint { ret rdr.get_chpos(); }
-        fn get_id() -> ast::node_id {
-            auto rv = next_id_var;
-            next_id_var += 1;
-            ret rv;
-        }
-        fn next_id() -> ast::node_id { ret next_id_var; }
+        fn get_id() -> ast::node_id { ret next_node_id(sess); }
+        fn get_sess() -> parse_sess { ret sess; }
     }
 
     auto ftype = SOURCE_FILE;
     if (str::ends_with(path, ".rc")) { ftype = CRATE_FILE; }
     auto srdr = io::file_reader(path);
     auto filemap = codemap::new_filemap(path, pos);
-    vec::push(sess.get_codemap().files, filemap);
+    vec::push(sess.cm.files, filemap);
     auto itr = @interner::mk(str::hash, str::eq);
-    auto rdr = lexer::new_reader(sess, srdr, filemap, itr);
+    auto rdr = lexer::new_reader(sess.cm, srdr, filemap, itr);
     // Make sure npos points at first actual token:
 
     lexer::consume_whitespace_and_comments(rdr);
     auto npos = rdr.get_chpos();
     ret stdio_parser(sess, cfg, ftype, lexer::next_token(rdr),
                      npos, npos, npos, UNRESTRICTED, rdr,
-                     prec_table(), next_id, bad_expr_word_table(),
-                     ext::syntax_expander_table());
+                     prec_table(), bad_expr_word_table(),
+                     ex::syntax_expander_table());
 }
 
 // These are the words that shouldn't be allowed as value identifiers,
@@ -181,7 +186,7 @@ fn expect(&parser p, token::token t) {
     }
 }
 
-fn spanned[T](uint lo, uint hi, &T node) -> common::spanned[T] {
+fn spanned[T](uint lo, uint hi, &T node) -> ast::spanned[T] {
     ret rec(node=node, span=rec(lo=lo, hi=hi));
 }
 
@@ -326,8 +331,7 @@ fn parse_ty_field(&parser p) -> ast::ty_field {
 fn ident_index(&parser p, &vec[ast::arg] args, &ast::ident i) -> uint {
     auto j = 0u;
     for (ast::arg a in args) { if (a.ident == i) { ret j; } j += 1u; }
-    p.get_session().span_fatal(p.get_span(),
-                             "Unbound variable " + i + " in constraint arg");
+    p.fatal("Unbound variable " + i + " in constraint arg");
 }
 
 fn parse_constr_arg(vec[ast::arg] args, &parser p) -> @ast::constr_arg {
@@ -359,7 +363,7 @@ fn parse_ty_constr(&vec[ast::arg] fn_args, &parser p) -> @ast::constr {
 // mentioned in a constraint to an arg index.
 // Seems weird to do this in the parser, but I'm not sure how else to.
 fn parse_constrs(&vec[ast::arg] args, &parser p) ->
-   common::spanned[vec[@ast::constr]] {
+    ast::spanned[vec[@ast::constr]] {
     auto lo = p.get_lo_pos();
     auto hi = p.get_hi_pos();
     let vec[@ast::constr] constrs = [];
@@ -431,7 +435,7 @@ fn parse_ty_postfix(@ast::ty orig_t, &parser p) -> @ast::ty {
 
 fn parse_ty_or_bang(&parser p) -> ty_or_bang {
     alt (p.peek()) {
-        case (token::NOT) { p.bump(); ret a_bang[@ast::ty]; }
+        case (token::NOT) { p.bump(); ret a_bang; }
         case (_) { ret a_ty(parse_ty(p)); }
     }
 }
@@ -460,25 +464,25 @@ fn parse_ty(&parser p) -> @ast::ty {
     } else if (eat_word(p, "task")) {
         t = ast::ty_task;
     } else if (eat_word(p, "i8")) {
-        t = ast::ty_machine(common::ty_i8);
+        t = ast::ty_machine(ast::ty_i8);
     } else if (eat_word(p, "i16")) {
-        t = ast::ty_machine(common::ty_i16);
+        t = ast::ty_machine(ast::ty_i16);
     } else if (eat_word(p, "i32")) {
-        t = ast::ty_machine(common::ty_i32);
+        t = ast::ty_machine(ast::ty_i32);
     } else if (eat_word(p, "i64")) {
-        t = ast::ty_machine(common::ty_i64);
+        t = ast::ty_machine(ast::ty_i64);
     } else if (eat_word(p, "u8")) {
-        t = ast::ty_machine(common::ty_u8);
+        t = ast::ty_machine(ast::ty_u8);
     } else if (eat_word(p, "u16")) {
-        t = ast::ty_machine(common::ty_u16);
+        t = ast::ty_machine(ast::ty_u16);
     } else if (eat_word(p, "u32")) {
-        t = ast::ty_machine(common::ty_u32);
+        t = ast::ty_machine(ast::ty_u32);
     } else if (eat_word(p, "u64")) {
-        t = ast::ty_machine(common::ty_u64);
+        t = ast::ty_machine(ast::ty_u64);
     } else if (eat_word(p, "f32")) {
-        t = ast::ty_machine(common::ty_f32);
+        t = ast::ty_machine(ast::ty_f32);
     } else if (eat_word(p, "f64")) {
-        t = ast::ty_machine(common::ty_f64);
+        t = ast::ty_machine(ast::ty_f64);
     } else if (p.peek() == token::LPAREN) {
         p.bump();
         alt (p.peek()) {
@@ -541,9 +545,7 @@ fn parse_ty(&parser p) -> @ast::ty {
         hi = p.get_hi_pos();
         expect(p, token::RBRACKET);
     } else if (eat_word(p, "mutable")) {
-        p.get_session().span_warn(p.get_span(),
-                                  "ignoring deprecated 'mutable'"
-                                  + " type constructor");
+        p.warn("ignoring deprecated 'mutable' type constructor");
         auto typ = parse_ty(p);
         t = typ.node;
         hi = typ.span.hi;
@@ -585,7 +587,7 @@ fn parse_seq_to_end[T](token::token ket, option::t[token::token] sep,
 
 fn parse_seq[T](token::token bra, token::token ket,
                 option::t[token::token] sep, fn(&parser) -> T  f, &parser p)
-   -> util::common::spanned[vec[T]] {
+   -> ast::spanned[vec[T]] {
     auto lo = p.get_lo_pos();
     expect(p, bra);
     auto result = parse_seq_to_end[T](ket, sep, f, p);
@@ -764,8 +766,7 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
                 ex = ast::expr_lit(lit);
             }
             case (_) {
-                p.get_session().span_unimpl(p.get_span(),
-                                            "unique pointer creation");
+                p.fatal("unimplemented: unique pointer creation");
             }
         }
     } else if (eat_word(p, "obj")) {
@@ -971,21 +972,21 @@ fn parse_syntax_ext_naked(&parser p, uint lo) -> @ast::expr {
  * wish to use while bootstrapping. The eventual aim is to permit
  * loading rust crates to process extensions.
  */
-fn expand_syntax_ext(&parser p, common::span sp, &ast::path path,
+fn expand_syntax_ext(&parser p, span sp, &ast::path path,
                      vec[@ast::expr] args, option::t[str] body) ->
    ast::expr_ {
     assert (vec::len(path.node.idents) > 0u);
     auto extname = path.node.idents.(0);
     alt (p.get_syntax_expanders().find(extname)) {
         case (none) { p.fatal("unknown syntax expander: '" + extname + "'"); }
-        case (some(ext::normal(?ext))) {
-            auto ext_cx = ext::mk_ctxt(p);
+        case (some(ex::normal(?ext))) {
+            auto ext_cx = ex::mk_ctxt(p.get_sess());
             ret ast::expr_ext(path, args, body, ext(ext_cx, sp, args, body));
         }
         // because we have expansion inside parsing, new macros are only
         // visible further down the file
-        case (some(ext::macro_defining(?ext))) {
-            auto ext_cx = ext::mk_ctxt(p);
+        case (some(ex::macro_defining(?ext))) {
+            auto ext_cx = ex::mk_ctxt(p.get_sess());
             auto name_and_extension = ext(ext_cx, sp, args, body);
             p.get_syntax_expanders().insert(name_and_extension._0,
                                             name_and_extension._1);
@@ -1049,9 +1050,7 @@ fn parse_dot_or_call_expr_with(&parser p, @ast::expr e) -> @ast::expr {
 
 fn parse_prefix_expr(&parser p) -> @ast::expr {
     if (eat_word(p, "mutable")) {
-        p.get_session().span_warn(p.get_span(),
-                                  "ignoring deprecated 'mutable'"
-                                  + " prefix operator");
+        p.warn("ignoring deprecated 'mutable' prefix operator");
     }
     auto lo = p.get_lo_pos();
     auto hi = p.get_hi_pos();
@@ -1676,7 +1675,7 @@ fn parse_ty_params(&parser p) -> vec[ast::ty_param] {
 }
 
 fn parse_fn_decl(&parser p, ast::purity purity) -> ast::fn_decl {
-    let util::common::spanned[vec[ast::arg]] inputs =
+    let ast::spanned[vec[ast::arg]] inputs =
         parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA), parse_arg,
                   p);
     let ty_or_bang rslt;
@@ -1784,7 +1783,7 @@ fn parse_item_obj(&parser p, ast::layer lyr, vec[ast::attribute] attrs) ->
     auto lo = p.get_last_lo_pos();
     auto ident = parse_value_ident(p);
     auto ty_params = parse_ty_params(p);
-    let util::common::spanned[vec[ast::obj_field]] fields =
+    let ast::spanned[vec[ast::obj_field]] fields =
         parse_seq[ast::obj_field](token::LPAREN, token::RPAREN,
                                   some(token::COMMA), parse_obj_field, p);
     let vec[@ast::method] meths = [];
@@ -2320,7 +2319,10 @@ fn parse_native_view(&parser p) -> vec[@ast::view_item] {
     ret items;
 }
 
-fn parse_crate_from_source_file(&parser p) -> @ast::crate {
+fn parse_crate_from_source_file(&str input, &ast::crate_cfg cfg,
+                                &codemap::codemap cm) -> @ast::crate {
+    auto sess = @rec(cm=cm, mutable next_id=0);
+    auto p = new_parser(sess, cfg, input, 0u);
     auto lo = p.get_lo_pos();
     auto crate_attrs = parse_inner_attrs_and_next(p);
     auto first_item_outer_attrs = crate_attrs._1;
@@ -2428,7 +2430,10 @@ fn parse_crate_directives(&parser p, token::token term,
     ret cdirs;
 }
 
-fn parse_crate_from_crate_file(&parser p) -> @ast::crate {
+fn parse_crate_from_crate_file(&str input, &ast::crate_cfg cfg,
+                               &codemap::codemap cm) -> @ast::crate {
+    auto sess = @rec(cm=cm, mutable next_id=0);
+    auto p = new_parser(sess, cfg, input, 0u);
     auto lo = p.get_lo_pos();
     auto prefix = std::fs::dirname(p.get_filemap().name);
     auto leading_attrs = parse_inner_attrs_and_next(p);
@@ -2436,14 +2441,12 @@ fn parse_crate_from_crate_file(&parser p) -> @ast::crate {
     auto first_cdir_attr = leading_attrs._1;
     auto cdirs = parse_crate_directives(p, token::EOF, first_cdir_attr);
     let vec[str] deps = [];
-    auto cx =
-        @rec(p=p,
-             mode=eval::mode_parse,
-             mutable deps=deps,
-             sess=p.get_session(),
-             mutable chpos=p.get_chpos(),
-             mutable next_id=p.next_id(),
-             cfg = p.get_cfg());
+    auto cx = @rec(p=p,
+                   mode=eval::mode_parse,
+                   mutable deps=deps,
+                   sess=sess,
+                   mutable chpos=p.get_chpos(),
+                   cfg = p.get_cfg());
     auto m =
         eval::eval_crate_directives_to_mod(cx, cdirs, prefix);
     auto hi = p.get_hi_pos();
diff --git a/src/comp/front/token.rs b/src/comp/syntax/parse/token.rs
index 664a5db5e82..b8ea07d50db 100644
--- a/src/comp/front/token.rs
+++ b/src/comp/syntax/parse/token.rs
@@ -1,8 +1,8 @@
 
-import util::common::ty_mach;
-import util::common::ty_mach_to_str;
-import util::common::new_str_hash;
-import util::data::interner;
+import ast::ty_mach;
+import ast::ty_mach_to_str;
+import _std::new_str_hash;
+import util::interner;
 import std::int;
 import std::uint;
 import std::str;
diff --git a/src/comp/pretty/pp.rs b/src/comp/syntax/print/pp.rs
index ef3a87585c4..ef3a87585c4 100644
--- a/src/comp/pretty/pp.rs
+++ b/src/comp/syntax/print/pp.rs
diff --git a/src/comp/pretty/pprust.rs b/src/comp/syntax/print/pprust.rs
index 104362aa26e..b146d703471 100644
--- a/src/comp/pretty/pprust.rs
+++ b/src/comp/syntax/print/pprust.rs
@@ -5,12 +5,11 @@ import std::vec;
 import std::str;
 import std::io;
 import std::option;
-import driver::session::session;
-import front::lexer;
-import front::codemap;
-import front::codemap::codemap;
-import front::ast;
-import util::common;
+import parse::lexer;
+import syntax::codemap::codemap;
+import ast;
+import _std::istr;
+import _std::uistr;
 import option::some;
 import option::none;
 import pp::printer;
@@ -25,15 +24,63 @@ import pp::breaks;
 import pp::consistent;
 import pp::inconsistent;
 import pp::eof;
-import ppaux::*;
 
-fn print_crate(session sess, @ast::crate crate, str filename,
+// The ps is stored here to prevent recursive type.
+// FIXME use a nominal tag instead
+tag ann_node {
+    node_block(ps, ast::block);
+    node_item(ps, @ast::item);
+    node_expr(ps, @ast::expr);
+    node_pat(ps, @ast::pat);
+}
+type pp_ann = rec(fn(&ann_node node) pre,
+                  fn(&ann_node node) post);
+
+fn no_ann() -> pp_ann {
+    fn ignore(&ann_node node) {}
+    ret rec(pre=ignore, post=ignore);
+}
+
+type ps =
+    @rec(pp::printer s,
+         option::t[codemap] cm,
+         option::t[vec[lexer::cmnt]] comments,
+         option::t[vec[lexer::lit]] literals,
+         mutable uint cur_cmnt,
+         mutable uint cur_lit,
+         mutable vec[pp::breaks] boxes,
+         pp_ann ann);
+
+fn ibox(&ps s, uint u) {
+    vec::push(s.boxes, pp::inconsistent);
+    pp::ibox(s.s, u);
+}
+
+fn end(&ps s) { vec::pop(s.boxes); pp::end(s.s); }
+
+fn rust_printer(io::writer writer) -> ps {
+    let vec[pp::breaks] boxes = [];
+    ret @rec(s=pp::mk_printer(writer, default_columns),
+             cm=none[codemap],
+             comments=none[vec[lexer::cmnt]],
+             literals=none[vec[lexer::lit]],
+             mutable cur_cmnt=0u,
+             mutable cur_lit=0u,
+             mutable boxes=boxes,
+             ann=no_ann());
+}
+
+const uint indent_unit = 4u;
+
+const uint default_columns = 78u;
+
+fn print_crate(&codemap cm, @ast::crate crate, str filename,
                io::writer out, &pp_ann ann) {
     let vec[pp::breaks] boxes = [];
-    auto r = lexer::gather_comments_and_literals(sess, filename);
+    auto r = lexer::gather_comments_and_literals(cm, filename);
     auto s =
         @rec(s=pp::mk_printer(out, default_columns),
-             cm=some(sess.get_codemap()),
+             cm=some(cm),
              comments=some(r.cmnts),
              literals=some(r.lits),
              mutable cur_cmnt=0u,
@@ -119,7 +166,7 @@ fn bopen(&ps s) {
 
 }
 
-fn bclose(&ps s, common::span span) {
+fn bclose(&ps s, codemap::span span) {
     maybe_print_comment(s, span.hi);
     break_offset(s.s, 1u, -(indent_unit as int));
     word(s.s, "}");
@@ -161,7 +208,7 @@ fn commasep[IN](&ps s, breaks b, vec[IN] elts, fn(&ps, &IN)  op) {
 }
 
 fn commasep_cmnt[IN](&ps s, breaks b, vec[IN] elts, fn(&ps, &IN)  op,
-                     fn(&IN) -> common::span  get_span) {
+                     fn(&IN) -> codemap::span  get_span) {
     box(s, 0u, b);
     auto len = vec::len[IN](elts);
     auto i = 0u;
@@ -180,7 +227,7 @@ fn commasep_cmnt[IN](&ps s, breaks b, vec[IN] elts, fn(&ps, &IN)  op,
 }
 
 fn commasep_exprs(&ps s, breaks b, vec[@ast::expr] exprs) {
-    fn expr_span(&@ast::expr expr) -> common::span { ret expr.span; }
+    fn expr_span(&@ast::expr expr) -> codemap::span { ret expr.span; }
     commasep_cmnt(s, b, exprs, print_expr, expr_span);
 }
 
@@ -208,7 +255,7 @@ fn print_type(&ps s, &ast::ty ty) {
         case (ast::ty_int) { word(s.s, "int"); }
         case (ast::ty_uint) { word(s.s, "uint"); }
         case (ast::ty_float) { word(s.s, "float"); }
-        case (ast::ty_machine(?tm)) { word(s.s, common::ty_mach_to_str(tm)); }
+        case (ast::ty_machine(?tm)) { word(s.s, ast::ty_mach_to_str(tm)); }
         case (ast::ty_char) { word(s.s, "char"); }
         case (ast::ty_str) { word(s.s, "str"); }
         case (ast::ty_istr) { word(s.s, "istr"); }
@@ -257,7 +304,7 @@ fn print_type(&ps s, &ast::ty ty) {
                 word(s.s, f.node.ident);
                 end(s);
             }
-            fn get_span(&ast::ty_field f) -> common::span { ret f.span; }
+            fn get_span(&ast::ty_field f) -> codemap::span { ret f.span; }
             commasep_cmnt(s, consistent, fields, print_field, get_span);
             pclose(s);
         }
@@ -435,7 +482,7 @@ fn print_item(&ps s, &@ast::item item) {
                 word(s.s, field.ident);
                 end(s);
             }
-            fn get_span(&ast::obj_field f) -> common::span { ret f.ty.span; }
+            fn get_span(&ast::obj_field f) -> codemap::span { ret f.ty.span; }
             commasep_cmnt(s, consistent, _obj.fields, print_field, get_span);
             pclose(s);
             space(s.s);
@@ -517,7 +564,7 @@ fn print_stmt(&ps s, &ast::stmt st) {
             print_expr(s, expr);
         }
     }
-    if (front::parser::stmt_ends_with_semi(st)) { word(s.s, ";"); }
+    if (parse::parser::stmt_ends_with_semi(st)) { word(s.s, ";"); }
     maybe_print_trailing_comment(s, st.span, none[uint]);
 }
 
@@ -605,7 +652,7 @@ fn print_expr(&ps s, &@ast::expr expr) {
                 print_expr(s, elt.expr);
                 end(s);
             }
-            fn get_span(&ast::elt elt) -> common::span { ret elt.expr.span; }
+            fn get_span(&ast::elt elt) -> codemap::span { ret elt.expr.span; }
             word(s.s, "tup");
             popen(s);
             commasep_cmnt(s, inconsistent, exprs, printElt, get_span);
@@ -620,7 +667,9 @@ fn print_expr(&ps s, &@ast::expr expr) {
                 print_expr(s, field.node.expr);
                 end(s);
             }
-            fn get_span(&ast::field field) -> common::span { ret field.span; }
+            fn get_span(&ast::field field) -> codemap::span {
+                ret field.span;
+            }
             word(s.s, "rec");
             popen(s);
             commasep_cmnt(s, consistent, fields, print_field, get_span);
@@ -675,11 +724,11 @@ fn print_expr(&ps s, &@ast::expr expr) {
         }
         case (ast::expr_unary(?op, ?expr)) {
             word(s.s, ast::unop_to_str(op));
-            print_maybe_parens(s, expr, front::parser::unop_prec);
+            print_maybe_parens(s, expr, parse::parser::unop_prec);
         }
         case (ast::expr_lit(?lit)) { print_literal(s, lit); }
         case (ast::expr_cast(?expr, ?ty)) {
-            print_maybe_parens(s, expr, front::parser::as_prec);
+            print_maybe_parens(s, expr, parse::parser::as_prec);
             space(s.s);
             word_space(s, "as");
             print_type(s, *ty);
@@ -1114,7 +1163,7 @@ fn print_view_item(&ps s, &@ast::view_item item) {
 // FIXME: The fact that this builds up the table anew for every call is
 // not good. Eventually, table should be a const.
 fn operator_prec(ast::binop op) -> int {
-    for (front::parser::op_spec spec in front::parser::prec_table()) {
+    for (parse::parser::op_spec spec in parse::parser::prec_table()) {
         if (spec.op == op) { ret spec.prec; }
     }
     fail;
@@ -1127,10 +1176,10 @@ fn print_maybe_parens(&ps s, &@ast::expr expr, int outer_prec) {
             add_them = operator_prec(op) < outer_prec;
         }
         case (ast::expr_cast(_, _)) {
-            add_them = front::parser::as_prec < outer_prec;
+            add_them = parse::parser::as_prec < outer_prec;
         }
         case (ast::expr_ternary(_, _, _)) {
-            add_them = front::parser::ternary_prec < outer_prec;
+            add_them = parse::parser::ternary_prec < outer_prec;
         }
         case (_) { add_them = false; }
     }
@@ -1186,7 +1235,7 @@ fn print_ty_fn(&ps s, &ast::proto proto, &option::t[str] id,
     end(s);
 }
 
-fn maybe_print_trailing_comment(&ps s, common::span span,
+fn maybe_print_trailing_comment(&ps s, codemap::span span,
                                 option::t[uint] next_pos) {
     auto cm;
     alt (s.cm) { case (some(?ccm)) { cm = ccm; } case (_) { ret; } }
@@ -1221,6 +1270,197 @@ fn in_cbox(&ps s) -> bool {
     if (len == 0u) { ret false; }
     ret s.boxes.(len - 1u) == pp::consistent;
 }
+
+fn print_literal(&ps s, &@ast::lit lit) {
+    maybe_print_comment(s, lit.span.lo);
+    alt (next_lit(s)) {
+        case (some(?lt)) {
+            if (lt.pos == lit.span.lo) {
+                word(s.s, lt.lit);
+                s.cur_lit += 1u;
+                ret;
+            }
+        }
+        case (_) { }
+    }
+    alt (lit.node) {
+        case (ast::lit_str(?st, ?kind)) {
+            if (kind == ast::sk_unique) { word(s.s, "~"); }
+            print_string(s, st);
+        }
+        case (ast::lit_char(?ch)) {
+            word(s.s,
+                 "'" + escape_str(str::from_bytes([ch as u8]), '\'') + "'");
+        }
+        case (ast::lit_int(?val)) { word(s.s, istr(val)); }
+        case (ast::lit_uint(?val)) { word(s.s, uistr(val) + "u"); }
+        case (ast::lit_float(?fstr)) { word(s.s, fstr); }
+        case (ast::lit_mach_int(?mach, ?val)) {
+            word(s.s, istr(val as int));
+            word(s.s, ast::ty_mach_to_str(mach));
+        }
+        case (ast::lit_mach_float(?mach, ?val)) {
+            // val is already a str
+            word(s.s, val);
+            word(s.s, ast::ty_mach_to_str(mach));
+        }
+        case (ast::lit_nil) { word(s.s, "()"); }
+        case (ast::lit_bool(?val)) {
+            if (val) { word(s.s, "true"); } else { word(s.s, "false"); }
+        }
+    }
+}
+
+fn lit_to_str(&@ast::lit l) -> str { be to_str(l, print_literal); }
+
+fn next_lit(&ps s) -> option::t[lexer::lit] {
+    alt (s.literals) {
+        case (some(?lits)) {
+            if (s.cur_lit < vec::len(lits)) {
+                ret some(lits.(s.cur_lit));
+            } else { ret none[lexer::lit]; }
+        }
+        case (_) { ret none[lexer::lit]; }
+    }
+}
+
+fn maybe_print_comment(&ps s, uint pos) {
+    while (true) {
+        alt (next_comment(s)) {
+            case (some(?cmnt)) {
+                if (cmnt.pos < pos) {
+                    print_comment(s, cmnt);
+                    s.cur_cmnt += 1u;
+                } else { break; }
+            }
+            case (_) { break; }
+        }
+    }
+}
+
+fn print_comment(&ps s, lexer::cmnt cmnt) {
+    alt (cmnt.style) {
+        case (lexer::mixed) {
+            assert (vec::len(cmnt.lines) == 1u);
+            zerobreak(s.s);
+            word(s.s, cmnt.lines.(0));
+            zerobreak(s.s);
+        }
+        case (lexer::isolated) {
+            pprust::hardbreak_if_not_bol(s);
+            for (str line in cmnt.lines) { word(s.s, line); hardbreak(s.s); }
+        }
+        case (lexer::trailing) {
+            word(s.s, " ");
+            if (vec::len(cmnt.lines) == 1u) {
+                word(s.s, cmnt.lines.(0));
+                hardbreak(s.s);
+            } else {
+                ibox(s, 0u);
+                for (str line in cmnt.lines) {
+                    word(s.s, line);
+                    hardbreak(s.s);
+                }
+                end(s);
+            }
+        }
+        case (lexer::blank_line) {
+            // We need to do at least one, possibly two hardbreaks.
+            pprust::hardbreak_if_not_bol(s);
+            hardbreak(s.s);
+        }
+    }
+}
+
+fn print_string(&ps s, &str st) {
+    word(s.s, "\"");
+    word(s.s, escape_str(st, '"'));
+    word(s.s, "\"");
+}
+
+fn escape_str(str st, char to_escape) -> str {
+    let str out = "";
+    auto len = str::byte_len(st);
+    auto i = 0u;
+    while (i < len) {
+        alt (st.(i) as char) {
+            case ('\n') { out += "\\n"; }
+            case ('\t') { out += "\\t"; }
+            case ('\r') { out += "\\r"; }
+            case ('\\') { out += "\\\\"; }
+            case (?cur) {
+                if (cur == to_escape) { out += "\\"; }
+                // FIXME some (or all?) non-ascii things should be escaped
+
+                str::push_char(out, cur);
+            }
+        }
+        i += 1u;
+    }
+    ret out;
+}
+
+fn to_str[T](&T t, fn(&ps, &T)  f) -> str {
+    auto writer = io::string_writer();
+    auto s = rust_printer(writer.get_writer());
+    f(s, t);
+    eof(s.s);
+    ret writer.get_str();
+}
+
+fn next_comment(&ps s) -> option::t[lexer::cmnt] {
+    alt (s.comments) {
+        case (some(?cmnts)) {
+            if (s.cur_cmnt < vec::len(cmnts)) {
+                ret some(cmnts.(s.cur_cmnt));
+            } else { ret none[lexer::cmnt]; }
+        }
+        case (_) { ret none[lexer::cmnt]; }
+    }
+}
+
+
+fn constr_args_to_str[T](fn(&T) -> str  f,
+                         &vec[@ast::constr_arg_general[T]] args) -> str {
+    auto comma = false;
+    auto s = "(";
+    for (@ast::constr_arg_general[T] a in args) {
+        if (comma) { s += ", "; } else { comma = true; }
+        s += constr_arg_to_str[T](f, a.node);
+    }
+    s += ")";
+    ret s;
+}
+
+fn constr_arg_to_str[T](fn(&T) -> str  f, &ast::constr_arg_general_[T] c) ->
+   str {
+    alt (c) {
+        case (ast::carg_base) { ret "*"; }
+        case (ast::carg_ident(?i)) { ret f(i); }
+        case (ast::carg_lit(?l)) { ret lit_to_str(l); }
+    }
+}
+
+// needed b/c constr_args_to_str needs
+// something that takes an alias
+// (argh)
+fn uint_to_str(&uint i) -> str { ret uistr(i); }
+
+fn ast_constr_to_str(&@ast::constr c) -> str {
+    ret ast::path_to_str(c.node.path) +
+            constr_args_to_str(uint_to_str, c.node.args);
+}
+
+fn ast_constrs_str(&vec[@ast::constr] constrs) -> str {
+    auto s = "";
+    auto colon = true;
+    for (@ast::constr c in constrs) {
+        if (colon) { s += " : "; colon = false; } else { s += ", "; }
+        s += ast_constr_to_str(c);
+    }
+    ret s;
+}
+
 //
 // Local Variables:
 // mode: rust
diff --git a/src/comp/syntax/util/interner.rs b/src/comp/syntax/util/interner.rs
new file mode 100644
index 00000000000..e096b953a89
--- /dev/null
+++ b/src/comp/syntax/util/interner.rs
@@ -0,0 +1,35 @@
+// An "interner" is a data structure that associates values with uint tags and
+// allows bidirectional lookup; i.e. given a value, one can easily find the
+// type, and vice versa.
+import std::vec;
+import std::map;
+import std::map::hashmap;
+import std::map::hashfn;
+import std::map::eqfn;
+import std::option;
+import std::option::none;
+import std::option::some;
+
+type interner[T] =
+    rec(hashmap[T, uint] map,
+        mutable vec[T] vect,
+        hashfn[T] hasher,
+        eqfn[T] eqer);
+
+fn mk[T](hashfn[T] hasher, eqfn[T] eqer) -> interner[T] {
+    auto m = map::mk_hashmap[T, uint](hasher, eqer);
+    let vec[T] vect = [];
+    ret rec(map=m, mutable vect=vect, hasher=hasher, eqer=eqer);
+}
+fn intern[T](&interner[T] itr, &T val) -> uint {
+    alt (itr.map.find(val)) {
+        case (some(?idx)) { ret idx; }
+        case (none) {
+            auto new_idx = vec::len[T](itr.vect);
+            itr.map.insert(val, new_idx);
+            itr.vect += [val];
+            ret new_idx;
+        }
+    }
+}
+fn get[T](&interner[T] itr, uint idx) -> T { ret itr.vect.(idx); }
diff --git a/src/comp/middle/visit.rs b/src/comp/syntax/visit.rs
index c87373c4ff8..a709814a9a3 100644
--- a/src/comp/middle/visit.rs
+++ b/src/comp/syntax/visit.rs
@@ -1,10 +1,9 @@
 
-import front::ast::*;
+import ast::*;
 import std::option;
 import std::option::some;
 import std::option::none;
-import util::common::span;
-import util::common::respan;
+import codemap::span;
 
 
 // Context-passing AST walker. Each overridden visit method has full control
diff --git a/src/comp/middle/walk.rs b/src/comp/syntax/walk.rs
index 598c6d68f78..79e8ca6dca6 100644
--- a/src/comp/middle/walk.rs
+++ b/src/comp/syntax/walk.rs
@@ -1,11 +1,11 @@
 
-import front::ast;
-import middle::ty::ty_param;
+import ast;
+import ast::ty_param;
+import ast::respan;
 import std::option;
 import std::option::some;
 import std::option::none;
-import util::common::span;
-import util::common::respan;
+import codemap::span;
 
 type ast_visitor =
     rec(fn() -> bool  keep_going,
diff --git a/src/comp/util/common.rs b/src/comp/util/common.rs
index 9eca5c1f9b5..cf50c2fbc73 100644
--- a/src/comp/util/common.rs
+++ b/src/comp/util/common.rs
@@ -7,70 +7,30 @@ import std::vec;
 import std::option;
 import std::option::none;
 import std::option::some;
-import front::ast;
-import front::ast::ty;
-import front::ast::pat;
-import front::codemap::codemap;
-import front::ast::lit;
-import front::ast::path;
-import middle::walk;
+import syntax::ast;
+import ast::ty;
+import ast::pat;
+import syntax::codemap::codemap;
+import syntax::codemap::span;
+import ast::lit;
+import ast::path;
+import syntax::walk;
 import std::io::stdout;
 import std::io::str_writer;
 import std::io::string_writer;
-import pretty::pprust::print_block;
-import pretty::pprust::print_item;
-import pretty::pprust::print_expr;
-import pretty::pprust::print_path;
-import pretty::pprust::print_decl;
-import pretty::pprust::print_fn;
-import pretty::pprust::print_type;
-import pretty::ppaux::print_literal;
-import pretty::pp::mk_printer;
-
-type filename = str;
-
-type span = rec(uint lo, uint hi);
-
-type spanned[T] = rec(T node, span span);
+import syntax::print;
+import print::pprust::print_block;
+import print::pprust::print_item;
+import print::pprust::print_expr;
+import print::pprust::print_path;
+import print::pprust::print_decl;
+import print::pprust::print_fn;
+import print::pprust::print_type;
+import print::pprust::print_literal;
+import print::pp::mk_printer;
 
 type flag = hashmap[str, ()];
 
-tag ty_mach {
-    ty_i8;
-    ty_i16;
-    ty_i32;
-    ty_i64;
-    ty_u8;
-    ty_u16;
-    ty_u32;
-    ty_u64;
-    ty_f32;
-    ty_f64;
-}
-
-tag ty_or_bang[T] { a_ty(T); a_bang; }
-
-fn ty_mach_to_str(ty_mach tm) -> str {
-    alt (tm) {
-        case (ty_u8) { ret "u8"; }
-        case (ty_u16) { ret "u16"; }
-        case (ty_u32) { ret "u32"; }
-        case (ty_u64) { ret "u64"; }
-        case (ty_i8) { ret "i8"; }
-        case (ty_i16) { ret "i16"; }
-        case (ty_i32) { ret "i32"; }
-        case (ty_i64) { ret "i64"; }
-        case (ty_f32) { ret "f32"; }
-        case (ty_f64) { ret "f64"; }
-    }
-}
-
-fn new_str_hash[V]() -> std::map::hashmap[str, V] {
-    let std::map::hashfn[str] hasher = std::str::hash;
-    let std::map::eqfn[str] eqer = std::str::eq;
-    ret std::map::mk_hashmap[str, V](hasher, eqer);
-}
-
 fn def_eq(&ast::def_id a, &ast::def_id b) -> bool {
     ret a._0 == b._0 && a._1 == b._1;
 }
@@ -88,26 +48,6 @@ fn new_def_hash[V]() -> std::map::hashmap[ast::def_id, V] {
     ret std::map::mk_hashmap[ast::def_id, V](hasher, eqer);
 }
 
-fn new_int_hash[V]() -> std::map::hashmap[int, V] {
-    fn hash_int(&int x) -> uint { ret x as uint; }
-    fn eq_int(&int a, &int b) -> bool { ret a == b; }
-    auto hasher = hash_int;
-    auto eqer = eq_int;
-    ret std::map::mk_hashmap[int, V](hasher, eqer);
-}
-
-fn new_uint_hash[V]() -> std::map::hashmap[uint, V] {
-    fn hash_uint(&uint x) -> uint { ret x; }
-    fn eq_uint(&uint a, &uint b) -> bool { ret a == b; }
-    auto hasher = hash_uint;
-    auto eqer = eq_uint;
-    ret std::map::mk_hashmap[uint, V](hasher, eqer);
-}
-
-fn istr(int i) -> str { ret int::to_str(i, 10u); }
-
-fn uistr(uint i) -> str { ret uint::to_str(i, 10u); }
-
 fn elt_expr(&ast::elt e) -> @ast::expr { ret e.expr; }
 
 fn elt_exprs(&vec[ast::elt] elts) -> vec[@ast::expr] {
@@ -122,31 +62,31 @@ fn field_exprs(vec[ast::field] fields) -> vec[@ast::expr] {
     ret vec::map[ast::field, @ast::expr](f, fields);
 }
 
-fn log_expr(&ast::expr e) { log pretty::pprust::expr_to_str(@e); }
+fn log_expr(&ast::expr e) { log print::pprust::expr_to_str(@e); }
 
-fn log_expr_err(&ast::expr e) { log_err pretty::pprust::expr_to_str(@e); }
+fn log_expr_err(&ast::expr e) { log_err print::pprust::expr_to_str(@e); }
 
-fn log_ty_err(&ty t) { log_err pretty::pprust::ty_to_str(t); }
+fn log_ty_err(&ty t) { log_err print::pprust::ty_to_str(t); }
 
-fn log_pat_err(&@pat p) { log_err pretty::pprust::pat_to_str(p); }
+fn log_pat_err(&@pat p) { log_err print::pprust::pat_to_str(p); }
 
-fn log_block(&ast::block b) { log pretty::pprust::block_to_str(b); }
+fn log_block(&ast::block b) { log print::pprust::block_to_str(b); }
 
-fn log_block_err(&ast::block b) { log_err pretty::pprust::block_to_str(b); }
+fn log_block_err(&ast::block b) { log_err print::pprust::block_to_str(b); }
 
-fn log_item_err(&@ast::item i) { log_err pretty::pprust::item_to_str(i); }
+fn log_item_err(&@ast::item i) { log_err print::pprust::item_to_str(i); }
 
 fn log_fn(&ast::_fn f, str name, vec[ast::ty_param] params) {
-    log pretty::pprust::fun_to_str(f, name, params);
+    log print::pprust::fun_to_str(f, name, params);
 }
 
 fn log_fn_err(&ast::_fn f, str name, vec[ast::ty_param] params) {
-    log_err pretty::pprust::fun_to_str(f, name, params);
+    log_err print::pprust::fun_to_str(f, name, params);
 }
 
-fn log_stmt(&ast::stmt st) { log pretty::pprust::stmt_to_str(st); }
+fn log_stmt(&ast::stmt st) { log print::pprust::stmt_to_str(st); }
 
-fn log_stmt_err(&ast::stmt st) { log_err pretty::pprust::stmt_to_str(st); }
+fn log_stmt_err(&ast::stmt st) { log_err print::pprust::stmt_to_str(st); }
 
 fn has_nonlocal_exits(&ast::block b) -> bool {
     auto has_exits = @mutable false;
@@ -232,27 +172,6 @@ fn lit_eq(&@ast::lit l, &@ast::lit m) -> bool {
     }
 }
 
-fn respan[T](&span sp, &T t) -> spanned[T] { ret rec(node=t, span=sp); }
-
-fn may_begin_ident(char c) -> bool { ret is_alpha(c) || c == '_'; }
-
-fn in_range(char c, char lo, char hi) -> bool { ret lo <= c && c <= hi; }
-
-fn is_alpha(char c) -> bool {
-    ret in_range(c, 'a', 'z') || in_range(c, 'A', 'Z');
-}
-
-fn is_dec_digit(char c) -> bool { ret in_range(c, '0', '9'); }
-
-fn is_alnum(char c) -> bool { ret is_alpha(c) || is_dec_digit(c); }
-
-fn is_hex_digit(char c) -> bool {
-    ret in_range(c, '0', '9') || in_range(c, 'a', 'f') ||
-            in_range(c, 'A', 'F');
-}
-
-fn is_bin_digit(char c) -> bool { ret c == '0' || c == '1'; }
-
 // FIXME move to vec
 fn any[T](&fn(&T) -> bool f, &vec[T] v) -> bool {
     for (T t in v) {
diff --git a/src/comp/util/data.rs b/src/comp/util/data.rs
deleted file mode 100644
index 5ff3cf68678..00000000000
--- a/src/comp/util/data.rs
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
-// An "interner" is a data structure that associates values with uint tags and
-// allows bidirectional lookup; i.e. given a value, one can easily find the
-// type, and vice versa.
-import std::vec;
-import std::map;
-import std::map::hashmap;
-import std::map::hashfn;
-import std::map::eqfn;
-import std::option;
-import std::option::none;
-import std::option::some;
-
-mod interner {
-    type interner[T] =
-        rec(hashmap[T, uint] map,
-            mutable vec[T] vect,
-            hashfn[T] hasher,
-            eqfn[T] eqer);
-
-    fn mk[T](hashfn[T] hasher, eqfn[T] eqer) -> interner[T] {
-        auto m = map::mk_hashmap[T, uint](hasher, eqer);
-        let vec[T] vect = [];
-        ret rec(map=m, mutable vect=vect, hasher=hasher, eqer=eqer);
-    }
-    fn intern[T](&interner[T] itr, &T val) -> uint {
-        alt (itr.map.find(val)) {
-            case (some(?idx)) { ret idx; }
-            case (none) {
-                auto new_idx = vec::len[T](itr.vect);
-                itr.map.insert(val, new_idx);
-                itr.vect += [val];
-                ret new_idx;
-            }
-        }
-    }
-    fn get[T](&interner[T] itr, uint idx) -> T { ret itr.vect.(idx); }
-}
diff --git a/src/comp/util/ppaux.rs b/src/comp/util/ppaux.rs
new file mode 100644
index 00000000000..4adc6c437db
--- /dev/null
+++ b/src/comp/util/ppaux.rs
@@ -0,0 +1,182 @@
+import std::io;
+import std::vec;
+import std::str;
+import std::option;
+import std::option::none;
+import std::option::some;
+import middle::ty;
+import middle::ty::*;
+import syntax::print::pp;
+import syntax::print::pprust;
+import pp::word;
+import pp::eof;
+import pp::zerobreak;
+import pp::hardbreak;
+import syntax::_std::istr;
+import syntax::_std::uistr;
+import ast::ty_mach_to_str;
+import syntax::ast;
+
+fn mode_str(&ty::mode m) -> str {
+    alt (m) {
+        case (mo_val) { "" }
+        case (mo_alias(false)) { "&" }
+        case (mo_alias(true)) { "&mutable " }
+    }
+}
+
+fn mode_str_1(&ty::mode m) -> str {
+    alt (m) {
+        case (mo_val) { "val" }
+        case (_)      { mode_str(m) }
+    }
+}
+
+fn fn_ident_to_string(ast::node_id id, &ast::fn_ident i) -> str {
+    ret alt (i) {
+        case (none) { "anon" + istr(id) }
+        case (some(?s)) { s }
+    };
+}
+
+fn ty_to_str(&ctxt cx, &t typ) -> str {
+    fn fn_input_to_str(&ctxt cx, &rec(middle::ty::mode mode, t ty) input) ->
+       str {
+        auto s = mode_str(input.mode);
+        ret s + ty_to_str(cx, input.ty);
+    }
+    fn fn_to_str(&ctxt cx, ast::proto proto, option::t[ast::ident] ident,
+                 &arg[] inputs, t output, ast::controlflow cf,
+                 &vec[@constr_def] constrs) -> str {
+        auto s;
+        alt (proto) {
+            case (ast::proto_iter) { s = "iter"; }
+            case (ast::proto_fn) { s = "fn"; }
+        }
+        alt (ident) { case (some(?i)) { s += " "; s += i; } case (_) { } }
+        s += "(";
+        auto strs = [];
+        for (arg a in inputs) { strs += [fn_input_to_str(cx, a)]; }
+        s += str::connect(strs, ", ");
+        s += ")";
+        if (struct(cx, output) != ty_nil) {
+            alt (cf) {
+                case (ast::noreturn) { s += " -> !"; }
+                case (ast::return) { s += " -> " + ty_to_str(cx, output); }
+            }
+        }
+        s += constrs_str(constrs);
+        ret s;
+    }
+    fn method_to_str(&ctxt cx, &method m) -> str {
+        ret fn_to_str(cx, m.proto, some[ast::ident](m.ident), m.inputs,
+                      m.output, m.cf, m.constrs) + ";";
+    }
+    fn field_to_str(&ctxt cx, &field f) -> str {
+        ret mt_to_str(cx, f.mt) + " " + f.ident;
+    }
+    fn mt_to_str(&ctxt cx, &mt m) -> str {
+        auto mstr;
+        alt (m.mut) {
+            case (ast::mut) { mstr = "mutable "; }
+            case (ast::imm) { mstr = ""; }
+            case (ast::maybe_mut) { mstr = "mutable? "; }
+        }
+        ret mstr + ty_to_str(cx, m.ty);
+    }
+    alt (cname(cx, typ)) { case (some(?cs)) { ret cs; } case (_) { } }
+    auto s = "";
+    alt (struct(cx, typ)) {
+        case (ty_native(_)) { s += "native"; }
+        case (ty_nil) { s += "()"; }
+        case (ty_bot) { s += "_|_"; }
+        case (ty_bool) { s += "bool"; }
+        case (ty_int) { s += "int"; }
+        case (ty_float) { s += "float"; }
+        case (ty_uint) { s += "uint"; }
+        case (ty_machine(?tm)) { s += ty_mach_to_str(tm); }
+        case (ty_char) { s += "char"; }
+        case (ty_str) { s += "str"; }
+        case (ty_istr) { s += "istr"; }
+        case (ty_box(?tm)) { s += "@" + mt_to_str(cx, tm); }
+        case (ty_vec(?tm)) { s += "vec[" + mt_to_str(cx, tm) + "]"; }
+        case (ty_ivec(?tm)) { s += "ivec[" + mt_to_str(cx, tm) + "]"; }
+        case (ty_port(?t)) { s += "port[" + ty_to_str(cx, t) + "]"; }
+        case (ty_chan(?t)) { s += "chan[" + ty_to_str(cx, t) + "]"; }
+        case (ty_type) { s += "type"; }
+        case (ty_task) { s += "task"; }
+        case (ty_tup(?elems)) {
+            let vec[str] strs = [];
+            for (mt tm in elems) { strs += [mt_to_str(cx, tm)]; }
+            s += "tup(" + str::connect(strs, ",") + ")";
+        }
+        case (ty_rec(?elems)) {
+            let vec[str] strs = [];
+            for (field fld in elems) { strs += [field_to_str(cx, fld)]; }
+            s += "rec(" + str::connect(strs, ",") + ")";
+        }
+        case (ty_tag(?id, ?tps)) {
+            // The user should never see this if the cname is set properly!
+
+            s += "<tag#" + istr(id._0) + ":" + istr(id._1) + ">";
+            if (vec::len[t](tps) > 0u) {
+                auto f = bind ty_to_str(cx, _);
+                auto strs = vec::map[t, str](f, tps);
+                s += "[" + str::connect(strs, ",") + "]";
+            }
+        }
+        case (ty_fn(?proto, ?inputs, ?output, ?cf, ?constrs)) {
+            s += fn_to_str(cx, proto, none, inputs, output, cf, constrs);
+        }
+        case (ty_native_fn(_, ?inputs, ?output)) {
+            s += fn_to_str(cx, ast::proto_fn, none, inputs, output,
+                           ast::return, []);
+        }
+        case (ty_obj(?meths)) {
+            auto f = bind method_to_str(cx, _);
+            auto m = vec::map[method, str](f, meths);
+            s += "obj {\n\t" + str::connect(m, "\n\t") + "\n}";
+        }
+        case (ty_res(?id, _, _)) {
+            s += "<resource#" + istr(id._0) + ":" + istr(id._1) + ">";
+        }
+        case (ty_var(?v)) { s += "<T" + istr(v) + ">"; }
+        case (ty_param(?id)) {
+            s += "'" + str::unsafe_from_bytes([('a' as u8) + (id as u8)]);
+        }
+        case (_) { s += ty_to_short_str(cx, typ); }
+    }
+    ret s;
+}
+
+fn ty_to_short_str(&ctxt cx, t typ) -> str {
+    auto f = def_to_str;
+    auto ecx = @rec(ds=f, tcx=cx, abbrevs=metadata::tyencode::ac_no_abbrevs);
+    auto s = metadata::tyencode::ty_str(ecx, typ);
+    if (str::byte_len(s) >= 32u) { s = str::substr(s, 0u, 32u); }
+    ret s;
+}
+
+fn constr_to_str(&@constr_def c) -> str {
+    ret ast::path_to_str(c.node.path) +
+        pprust::constr_args_to_str(pprust::uint_to_str, c.node.args);
+}
+
+fn constrs_str(&vec[@constr_def] constrs) -> str {
+    auto s = "";
+    auto colon = true;
+    for (@constr_def c in constrs) {
+        if (colon) { s += " : "; colon = false; } else { s += ", "; }
+        s += constr_to_str(c);
+    }
+    ret s;
+}
+
+// Local Variables:
+// mode: rust
+// fill-column: 78;
+// indent-tabs-mode: nil
+// c-basic-offset: 4
+// buffer-file-coding-system: utf-8-unix
+// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
+// End:
diff --git a/src/lib/int.rs b/src/lib/int.rs
index 2387d258723..af2403cd4b0 100644
--- a/src/lib/int.rs
+++ b/src/lib/int.rs
@@ -47,6 +47,7 @@ fn to_str(int n, uint radix) -> str {
             "-" + uint::to_str(-n as uint, radix)
         } else { uint::to_str(n as uint, radix) };
 }
+fn str(int i) -> str { ret to_str(i, 10u); }
 
 fn pow(int base, uint exponent) -> int {
     ret if (exponent == 0u) {
diff --git a/src/lib/map.rs b/src/lib/map.rs
index 90b2693bdcf..95214bcbf26 100644
--- a/src/lib/map.rs
+++ b/src/lib/map.rs
@@ -1,6 +1,3 @@
-
-
-
 /**
  * At the moment, this is a partial hashmap implementation, not yet fit for
  * use, but useful as a stress test for rustboot.
@@ -196,6 +193,31 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
     let vec[mutable bucket[K, V]] bkts = make_buckets[K, V](initial_capacity);
     ret hashmap[K, V](hasher, eqer, bkts, initial_capacity, 0u, load_factor);
 }
+
+// Hash map constructors for basic types
+
+fn new_str_hash[V]() -> hashmap[str, V] {
+    let hashfn[str] hasher = str::hash;
+    let eqfn[str] eqer = str::eq;
+    ret mk_hashmap[str, V](hasher, eqer);
+}
+
+fn new_int_hash[V]() -> hashmap[int, V] {
+    fn hash_int(&int x) -> uint { ret x as uint; }
+    fn eq_int(&int a, &int b) -> bool { ret a == b; }
+    auto hasher = hash_int;
+    auto eqer = eq_int;
+    ret mk_hashmap[int, V](hasher, eqer);
+}
+
+fn new_uint_hash[V]() -> hashmap[uint, V] {
+    fn hash_uint(&uint x) -> uint { ret x; }
+    fn eq_uint(&uint a, &uint b) -> bool { ret a == b; }
+    auto hasher = hash_uint;
+    auto eqer = eq_uint;
+    ret mk_hashmap[uint, V](hasher, eqer);
+}
+
 // Local Variables:
 // mode: rust;
 // fill-column: 78;
diff --git a/src/lib/uint.rs b/src/lib/uint.rs
index ca632914a45..6908aa6342a 100644
--- a/src/lib/uint.rs
+++ b/src/lib/uint.rs
@@ -92,6 +92,8 @@ fn to_str(uint num, uint radix) -> str {
     while (len != 0u) { len -= 1u; s1 += str::unsafe_from_byte(s.(len)); }
     ret s1;
 }
+fn str(uint i) -> str { ret to_str(i, 10u); }
+
 // Local Variables:
 // mode: rust;
 // fill-column: 78;
diff --git a/src/lib/vec.rs b/src/lib/vec.rs
index cf7be916722..2a075477937 100644
--- a/src/lib/vec.rs
+++ b/src/lib/vec.rs
@@ -301,6 +301,19 @@ fn or(&vec[bool] v) -> bool {
     ret vec::foldl[bool, bool](f, false, v);
 }
 
+fn any[T](&fn(&T) -> bool f, &vec[T] v) -> bool {
+    for (T t in v) {
+        if (f(t)) { ret true; } 
+    }
+    ret false;
+}
+fn all[T](&fn(&T) -> bool f, &vec[T] v) -> bool {
+    for (T t in v) {
+        if (!f(t)) { ret false; } 
+    }
+    ret true;
+}
+
 fn clone[T](&vec[T] v) -> vec[T] { ret slice[T](v, 0u, len[T](v)); }
 
 fn plus_option[T](&mutable vec[T] v, &option::t[T] o) {