mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-18 19:03:45 +00:00
library/dir.m:
As above, previously this just threw a string on a brace mismatch.
tests/hard_coded/brace.m:
Replace the use of '__' as a module qualifier.
50 lines
1.1 KiB
Mathematica
50 lines
1.1 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
:- module brace.
|
|
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module dir.
|
|
:- import_module list.
|
|
|
|
main(!IO) :-
|
|
list.foldl(expand_print, test_inputs, !IO).
|
|
|
|
:- pred expand_print(string::in, io::di, io::uo) is det.
|
|
|
|
expand_print(Arg, !IO) :-
|
|
io.write_string(Arg, !IO),
|
|
io.nl(!IO),
|
|
write_expansions(expand_braces(Arg), !IO).
|
|
|
|
:- pred write_expansions(list(string)::in, io::di, io::uo) is det.
|
|
|
|
write_expansions([], !IO).
|
|
write_expansions([Str | Strs], !IO) :-
|
|
io.write_string(" ", !IO),
|
|
io.write_string(Str, !IO),
|
|
io.nl(!IO),
|
|
write_expansions(Strs, !IO).
|
|
|
|
:- func test_inputs = list(string).
|
|
|
|
test_inputs = [
|
|
"abc",
|
|
"{a,b}",
|
|
"a{b,c}d",
|
|
"aa{bb,cc}dd",
|
|
"aa{bb,cc,{d,e}}ff",
|
|
"aa{{b1,b2,b3},cc,{d,e}}ff",
|
|
"aa{{b1,{b21,b22,b23},b3},cc,{d,e}}ff",
|
|
"a{b,c}d{e,f,g}h",
|
|
"aa{bb,cc,{{d1,d2},e}}ff{g,hh}"
|
|
].
|