Files
mercury/browser/browse_test.m
Julien Fischer 459847a064 Move the univ, maybe, pair and unit types from std_util into their own
Estimated hours taken: 18
Branches: main

Move the univ, maybe, pair and unit types from std_util into their own
modules.  std_util still contains the general purpose higher-order programming
constructs.

library/std_util.m:
	Move univ, maybe, pair and unit (plus any other related types
	and procedures) into their own modules.

library/maybe.m:
	New module.  This contains the maybe and maybe_error types and
	the associated procedures.

library/pair.m:
	New module.  This contains the pair type and associated procedures.

library/unit.m:
	New module. This contains the types unit/0 and unit/1.

library/univ.m:
	New module. This contains the univ type and associated procedures.

library/library.m:
	Add the new modules.

library/private_builtin.m:
	Update the declaration of the type_ctor_info struct for univ.

runtime/mercury.h:
	Update the declaration for the type_ctor_info struct for univ.

runtime/mercury_mcpp.h:
runtime/mercury_hlc_types.h:
	Update the definition of MR_Univ.

runtime/mercury_init.h:
	Fix a comment: ML_type_name is now exported from type_desc.m.

compiler/mlds_to_il.m:
	Update the the name of the module that defines univs (which are
	handled specially by the il code generator.)

library/*.m:
compiler/*.m:
browser/*.m:
mdbcomp/*.m:
profiler/*.m:
deep_profiler/*.m:
	Conform to the above changes.  Import the new modules where they
	are needed; don't import std_util where it isn't needed.

	Fix formatting in lots of modules.  Delete duplicate module
	imports.

tests/*:
	Update the test suite to confrom to the above changes.
2006-03-29 08:09:58 +00:00

76 lines
2.3 KiB
Mathematica

%---------------------------------------------------------------------------%
% vim: ft=mercury ts=4 sw=4 et
%---------------------------------------------------------------------------%
% Copyright (C) 1998-2000, 2003, 2005-2006 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::di, io::uo) is cc_multi.
:- implementation.
:- import_module mdb.
:- import_module mdb.browse.
:- import_module mdb.browser_info.
:- import_module assoc_list.
:- import_module int.
:- import_module list.
:- import_module string.
:- import_module tree234.
main(!IO) :-
Filename = "/etc/fstab",
EXIT_FAILURE = 1,
EXIT_SUCCESS = 0,
io.open_input(Filename, Result, !IO),
( Result = ok(WordsStream) ->
read_words(WordsStream, Words, !IO),
io.close_input(WordsStream, !IO),
assoc_list.from_corresponding_lists(Words, Words, AssocList),
tree234.assoc_list_to_tree234(AssocList, Tree),
io.stdin_stream(StdIn, !IO),
io.stdout_stream(StdOut, !IO),
browser_info.init_persistent_state(State0),
io.write_string("list:", !IO),
io.nl(!IO),
browse.browse(AssocList, StdIn, StdOut, _, State0, State1, !IO),
io.write_string("tree:", !IO),
io.nl(!IO),
browse.browse(Tree, StdIn, StdOut, _, State1, State2, !IO),
io.write_string("stream:", !IO),
io.nl(!IO),
browse.browse(StdIn, StdIn, StdOut, _, State2, _, !IO),
io.set_exit_status(EXIT_SUCCESS, !IO)
;
io.write_string("Can't open input file.\n", !IO),
io.set_exit_status(EXIT_FAILURE, !IO)
).
:- pred read_words(io.input_stream::in, list(string)::out,
io.state::di, io.state::uo) is det.
read_words(Stream, Words, !IO) :-
io.read_word(Stream, Result, !IO),
( Result = ok(Chars) ->
string.from_char_list(Chars, Word),
read_words(Stream, Rest, !IO),
Words = [Word | Rest]
;
Words = []
).
%---------------------------------------------------------------------------%