Files
mercury/browser/browse_test.m
Bert Thompson eee1996975 Add a simple term browser for use by the trace-based debugger.
Estimated hours taken: 40

Add a simple term browser for use by the trace-based debugger.

This is minimal but useful browser. Not included in this version
are a scripting language, Windows Explorer-style tree expansion,
and other features not yet thought of.

N.B. This still needs to be hooked into the debugger.

browser/Mmakefile:
	Added target browse_test.

browser/browser_library.m:
	Added modules required for the browser.

browser/browse_test.m:
	A simple driver for the browser with an example
	data structure to browse. (new file)

browser/browse.m:
	The browser proper. (new file)

browser/parse.m:
	Parser for browser's command language. (new file)

browser/util.m:
	Miscellaneous utilities used in the browser code. (new file)

browser/frame.m:
	Bare minimal ASCII graphics frames. (new file)
1998-10-25 07:16:41 +00:00

57 lines
1.5 KiB
Mathematica

%---------------------------------------------------------------------------%
% Copyright (C) 1998 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.
%---------------------------------------------------------------------------%
% browse_test - Driver to test the browser.
%
% authors: aet
% stability: low
:- module browse_test.
:- interface.
:- import_module io.
:- pred main(io__state, io__state).
:- mode main(di, uo) is det.
:- implementation.
:- import_module browse, list, string, int, std_util, tree234, assoc_list.
main -->
{ Filename = "/etc/hosts" },
{ EXIT_FAILURE = 1 },
{ EXIT_SUCCESS = 0 },
io__see(Filename, Result),
( { Result = error(_) } ->
io__write_string("Can't open input file.\n"),
io__set_exit_status(EXIT_FAILURE)
;
read_words(Words),
io__seen,
{ assoc_list__from_corresponding_lists(Words, Words,
AssocList) },
{ tree234__assoc_list_to_tree234(AssocList, Tree) },
{ type_to_univ(Tree, Univ) },
browse__browse(Univ),
io__set_exit_status(EXIT_SUCCESS)
).
:- pred read_words(list(string), io__state, io__state).
:- mode read_words(out, di, uo) is det.
read_words(Words) -->
io__read_word(Result),
( { Result = ok(Chars) } ->
{ string__from_char_list(Chars, Word) },
read_words(Rest),
{ Words = [Word|Rest] }
;
{ Words = [] }
).
%---------------------------------------------------------------------------%