[m-rev.] for review: add `mode' command to interactive term browser

Julien Fischer juliensf at cs.mu.OZ.AU
Mon Jan 17 02:12:29 AEDT 2005


On Thu, 6 Jan 2005, Ian MacLarty wrote:

> This is like the 3rd time I'm trying to send this email - doesn't seem
> to want to come through for some reason...
>
> For review by anyone.
>
> Estimated hours taken: 5
> Branches: main
>
> Add `mode' command to interactive term browser to display the mode of a
> sub-term.  At the moment this command only works when the term browser is
> invoked from inside the declarative debugger.
>
> browser/browser_info.m
> 	Allow a function to be passed to the browser which it can call to
> 	work out the mode of a sub-term.
>
> browser/browse.m
> 	Export versions of the browser invocation predicates that don't
> 	accept a mode function.
>
> 	Handle the `mode' browser command by calling the supplied function
> 	if it's present.
>
> 	Document the `mode' command in the browser help message.
>
> browser/declarative_debugger.m
> 	To determine the mode of a sub-term we compare the state of
> 	instantiation of the sub-term at the CALL event and at the EXIT, FAIL
> 	or EXCP event.  To do this we need the initial and final
> 	atoms for incorrect contour bugs and wrong answer nodes (for
> 	other nodes the initial and final atoms are the same).
>
> browser/declarative_oracle.m
> 	The wrong_answer functor now has 3 arguments.
>
Why does it now have 3 arguments?  That statement by itself is not
particularly helpful.


> browser/declarative_tree.m
> 	Export trace_atom_subterm_is_ground/3 for use in declarative_user.m.
>
> 	Include the initial atom in wrong answer nodes and incorrect contour
> 	bugs.
>
> browser/declarative_user.m
> 	Add function arg_num_to_arg_pos to replace some duplicated code.
>
> 	Alter the edt_node_trace_atom predicate to find the initial and the
> 	final atoms for a question.
>
> 	Add a function to find the mode of a sub-term given the path to the
> 	sub-term and the initial and final atoms.  Pass this function to
> 	the browser so it can work out the mode of a sub-term.
>
> browser/parse.m
> 	Parse `mode' command.
>
> tests/debugger/declarative/Mmakefile
> tests/debugger/declarative/browser_mode.exp
> tests/debugger/declarative/browser_mode.inp
> tests/debugger/declarative/browser_mode.m
> 	Test the `mode' command.
>
> Index: browser/browse.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/browser/browse.m,v
> retrieving revision 1.48
> diff -u -r1.48 browse.m
> --- browser/browse.m	11 Dec 2004 01:59:50 -0000	1.48
> +++ browser/browse.m	5 Jan 2005 05:03:42 -0000
> @@ -25,10 +25,30 @@
>  :- import_module io, std_util, list.
>
>  	% The interactive term browser.  The caller type will be `browse', and
> +	% the default format for the `browse' caller type will be used.  Since
> +	% this predicate is exported to be used by C code, no mode function
> +	% can be supplied.
> +	%
It would proably be better to refer to it consistently as a "browse mode
function" rather than a "mode function".

...

>  	% The browser interface for the external debugger.  The caller type
>  	% will be `browse', and the default format will be used.
> +	% This version is exported for use in C code, so no mode functin
> +	% can be supplied.
>  	%
s/functin/function/

> -:- pred browse__browse_external(T::in, io__input_stream::in,
> +:- pred browse__browse_external_no_modes(T::in, io__input_stream::in,
>  	io__output_stream::in,
>  	browser_persistent_state::in, browser_persistent_state::out,
>  	io::di, io::uo) is cc_multi.
>
> +	% The browser interface for the external debugger.  The caller type
> +	% will be `browse', and the default format will be used.
> +	%
> +:- pred browse__browse_external(T::in, io__input_stream::in,
> +	io__output_stream::in, maybe(browser_mode_func)::in,
> +	browser_persistent_state::in, browser_persistent_state::out,
> +	io::di, io::uo) is cc_multi.
> +
>  	% The non-interactive term browser.  The caller type should be either
>  	% `print' or `print_all'.  The default portray format for that
>  	% caller type is used.

...

> +	% A signature for functions that can be used by the browser to work
> +	% out the mode of a sub-term.
> +	%
> +:- type browser_mode_func == (func(list(dir)) = browser_term_mode).
> +
> +	% The possible modes of a sub-term in the browser.  Note these do
> +	% not correspond directly with the declared Mercury modes.
> +	%
> +:- type browser_term_mode
> +			% The sub-term is bound at the call.  This could
> +			% correspond to the Mercury modes `in', `di', `ui',
> +			% etc.

I suggest something like:

	The sub-term is bound at the cell.  For example
	the Mercury builtin modes, `in', `di' and `ui'.

Likewise below:


> +	--->	input
> +			% The sub-term is unbound at the call.  The call
> +			% succeeded and bound the sub-term.  This could
> +			% correspond to the Mercury modes `out', `uo', etc.
> +	;	output
> +			% The sub-term is unbound at the call and at the
> +			% final EXIT, FAIL or EXCP event.
> +	;	unbound
> +			% If the user asks about the mode of an atom, this
> +			% value should be returned by the mode function.
> +	;	not_applicable.
> +
>  :- type dir
>  	--->	parent
>  	;	child_num(int)

...

> Index: tests/debugger/declarative/browser_mode.m
> ===================================================================
> RCS file: tests/debugger/declarative/browser_mode.m
> diff -N tests/debugger/declarative/browser_mode.m
> --- /dev/null	1 Jan 1970 00:00:00 -0000
> +++ tests/debugger/declarative/browser_mode.m	5 Jan 2005 04:01:38 -0000
> @@ -0,0 +1,57 @@
> +:- module browser_mode.
> +:- interface.
> +:- import_module io.
> +:- pred main(io__state::di, io__state::uo) is det.
> +:- implementation.
> +:- import_module int, std_util.
> +
> +main -->
> +	( { p('a', X), test(X) } ->
> +		io__write_string("yes\n")
> +	;
> +		io__write_string("no\n")
> +	).
> +
> +:- pred test(int).
> +:- mode test(in) is semidet.
> +
> +test(_) :-
> +	semidet_fail.
> +
> +:- pred p(character, int).
I'd suggest s/character/char/ there - see the comments at the start of
char.m (and below).

> +:- mode p(in, out) is nondet.
> +
> +p(A, D) :-
> +	q(A, B),
> +	(
> +		r(B, C)
> +	->
> +		(
> +			s(C, D)
> +		;
> +			D = 31
> +		)
> +	;
> +		not(
> +			q(B, _)
> +		),
> +		D = 32
> +	).
> +
> +:- pred q(character, character).
> +:- mode q(in, out) is nondet.
> +
> +q('a', 'a').
> +q('a', 'b').
> +q('c', 'c').
> +
> +:- pred r(character, int).

That looks fine otherwise.

Cheers,
Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list