nitc :: ABinOpHelper :: defaultinit
# Used to factorize work on Or, And, Implies and Binop expressions.
private class ABinOpHelper
super AExpr
fun bin_expr1: AExpr is abstract
fun bin_expr2: AExpr is abstract
# Operator string
fun bin_op: String is abstract
redef fun accept_pretty_printer(v) do
var can_inline = v.can_inline(self)
if not can_inline then
if (self isa ABinopExpr and bin_expr1 isa ABinopExpr) or
(self isa AAndExpr and (bin_expr1 isa AAndExpr or bin_expr1 isa AOrExpr)) or
(self isa AOrExpr and (bin_expr1 isa AAndExpr or bin_expr1 isa AOrExpr))
then
bin_expr1.force_block = true
end
end
v.visit bin_expr1
v.adds
v.consume bin_op
if can_inline then
v.adds
v.visit bin_expr2
else
v.forcen
v.indent += 1
v.addt
v.indent -= 1
v.visit bin_expr2
end
end
end
src/pretty.nit:1961,1--1998,3