diff options
Diffstat (limited to 'src/comp/syntax')
| -rw-r--r-- | src/comp/syntax/ast_util.rs | 5 | ||||
| -rw-r--r-- | src/comp/syntax/parse/parser.rs | 4 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/comp/syntax/ast_util.rs b/src/comp/syntax/ast_util.rs index cb0545c07b7..65c117cfa6b 100644 --- a/src/comp/syntax/ast_util.rs +++ b/src/comp/syntax/ast_util.rs @@ -326,6 +326,11 @@ fn ident_to_path(s: span, i: ident) -> @path { @respan(s, {global: false, idents: [i], types: []}) } +// Provides an extra node_id to hang callee information on, in case the +// operator is deferred to a user-supplied method. The parser is responsible +// for reserving this id. +fn op_expr_callee_id(e: @expr) -> node_id { e.id - 1 } + // Local Variables: // mode: rust // fill-column: 78; diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index a66b223175c..1e892eb43b1 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -1048,6 +1048,7 @@ fn parse_prefix_expr(p: parser) -> pexpr { p.bump(); let e = to_expr(parse_prefix_expr(p)); hi = e.span.hi; + p.get_id(); // see ast_util::op_expr_callee_id ex = ast::expr_unary(ast::not, e); } token::BINOP(b) { @@ -1056,6 +1057,7 @@ fn parse_prefix_expr(p: parser) -> pexpr { p.bump(); let e = to_expr(parse_prefix_expr(p)); hi = e.span.hi; + p.get_id(); // see ast_util::op_expr_callee_id ex = ast::expr_unary(ast::neg, e); } token::STAR { @@ -1146,6 +1148,7 @@ fn parse_more_binops(p: parser, plhs: pexpr, min_prec: int) -> p.bump(); let expr = parse_prefix_expr(p); let rhs = parse_more_binops(p, expr, cur.prec); + p.get_id(); // see ast_util::op_expr_callee_id let bin = mk_pexpr(p, lhs.span.lo, rhs.span.hi, ast::expr_binary(cur.op, lhs, rhs)); ret parse_more_binops(p, bin, min_prec); @@ -1186,6 +1189,7 @@ fn parse_assign_expr(p: parser) -> @ast::expr { token::LSR { aop = ast::lsr; } token::ASR { aop = ast::asr; } } + p.get_id(); // see ast_util::op_expr_callee_id ret mk_expr(p, lo, rhs.span.hi, ast::expr_assign_op(aop, lhs, rhs)); } token::LARROW { |
