[m-rev.] Fixes for test output
Ian MacLarty
maclarty at csse.unimelb.edu.au
Wed Aug 22 13:41:49 AEST 2007
On Wed, Aug 22, 2007 at 11:59:44AM +1000, Ralph Becket wrote:
> Here's an interdiff that I believe addresses your complaints:
>
>
...
> @@ -1690,8 +1691,48 @@
> %
> :- func synthetic_term_to_doc(string, list(univ), maybe(univ)) = doc.
>
> -synthetic_term_to_doc(Functor, Args, no) = format_term(Functor, Args).
> -synthetic_term_to_doc(Functor, Args, yes(Return)) =
> - docs([format_term(Functor, Args), str(" = "), format_univ(Return)]).
> +synthetic_term_to_doc(Functor0, Args, MaybeReturn) = Doc :-
Add a comment here saying why the following needs to be done (i.e.
because the proc_layout stores the qualified functor as a string with
dots as module qualifiers).
> + ( if
> + ( Functor0 = "!."
> + ; Functor0 = "."
> + ; Functor0 = ".."
> + ; Functor0 = "=.."
> + ; not string.contains_char(Functor0, ('.'))
> + )
> + then
> + Doc0 = format_term(Functor0, Args)
> + else
> + FunctorDoc = parts_to_doc(string.split_at_char(('.'), Functor0)),
> + (
> + Args = [],
> + Doc0 = FunctorDoc
> + ;
> + Args = [_ | _],
> + Doc0 = indent([
> + FunctorDoc, str("("),
> + format_list(Args, group([str(", "), nl])),
> + str(")")
> + ])
> + )
> + ),
> + (
> + MaybeReturn = no,
> + Doc = Doc0
> + ;
> + MaybeReturn = yes(Return),
> + Doc = docs([Doc0, str(" = "), format_arg(format_univ(Return))])
> + ).
> +
> +%-----------------------------------------------------------------------------%
> +
> +:- func parts_to_doc(list(string)) = doc.
> +
> +parts_to_doc([]) = str("").
> +
> +parts_to_doc([Part]) = str(term_io.quoted_atom(Part)).
> +
> +parts_to_doc([PartA, PartB | Parts]) =
> + docs([str(term_io.quoted_atom(PartA)), str("."),
> + parts_to_doc([PartB | Parts])]).
>
Can you give this function a more descriptive name, for example
qualified_functor_to_doc.
Otherwise it looks fine, thanks.
Ian.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list