|
| 1 | +import parse::classify::*; |
1 | 2 | import parse::comments;
|
2 | 3 | import parse::lexer;
|
3 | 4 | import codemap::codemap;
|
@@ -242,6 +243,12 @@ fn is_bol(s: ps) -> bool {
|
242 | 243 | s.s.last_token() == pp::hardbreak_tok();
|
243 | 244 | }
|
244 | 245 |
|
| 246 | +fn in_cbox(s: ps) -> bool { |
| 247 | + let len = vec::len(s.boxes); |
| 248 | + if len == 0u { ret false; } |
| 249 | + ret s.boxes[len - 1u] == pp::consistent; |
| 250 | +} |
| 251 | + |
245 | 252 | fn hardbreak_if_not_bol(s: ps) { if !is_bol(s) { hardbreak(s.s); } }
|
246 | 253 | fn space_if_not_bol(s: ps) { if !is_bol(s) { space(s.s); } }
|
247 | 254 | fn break_offset_if_not_bol(s: ps, n: uint, off: int) {
|
@@ -1484,34 +1491,6 @@ fn print_view_item(s: ps, item: @ast::view_item) {
|
1484 | 1491 | end(s); // end outer head-block
|
1485 | 1492 | }
|
1486 | 1493 |
|
1487 |
| - |
1488 |
| -// FIXME: The fact that this builds up the table anew for every call is |
1489 |
| -// not good. Eventually, table should be a const. |
1490 |
| -fn operator_prec(op: ast::binop) -> int { |
1491 |
| - for vec::each(*parse::prec::binop_prec_table()) {|spec| |
1492 |
| - if spec.op == op { ret spec.prec; } |
1493 |
| - } |
1494 |
| - core::unreachable(); |
1495 |
| -} |
1496 |
| - |
1497 |
| -fn need_parens(expr: @ast::expr, outer_prec: int) -> bool { |
1498 |
| - alt expr.node { |
1499 |
| - ast::expr_binary(op, _, _) { operator_prec(op) < outer_prec } |
1500 |
| - ast::expr_cast(_, _) { parse::prec::as_prec < outer_prec } |
1501 |
| - // This may be too conservative in some cases |
1502 |
| - ast::expr_assign(_, _) { true } |
1503 |
| - ast::expr_move(_, _) { true } |
1504 |
| - ast::expr_swap(_, _) { true } |
1505 |
| - ast::expr_assign_op(_, _, _) { true } |
1506 |
| - ast::expr_ret(_) { true } |
1507 |
| - ast::expr_be(_) { true } |
1508 |
| - ast::expr_assert(_) { true } |
1509 |
| - ast::expr_check(_, _) { true } |
1510 |
| - ast::expr_log(_, _, _) { true } |
1511 |
| - _ { !parse::classify::expr_requires_semi_to_be_stmt(expr) } |
1512 |
| - } |
1513 |
| -} |
1514 |
| - |
1515 | 1494 | fn print_op_maybe_parens(s: ps, expr: @ast::expr, outer_prec: int) {
|
1516 | 1495 | let add_them = need_parens(expr, outer_prec);
|
1517 | 1496 | if add_them { popen(s); }
|
@@ -1596,12 +1575,6 @@ fn print_remaining_comments(s: ps) {
|
1596 | 1575 | }
|
1597 | 1576 | }
|
1598 | 1577 |
|
1599 |
| -fn in_cbox(s: ps) -> bool { |
1600 |
| - let len = vec::len(s.boxes); |
1601 |
| - if len == 0u { ret false; } |
1602 |
| - ret s.boxes[len - 1u] == pp::consistent; |
1603 |
| -} |
1604 |
| - |
1605 | 1578 | fn print_literal(s: ps, &&lit: @ast::lit) {
|
1606 | 1579 | maybe_print_comment(s, lit.span.lo);
|
1607 | 1580 | alt next_lit(s, lit.span.lo) {
|
@@ -1839,25 +1812,6 @@ fn proto_to_str(p: ast::proto) -> str {
|
1839 | 1812 | };
|
1840 | 1813 | }
|
1841 | 1814 |
|
1842 |
| -fn ends_in_lit_int(ex: @ast::expr) -> bool { |
1843 |
| - alt ex.node { |
1844 |
| - ast::expr_lit(@{node: ast::lit_int(_, ast::ty_i), _}) { true } |
1845 |
| - ast::expr_binary(_, _, sub) | ast::expr_unary(_, sub) | |
1846 |
| - ast::expr_move(_, sub) | ast::expr_copy(sub) | |
1847 |
| - ast::expr_assign(_, sub) | ast::expr_be(sub) | |
1848 |
| - ast::expr_assign_op(_, _, sub) | ast::expr_swap(_, sub) | |
1849 |
| - ast::expr_log(_, _, sub) | ast::expr_assert(sub) | |
1850 |
| - ast::expr_check(_, sub) { ends_in_lit_int(sub) } |
1851 |
| - ast::expr_fail(osub) | ast::expr_ret(osub) { |
1852 |
| - alt osub { |
1853 |
| - some(ex) { ends_in_lit_int(ex) } |
1854 |
| - _ { false } |
1855 |
| - } |
1856 |
| - } |
1857 |
| - _ { false } |
1858 |
| - } |
1859 |
| -} |
1860 |
| - |
1861 | 1815 | //
|
1862 | 1816 | // Local Variables:
|
1863 | 1817 | // mode: rust
|
|
0 commit comments