mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-14 05:12:33 +00:00
Estimated hours taken: 1 Make all the modules in the browser library sub-modules of module `mdb', to avoid link errors when users use module names such as `parse'. browser/Mmakefile: browser/browser_library.m: browser/mdb.m: Rename browser_library.m to mdb.m. Change `:- import_module' declarations to `:- include_module' declarations. browser/Mmakefile: Remove the special case rule for `mer_browser.init' -- it doesn't work when the file names are not the same as the module name. Instead, the default rule for `mdb.init' is used and the output is copied to `mer_browser.init'. browser/.cvsignore: Rename header files, etc. browser/*.m: Add a `mdb__' prefix to the names of modules in the browser library in `:- module' and `:- import_module' declarations. trace/*.c: Rename the header files for the browser library in `#include' statements. tests/hard_coded/Mmakefile: tests/hard_coded/parse.m: tests/hard_coded/parse.exp: Test case.
60 lines
1.6 KiB
Mathematica
60 lines
1.6 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% Copyright (C) 1998-2000 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 list, string, int, std_util, tree234, assoc_list.
|
|
:- import_module mdb, mdb__browse.
|
|
|
|
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) },
|
|
io__stdin_stream(StdIn),
|
|
io__stdout_stream(StdOut),
|
|
browse__init_state(State),
|
|
browse__browse(Tree, StdIn, StdOut, State, _),
|
|
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 = [] }
|
|
).
|
|
|
|
%---------------------------------------------------------------------------%
|