From c5749cbbb1728553480a989a266de90a854e381f Mon Sep 17 00:00:00 2001 From: Markus Triska Date: Thu, 4 Mar 2021 21:33:29 +0100 Subject: [PATCH 1/2] remove unnecessary argument --- src/lib/format.pl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib/format.pl b/src/lib/format.pl index fe9c7d27..a9c8c32f 100644 --- a/src/lib/format.pl +++ b/src/lib/format.pl @@ -502,13 +502,13 @@ body_(Body, C, I, VNs) --> { C1 is I + 3 }, body_(If, C1, C1, VNs), " ->\n", body_(Then, 0, C1, VNs), "\n", - else_branch(Else, C1, I, VNs). + else_branch(Else, I, VNs). body_((A;B), C, I, VNs) --> !, indent_to(C, I), "( ", { C1 is I + 3 }, body_(A, C1, C1, VNs), "\n", - else_branch(B, C1, I, VNs). + else_branch(B, I, VNs). body_(Goal, C, I, VNs) --> indent_to(C, I), literal(Goal, VNs). @@ -520,14 +520,14 @@ body_if_then_else(Body, If, Then, Else) :- nonvar(A), A = (If -> Then). -else_branch(Else, C, I, VNs) --> +else_branch(Else, I, VNs) --> indent_to(0, I), "; ", + { C is I + 3 }, ( { body_if_then_else(Else, If, Then, NextElse) } -> - { C1 is I + 3 }, - body_(If, C1, C1, VNs), " ->\n", - body_(Then, 0, C1, VNs), "\n", - else_branch(NextElse, C1, I, VNs) + body_(If, C, C, VNs), " ->\n", + body_(Then, 0, C, VNs), "\n", + else_branch(NextElse, I, VNs) ; body_(Else, C, C, VNs), "\n", indent_to(0, I), ")" From d92951ba5b8b5802ff049a0c8c76b351274254c0 Mon Sep 17 00:00:00 2001 From: Markus Triska Date: Thu, 4 Mar 2021 21:38:39 +0100 Subject: [PATCH 2/2] ENHANCED: more readable indentation of nested disjunctions Example: ?- portray_clause((h :- a ; b ; c)). h :- ( a ; b ; c ). true. --- src/lib/format.pl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/format.pl b/src/lib/format.pl index a9c8c32f..823c700c 100644 --- a/src/lib/format.pl +++ b/src/lib/format.pl @@ -528,6 +528,9 @@ else_branch(Else, I, VNs) --> body_(If, C, C, VNs), " ->\n", body_(Then, 0, C, VNs), "\n", else_branch(NextElse, I, VNs) + ; { nonvar(Else), Else = ( A ; B ) } -> + body_(A, C, C, VNs), "\n", + else_branch(B, I, VNs) ; body_(Else, C, C, VNs), "\n", indent_to(0, I), ")"