Add span to field to catch per-field comments in rec exprs.

This commit is contained in:
Graydon Hoare 2011-05-30 15:56:01 -07:00
parent d12ea39896
commit b48cab962a
8 changed files with 27 additions and 22 deletions

View file

@ -229,7 +229,8 @@ tag decl_ {
type arm = rec(@pat pat, block block);
type elt = rec(mutability mut, @expr expr);
type field = rec(mutability mut, ident ident, @expr expr);
type field_ = rec(mutability mut, ident ident, @expr expr);
type field = spanned[field_];
tag spawn_dom {
dom_implicit;

View file

@ -148,9 +148,9 @@ fn pieces_to_expr(parser p, vec[piece] pieces, vec[@ast::expr] args)
for (tup(ast::ident, @ast::expr) field in fields) {
auto ident = field._0;
auto val = field._1;
auto astfield = rec(mut = ast::imm,
ident = ident,
expr = val);
auto astfield = rec(node=rec(mut = ast::imm,
ident = ident,
expr = val), span=sp);
astfields += [astfield];
}

View file

@ -737,11 +737,12 @@ fn parse_mutability(&parser p) -> ast::mutability {
}
fn parse_field(&parser p) -> ast::field {
auto lo = p.get_lo_pos();
auto m = parse_mutability(p);
auto i = parse_ident(p);
expect(p, token::EQ);
auto e = parse_expr(p);
ret rec(mut=m, ident=i, expr=e);
ret spanned(lo, e.span.hi, rec(mut=m, ident=i, expr=e));
}
fn parse_bottom_expr(&parser p) -> @ast::expr {