mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-10 19:33:11 +00:00
Fix a bug in the pretty printer for arbitrary terms where it would not
Estimated hours taken: 0.2 Branches: main library/pretty_printer.m: Fix a bug in the pretty printer for arbitrary terms where it would not start a new line for a functor that could not fit on the remainder of the line. This made it impossible to see structure from indentation in some cases. tests/hard_coded/test_pretty_printer.exp: tests/hard_coded/test_pretty_printer.m: Update the test case.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
%-----------------------------------------------------------------------------%
|
||||
% vim: ts=4 sw=4 expandtab tw=0 wm=0 ft=mercury
|
||||
%-----------------------------------------------------------------------------%
|
||||
% Copyright (C) 2007 The University of Melbourne
|
||||
% Copyright (C) 2007, 2009 The University of Melbourne
|
||||
% This file may only be copied under the terms of the GNU Library General
|
||||
% Public License - see the file COPYING.LIB in the Mercury distribution.
|
||||
%-----------------------------------------------------------------------------%
|
||||
@@ -712,7 +712,8 @@ expand_format_term(Name, Args, Doc, !Limit, CurrentPri) :-
|
||||
str("{"), indent([format_list(Args, str(", "))]), str("}")
|
||||
])
|
||||
else
|
||||
Doc0 = docs([
|
||||
Doc0 = group([
|
||||
nl,
|
||||
str(term_io.quoted_atom(Name)),
|
||||
str("("), indent([format_list(Args, str(", "))]), str(")")
|
||||
])
|
||||
|
||||
@@ -30,6 +30,11 @@ limit = triangular(1), max lines = 3, line width = 38
|
||||
100....
|
||||
|------------------------------------|
|
||||
|
||||
limit = triangular(1), max lines = 3, line width = 38
|
||||
|------------------------------------|
|
||||
succ(...)
|
||||
|------------------------------------|
|
||||
|
||||
limit = triangular(1), max lines = 3, line width = 38
|
||||
|------------------------------------|
|
||||
-...
|
||||
@@ -86,6 +91,11 @@ limit = triangular(1), max lines = 3, line width = 78
|
||||
100....
|
||||
|----------------------------------------------------------------------------|
|
||||
|
||||
limit = triangular(1), max lines = 3, line width = 78
|
||||
|----------------------------------------------------------------------------|
|
||||
succ(...)
|
||||
|----------------------------------------------------------------------------|
|
||||
|
||||
limit = triangular(1), max lines = 3, line width = 78
|
||||
|----------------------------------------------------------------------------|
|
||||
-...
|
||||
@@ -145,6 +155,11 @@ limit = triangular(1), max lines = 10, line width = 38
|
||||
100....
|
||||
|------------------------------------|
|
||||
|
||||
limit = triangular(1), max lines = 10, line width = 38
|
||||
|------------------------------------|
|
||||
succ(...)
|
||||
|------------------------------------|
|
||||
|
||||
limit = triangular(1), max lines = 10, line width = 38
|
||||
|------------------------------------|
|
||||
-...
|
||||
@@ -204,6 +219,11 @@ limit = triangular(1), max lines = 10, line width = 78
|
||||
100....
|
||||
|----------------------------------------------------------------------------|
|
||||
|
||||
limit = triangular(1), max lines = 10, line width = 78
|
||||
|----------------------------------------------------------------------------|
|
||||
succ(...)
|
||||
|----------------------------------------------------------------------------|
|
||||
|
||||
limit = triangular(1), max lines = 10, line width = 78
|
||||
|----------------------------------------------------------------------------|
|
||||
-...
|
||||
@@ -260,6 +280,11 @@ limit = linear(1), max lines = 3, line width = 38
|
||||
100....
|
||||
|------------------------------------|
|
||||
|
||||
limit = linear(1), max lines = 3, line width = 38
|
||||
|------------------------------------|
|
||||
succ(...)
|
||||
|------------------------------------|
|
||||
|
||||
limit = linear(1), max lines = 3, line width = 38
|
||||
|------------------------------------|
|
||||
-...
|
||||
@@ -316,6 +341,11 @@ limit = linear(1), max lines = 3, line width = 78
|
||||
100....
|
||||
|----------------------------------------------------------------------------|
|
||||
|
||||
limit = linear(1), max lines = 3, line width = 78
|
||||
|----------------------------------------------------------------------------|
|
||||
succ(...)
|
||||
|----------------------------------------------------------------------------|
|
||||
|
||||
limit = linear(1), max lines = 3, line width = 78
|
||||
|----------------------------------------------------------------------------|
|
||||
-...
|
||||
@@ -375,6 +405,11 @@ limit = linear(1), max lines = 10, line width = 38
|
||||
100....
|
||||
|------------------------------------|
|
||||
|
||||
limit = linear(1), max lines = 10, line width = 38
|
||||
|------------------------------------|
|
||||
succ(...)
|
||||
|------------------------------------|
|
||||
|
||||
limit = linear(1), max lines = 10, line width = 38
|
||||
|------------------------------------|
|
||||
-...
|
||||
@@ -434,6 +469,11 @@ limit = linear(1), max lines = 10, line width = 78
|
||||
100....
|
||||
|----------------------------------------------------------------------------|
|
||||
|
||||
limit = linear(1), max lines = 10, line width = 78
|
||||
|----------------------------------------------------------------------------|
|
||||
succ(...)
|
||||
|----------------------------------------------------------------------------|
|
||||
|
||||
limit = linear(1), max lines = 10, line width = 78
|
||||
|----------------------------------------------------------------------------|
|
||||
-...
|
||||
@@ -493,6 +533,14 @@ limit = triangular(10), max lines = 3, line width = 38
|
||||
100.99.98.97.96........
|
||||
|------------------------------------|
|
||||
|
||||
limit = triangular(10), max lines = 3, line width = 38
|
||||
|------------------------------------|
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
...
|
||||
|------------------------------------|
|
||||
|
||||
limit = triangular(10), max lines = 3, line width = 38
|
||||
|------------------------------------|
|
||||
-(-(-(-((... + ...) * ... /
|
||||
@@ -560,6 +608,11 @@ limit = triangular(10), max lines = 3, line width = 78
|
||||
100.99.98.97.96........
|
||||
|----------------------------------------------------------------------------|
|
||||
|
||||
limit = triangular(10), max lines = 3, line width = 78
|
||||
|----------------------------------------------------------------------------|
|
||||
succ(succ(succ(succ(succ(succ(succ(succ(succ(succ(...))))))))))
|
||||
|----------------------------------------------------------------------------|
|
||||
|
||||
limit = triangular(10), max lines = 3, line width = 78
|
||||
|----------------------------------------------------------------------------|
|
||||
-(-(-(-((... + ...) * ... / (... * ...)) / (... / ... * ... + -...)) /
|
||||
@@ -629,6 +682,20 @@ limit = triangular(10), max lines = 10, line width = 38
|
||||
100.99.98.97.96........
|
||||
|------------------------------------|
|
||||
|
||||
limit = triangular(10), max lines = 10, line width = 38
|
||||
|------------------------------------|
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(...))))))))))
|
||||
|------------------------------------|
|
||||
|
||||
limit = triangular(10), max lines = 10, line width = 38
|
||||
|------------------------------------|
|
||||
-(-(-(-((... + ...) * ... /
|
||||
@@ -706,6 +773,11 @@ limit = triangular(10), max lines = 10, line width = 78
|
||||
100.99.98.97.96........
|
||||
|----------------------------------------------------------------------------|
|
||||
|
||||
limit = triangular(10), max lines = 10, line width = 78
|
||||
|----------------------------------------------------------------------------|
|
||||
succ(succ(succ(succ(succ(succ(succ(succ(succ(succ(...))))))))))
|
||||
|----------------------------------------------------------------------------|
|
||||
|
||||
limit = triangular(10), max lines = 10, line width = 78
|
||||
|----------------------------------------------------------------------------|
|
||||
-(-(-(-((... + ...) * ... / (... * ...)) / (... / ... * ... + -...)) /
|
||||
@@ -773,6 +845,14 @@ limit = triangular(100), max lines = 3, line width = 38
|
||||
...
|
||||
|------------------------------------|
|
||||
|
||||
limit = triangular(100), max lines = 3, line width = 38
|
||||
|------------------------------------|
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
...
|
||||
|------------------------------------|
|
||||
|
||||
limit = triangular(100), max lines = 3, line width = 38
|
||||
|------------------------------------|
|
||||
-(-(-(-((x + x) * (x + x) /
|
||||
@@ -849,6 +929,11 @@ limit = triangular(100), max lines = 3, line width = 78
|
||||
.......
|
||||
|----------------------------------------------------------------------------|
|
||||
|
||||
limit = triangular(100), max lines = 3, line width = 78
|
||||
|----------------------------------------------------------------------------|
|
||||
succ(succ(succ(succ(succ(succ(succ(succ(succ(succ(zero))))))))))
|
||||
|----------------------------------------------------------------------------|
|
||||
|
||||
limit = triangular(100), max lines = 3, line width = 78
|
||||
|----------------------------------------------------------------------------|
|
||||
-(-(-(-((x + x) * (x + x) / (x / x * (x / x))) /
|
||||
@@ -936,6 +1021,20 @@ limit = triangular(100), max lines = 10, line width = 38
|
||||
52.51........
|
||||
|------------------------------------|
|
||||
|
||||
limit = triangular(100), max lines = 10, line width = 38
|
||||
|------------------------------------|
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(zero))))))))))
|
||||
|------------------------------------|
|
||||
|
||||
limit = triangular(100), max lines = 10, line width = 38
|
||||
|------------------------------------|
|
||||
-(-(-(-((x + x) * (x + x) /
|
||||
@@ -1049,6 +1148,11 @@ limit = triangular(100), max lines = 10, line width = 78
|
||||
.......
|
||||
|----------------------------------------------------------------------------|
|
||||
|
||||
limit = triangular(100), max lines = 10, line width = 78
|
||||
|----------------------------------------------------------------------------|
|
||||
succ(succ(succ(succ(succ(succ(succ(succ(succ(succ(zero))))))))))
|
||||
|----------------------------------------------------------------------------|
|
||||
|
||||
limit = triangular(100), max lines = 10, line width = 78
|
||||
|----------------------------------------------------------------------------|
|
||||
-(-(-(-((x + x) * (x + x) / (x / x * (x / x))) /
|
||||
@@ -1139,6 +1243,14 @@ limit = linear(10), max lines = 3, line width = 38
|
||||
100.99.98.97.96........
|
||||
|------------------------------------|
|
||||
|
||||
limit = linear(10), max lines = 3, line width = 38
|
||||
|------------------------------------|
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
...
|
||||
|------------------------------------|
|
||||
|
||||
limit = linear(10), max lines = 3, line width = 38
|
||||
|------------------------------------|
|
||||
-(-(-(-((... + ...) * ... / ...) /
|
||||
@@ -1200,6 +1312,11 @@ limit = linear(10), max lines = 3, line width = 78
|
||||
100.99.98.97.96........
|
||||
|----------------------------------------------------------------------------|
|
||||
|
||||
limit = linear(10), max lines = 3, line width = 78
|
||||
|----------------------------------------------------------------------------|
|
||||
succ(succ(succ(succ(succ(succ(succ(succ(succ(succ(...))))))))))
|
||||
|----------------------------------------------------------------------------|
|
||||
|
||||
limit = linear(10), max lines = 3, line width = 78
|
||||
|----------------------------------------------------------------------------|
|
||||
-(-(-(-((... + ...) * ... / ...) / ...) / ...) / ...)
|
||||
@@ -1259,6 +1376,20 @@ limit = linear(10), max lines = 10, line width = 38
|
||||
100.99.98.97.96........
|
||||
|------------------------------------|
|
||||
|
||||
limit = linear(10), max lines = 10, line width = 38
|
||||
|------------------------------------|
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(...))))))))))
|
||||
|------------------------------------|
|
||||
|
||||
limit = linear(10), max lines = 10, line width = 38
|
||||
|------------------------------------|
|
||||
-(-(-(-((... + ...) * ... / ...) /
|
||||
@@ -1323,6 +1454,11 @@ limit = linear(10), max lines = 10, line width = 78
|
||||
100.99.98.97.96........
|
||||
|----------------------------------------------------------------------------|
|
||||
|
||||
limit = linear(10), max lines = 10, line width = 78
|
||||
|----------------------------------------------------------------------------|
|
||||
succ(succ(succ(succ(succ(succ(succ(succ(succ(succ(...))))))))))
|
||||
|----------------------------------------------------------------------------|
|
||||
|
||||
limit = linear(10), max lines = 10, line width = 78
|
||||
|----------------------------------------------------------------------------|
|
||||
-(-(-(-((... + ...) * ... / ...) / ...) / ...) / ...)
|
||||
@@ -1385,6 +1521,14 @@ limit = linear(100), max lines = 3, line width = 38
|
||||
...
|
||||
|------------------------------------|
|
||||
|
||||
limit = linear(100), max lines = 3, line width = 38
|
||||
|------------------------------------|
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
...
|
||||
|------------------------------------|
|
||||
|
||||
limit = linear(100), max lines = 3, line width = 38
|
||||
|------------------------------------|
|
||||
-(-(-(-((x + x) * (x + x) /
|
||||
@@ -1461,6 +1605,11 @@ limit = linear(100), max lines = 3, line width = 78
|
||||
.......
|
||||
|----------------------------------------------------------------------------|
|
||||
|
||||
limit = linear(100), max lines = 3, line width = 78
|
||||
|----------------------------------------------------------------------------|
|
||||
succ(succ(succ(succ(succ(succ(succ(succ(succ(succ(zero))))))))))
|
||||
|----------------------------------------------------------------------------|
|
||||
|
||||
limit = linear(100), max lines = 3, line width = 78
|
||||
|----------------------------------------------------------------------------|
|
||||
-(-(-(-((x + x) * (x + x) / (x / x * (x / x))) /
|
||||
@@ -1548,6 +1697,20 @@ limit = linear(100), max lines = 10, line width = 38
|
||||
52.51........
|
||||
|------------------------------------|
|
||||
|
||||
limit = linear(100), max lines = 10, line width = 38
|
||||
|------------------------------------|
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(
|
||||
succ(zero))))))))))
|
||||
|------------------------------------|
|
||||
|
||||
limit = linear(100), max lines = 10, line width = 38
|
||||
|------------------------------------|
|
||||
-(-(-(-((x + x) * (x + x) /
|
||||
@@ -1661,6 +1824,11 @@ limit = linear(100), max lines = 10, line width = 78
|
||||
.......
|
||||
|----------------------------------------------------------------------------|
|
||||
|
||||
limit = linear(100), max lines = 10, line width = 78
|
||||
|----------------------------------------------------------------------------|
|
||||
succ(succ(succ(succ(succ(succ(succ(succ(succ(succ(zero))))))))))
|
||||
|----------------------------------------------------------------------------|
|
||||
|
||||
limit = linear(100), max lines = 10, line width = 78
|
||||
|----------------------------------------------------------------------------|
|
||||
-(-(-(-((x + x) * (x + x) / (x / x * (x / x))) /
|
||||
|
||||
@@ -52,6 +52,10 @@
|
||||
; op_tree * op_tree
|
||||
; op_tree / op_tree.
|
||||
|
||||
:- type church
|
||||
---> zero
|
||||
; succ(church).
|
||||
|
||||
:- type non_canonical_bool
|
||||
---> non_canonical_bool(int)
|
||||
where equality is non_canonical_bool_eq.
|
||||
@@ -209,6 +213,7 @@ test_case(test_case(LineWidth, MaxLines, Limit, Doc)) :-
|
||||
func(X, M) = M ^ elem(X) := float(X),
|
||||
List, map.init : map(int, float)),
|
||||
OpTree = mk_op_tree(200),
|
||||
Church = list.foldl(func(_, X) = succ(X), 1..10, zero),
|
||||
Tuple = {1, 2.0, "three", '4', {5}},
|
||||
Square = list.duplicate(10, 1..10) : list(list(int)),
|
||||
IndentTest = docs([
|
||||
@@ -243,6 +248,7 @@ test_case(test_case(LineWidth, MaxLines, Limit, Doc)) :-
|
||||
; Doc = format(MapFloat)
|
||||
; Doc = format(MapStr)
|
||||
; Doc = format(OpTree)
|
||||
; Doc = format(Church)
|
||||
; Doc = fmt_susp_seq(100)
|
||||
; Doc = format(Tuple)
|
||||
; Doc = format(Square)
|
||||
|
||||
Reference in New Issue
Block a user