don't print superfluous round brackets in curly braces
@@ -202,6 +202,7 @@ enum TokenOrRedirect {
Op(Atom, OpDesc),
NumberedVar(String),
CompositeRedirect(usize, DirectedOp),
+ CurlyBracketRedirect(usize),
FunctorRedirect(usize),
#[allow(unused)] IpAddr(IpAddr),
NumberFocus(usize, NumberFocus, Option<DirectedOp>),
@@ -735,8 +736,9 @@ fn format_curly_braces(&mut self, mut max_depth: usize) -> bool {
return false;
}
+
self.state_stack.push(TokenOrRedirect::RightCurly);
- self.state_stack.push(TokenOrRedirect::FunctorRedirect(max_depth));
+ self.state_stack.push(TokenOrRedirect::CurlyBracketRedirect(max_depth));
self.state_stack.push(TokenOrRedirect::LeftCurly);
true
@@ -791,8 +793,8 @@ fn format_clause(
}
}
- return match (name.as_str(), arity) {
- ("{}", 1) if !self.ignore_ops => self.format_curly_braces(max_depth),
+ return match (name, arity) {
+ (atom!("{}"), 1) if !self.ignore_ops => self.format_curly_braces(max_depth),
_ => self.format_struct(max_depth, arity, name),
};
}
@@ -1305,8 +1307,8 @@ fn handle_op_as_struct(
max_depth: usize,
) {
let add_brackets = if !self.ignore_ops {
- negated_operand
- || if let Some(ref op) = op {
+ negated_operand ||
+ if let Some(ref op) = op {
if self.numbervars && arity == 1 && name == atom!("$VAR") {
!self.iter.immediate_leaf_has_property(|addr| {
match Number::try_from(addr) {
@@ -1571,6 +1573,9 @@ pub fn print(mut self) -> Outputter {
TokenOrRedirect::CompositeRedirect(max_depth, op) => {
self.handle_heap_term(Some(op), false, max_depth)
}
+ TokenOrRedirect::CurlyBracketRedirect(max_depth) => {
+ self.handle_heap_term(None, false, max_depth)
+ }
TokenOrRedirect::FunctorRedirect(max_depth) => {
self.handle_heap_term(None, true, max_depth)
}
