summary refs log tree commit diff
path: root/src/comp/front
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2011-06-03 15:26:03 -0700
committerGraydon Hoare <graydon@mozilla.com>2011-06-03 15:42:42 -0700
commit088ab03fdbdd2fad29b678f5eeaadde4e15cb205 (patch)
tree00a3a6b77754b9788cffe0bff534f2d6530f6dc2 /src/comp/front
parent8235e76a473f6c650ad6a96dca0b5ef84ebdac4a (diff)
downloadrust-088ab03fdbdd2fad29b678f5eeaadde4e15cb205.tar.gz
rust-088ab03fdbdd2fad29b678f5eeaadde4e15cb205.zip
Add spans to fields, args, methods. Improve pp of same.
Diffstat (limited to 'src/comp/front')
-rw-r--r--src/comp/front/ast.rs10
-rw-r--r--src/comp/front/parser.rs20
2 files changed, 17 insertions, 13 deletions
diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs
index 85e525e8823..92f12c3dc1b 100644
--- a/src/comp/front/ast.rs
+++ b/src/comp/front/ast.rs
@@ -300,11 +300,15 @@ tag lit_ {
 // type structure in middle/ty.rs as well.
 
 type mt = rec(@ty ty, mutability mut);
-type ty_field = rec(ident ident, mt mt);
-type ty_arg = rec(mode mode, @ty ty);
-type ty_method = rec(proto proto, ident ident,
+type ty_field_ = rec(ident ident, mt mt);
+type ty_arg_ = rec(mode mode, @ty ty);
+type ty_method_ = rec(proto proto, ident ident,
                      vec[ty_arg] inputs, @ty output,
                      controlflow cf);
+type ty_field = spanned[ty_field_];
+type ty_arg = spanned[ty_arg_];
+type ty_method = spanned[ty_method_];
+
 type ty = spanned[ty_];
 tag ty_ {
     ty_nil;
diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs
index d7fecee6ca4..dbfdea89c21 100644
--- a/src/comp/front/parser.rs
+++ b/src/comp/front/parser.rs
@@ -287,7 +287,6 @@ fn eat_word(&parser p, &str word) -> bool {
                 p.bump();
                 ret true;
             } else { ret false; }
-            
         }
         case (_) { ret false; }
     }
@@ -312,7 +311,8 @@ fn check_bad_word(&parser p) {
 
 fn parse_ty_fn(ast::proto proto, &parser p, uint lo)
     -> ast::ty_ {
-    fn parse_fn_input_ty(&parser p) -> rec(ast::mode mode, @ast::ty ty) {
+    fn parse_fn_input_ty(&parser p) -> ast::ty_arg {
+        auto lo = p.get_lo_pos();
         auto mode;
         if (p.peek() == token::BINOP(token::AND)) {
             p.bump();
@@ -332,14 +332,12 @@ fn parse_ty_fn(ast::proto proto, &parser p, uint lo)
             case (_) { /* no param name present */ }
         }
 
-        ret rec(mode=mode, ty=t);
+        ret spanned(lo, t.span.hi, rec(mode=mode, ty=t));
     }
 
     auto lo = p.get_lo_pos();
-
-    auto f = parse_fn_input_ty; // FIXME: trans_const_lval bug
-    auto inputs = parse_seq[rec(ast::mode mode, @ast::ty ty)](token::LPAREN,
-        token::RPAREN, some(token::COMMA), f, p);
+    auto inputs = parse_seq(token::LPAREN, token::RPAREN,
+                            some(token::COMMA), parse_fn_input_ty, p);
 
     // FIXME: dropping constrs on the floor at the moment.
     // pick them up when they're used by typestate pass.
@@ -383,8 +381,9 @@ fn parse_ty_obj(&parser p, &mutable uint hi) -> ast::ty_ {
         expect(p, token::SEMI);
         alt (f) {
             case (ast::ty_fn(?proto, ?inputs, ?output, ?cf)) {
-                ret rec(proto=proto, ident=ident,
-                        inputs=inputs, output=output, cf=cf);
+                ret spanned(flo, output.span.hi,
+                            rec(proto=proto, ident=ident,
+                                inputs=inputs, output=output, cf=cf));
             }
         }
         fail;
@@ -405,9 +404,10 @@ fn parse_mt(&parser p) -> ast::mt {
 }
 
 fn parse_ty_field(&parser p) -> ast::ty_field {
+    auto lo = p.get_lo_pos();
     auto mt = parse_mt(p);
     auto id = parse_ident(p);
-    ret rec(ident=id, mt=mt);
+    ret spanned(lo, mt.ty.span.hi, rec(ident=id, mt=mt));
 }
 
 fn parse_constr_arg(&parser p) -> @ast::constr_arg {