diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-10-27 17:14:09 -0700 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-10-30 15:05:32 -0700 |
| commit | 62f98c8ff8179c9754718e62285b82b50dfcfe26 (patch) | |
| tree | c3db0a950f995408ea390f1b1952a24d2b982940 /src/libsyntax/parse/classify.rs | |
| parent | 17a5d0f3a0a76e172777456cc0f5ed8318149e33 (diff) | |
| download | rust-62f98c8ff8179c9754718e62285b82b50dfcfe26.tar.gz rust-62f98c8ff8179c9754718e62285b82b50dfcfe26.zip | |
Preserve parenthesization in the AST
Maintain explicit "paren" nodes in the AST so we can pretty-print without having to guess where parens should go. We may revisit this in the future. r=graydon
Diffstat (limited to 'src/libsyntax/parse/classify.rs')
| -rw-r--r-- | src/libsyntax/parse/classify.rs | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/src/libsyntax/parse/classify.rs b/src/libsyntax/parse/classify.rs index ff3abb5379e..2f3e29bd90f 100644 --- a/src/libsyntax/parse/classify.rs +++ b/src/libsyntax/parse/classify.rs @@ -36,39 +36,3 @@ fn stmt_ends_with_semi(stmt: ast::stmt) -> bool { } } } - -fn need_parens(expr: @ast::expr, outer_prec: uint) -> bool { - match expr.node { - ast::expr_binary(op, _, _) => operator_prec(op) < outer_prec, - ast::expr_cast(_, _) => parse::prec::as_prec < outer_prec, - // This may be too conservative in some cases - ast::expr_assign(_, _) => true, - ast::expr_swap(_, _) => true, - ast::expr_assign_op(_, _, _) => true, - ast::expr_ret(_) => true, - ast::expr_assert(_) => true, - ast::expr_log(_, _, _) => true, - _ => !parse::classify::expr_requires_semi_to_be_stmt(expr) - } -} - -fn ends_in_lit_int(ex: @ast::expr) -> bool { - match ex.node { - ast::expr_lit(node) => match node { - @{node: ast::lit_int(_, ast::ty_i), _} - | @{node: ast::lit_int_unsuffixed(_), _} => true, - _ => false - }, - ast::expr_binary(_, _, sub) | ast::expr_unary(_, sub) | - ast::expr_copy(sub) | ast::expr_assign(_, sub) | - ast::expr_assign_op(_, _, sub) | ast::expr_swap(_, sub) | - ast::expr_log(_, _, sub) | ast::expr_assert(sub) => { - ends_in_lit_int(sub) - } - ast::expr_fail(osub) | ast::expr_ret(osub) => match osub { - Some(ex) => ends_in_lit_int(ex), - _ => false - }, - _ => false - } -} |
