diff --git a/src/lib/format.pl b/src/lib/format.pl index 5389c90dd..2ac4744b8 100644 --- a/src/lib/format.pl +++ b/src/lib/format.pl @@ -593,7 +593,15 @@ literal(Lit, VNs) --> { write_term_to_chars(Lit, [quoted(true),variable_names(VNs),double_quotes(true)], Ls) }, - seq(Ls). + ( { nonvar(Lit), + functor(Lit, F, A), + current_op(Pri, _, F), + ( A =:= 0 + ; Pri >= 1000 + ) } -> + "(", seq(Ls), ")" + ; seq(Ls) + ). literal_(Lit, VNs) --> { phrase(literal(Lit, VNs), Ls) },