fixes to test suite for `__' as module qualifier
Fergus Henderson
fjh at cs.mu.oz.au
Sun Feb 23 11:38:08 AEDT 1997
Hi all,
Here's the diff for various fixes to the test cases so that they work
with `__' as a module qualifier.
Zoltan or Tom, can you please review the changes described in the log message?
The diff is also attached, but it's probably not worth reviewing.
I'm a bit concerned about the amount of existing code that is broken by
making `__' as a module qualfier, but I don't see any good alternative.
------------------------------------------------------------
Estimated hours: 1.5
Various fixes to the test cases so that they work with `__'
as a module qualifier.
tests/general/commit_bug.m:
tests/general/mode_info_bug.m:
tests/general/partition.m:
tests/hard_coded/string_alignment.m:
Delete `nl' predicate (and replace calls with calls to `io__nl')
to avoid ambiguities with `io__nl'.
tests/general/partition.m:
Rename `write' as `write_s'
to avoid ambiguities with `io__write'.
tests/warnings/singleton_test.m:
tests/warnings/singleton_test.exp:
tests/warnings/pragma_source_code.m:
tests/warnings/pragma_source_code.exp:
s/append/my_append/g
to avoid ambiguities with `list__append'.
tests/general/parse_list.m:
tests/general/semidet_map.m:
s/meta__/meta_/g
to avoid errors about defining `meta__blah' in a module
other than `meta'.
tests/hard_coded/qual_strang.m:
tests/hard_coded/qual_strung.m:
s/string__//g
to avoid errors about defining `string__blah' in a module
other than `string'.
tests/valid/middle_rec_bug.m:
s/garbage_out__/garbage_out_/g
to avoid errors about defining `garbage_out__blah' in a module
other than `garbage_out'.
tests/hard_coded/qual_basic_test.m:
tests/hard_coded/qual_adv_test.m:
Eliminate double quantifiers, e.g. delete the `io__' in
`io:io__write_string'.
Also test calling `write_string' without `io:' or `io__'.
cvs diff: Diffing .
cvs diff: Diffing benchmarks
cvs diff: Diffing general
Index: general/commit_bug.m
===================================================================
RCS file: /home/staff/zs/imp/tests/general/commit_bug.m,v
retrieving revision 1.4
diff -u -r1.4 commit_bug.m
--- commit_bug.m 1996/11/04 07:08:00 1.4
+++ commit_bug.m 1997/02/22 22:48:32
@@ -41,14 +41,10 @@
foo(X, X).
foo(_, 7).
-:- pred nl(io__state::di, io__state::uo) is det.
-nl -->
- io__write_string("\n").
-
:- pred print_intlist(list(int)::in,io__state::di, io__state::uo) is det.
print_intlist([]) --> [].
print_intlist([X|L]) -->
io__write_int(X),
- nl,
+ io__nl,
print_intlist(L).
Index: general/mode_inf_bug.m
===================================================================
RCS file: /home/staff/zs/imp/tests/general/mode_inf_bug.m,v
retrieving revision 1.1
diff -u -r1.1 mode_inf_bug.m
--- mode_inf_bug.m 1996/11/25 09:46:05 1.1
+++ mode_inf_bug.m 1997/02/22 22:51:09
@@ -20,15 +20,14 @@
time(Pred, Count, _InternalCount) -->
( { Pred } ->
- write("yes")
+ write_s("yes")
;
- write("no")
+ write_s("no")
),
- nl,
- write("Count = "), io__write_int(Count), nl.
+ io__nl,
+ write_s("Count = "), io__write_int(Count), nl.
-write(S) --> io__write_string(S).
-nl --> write("\n").
+write_s(S) --> io__write_string(S).
:- type hook ---> hook_is_a.
@@ -96,16 +95,16 @@
test_map_list_2(N) :- gen_a_list(N,L), map_list_2(L,hook_is_a).
test_all(ListSize,Count,InternalCount) -->
- write("Non-meta predicate:"),
+ write_s("Non-meta predicate:"),
time(test_is_a_list_1(ListSize),Count,InternalCount),nl,
%%
- write("Non-meta predicate with call:"),
+ write_s("Non-meta predicate with call:"),
time(test_is_a_list_2(ListSize),Count,InternalCount),nl,
%%
- write("Meta-predicate with call:"),
+ write_s("Meta-predicate with call:"),
time(test_map_list_1(ListSize),Count,InternalCount),nl,
%%
- write("Meta-predicate with hook:"),
+ write_s("Meta-predicate with hook:"),
time(test_map_list_2(ListSize),Count,InternalCount).
test1 --> test_all(1000,10,10).
Index: general/parse_list.m
===================================================================
RCS file: /home/staff/zs/imp/tests/general/parse_list.m,v
retrieving revision 1.1
diff -u -r1.1 parse_list.m
--- parse_list.m 1995/10/06 18:11:57 1.1
+++ parse_list.m 1997/02/23 00:06:47
@@ -10,24 +10,24 @@
:- pred main(io__state::di, io__state::uo) is det.
-:- pred meta__parse_list(pred(Y, Y, X), list(X), Y, Y).
-:- mode meta__parse_list(pred(in, out, out) is semidet, out, in, out) is det.
+:- pred meta_parse_list(pred(Y, Y, X), list(X), Y, Y).
+:- mode meta_parse_list(pred(in, out, out) is semidet, out, in, out) is det.
:- implementation.
:- import_module mercury_builtin, int, string.
main -->
{P = lambda([I::in, O::out, N::out] is semidet, one_or_two(N, I, O))},
- ( {meta__parse_list(P, [X, Y], [2, 1, 3], _)} ->
+ ( {meta_parse_list(P, [X, Y], [2, 1, 3], _)} ->
{string__int_to_string(X, SX)},
{string__int_to_string(Y, SY)},
io__write_strings(["Success: X = ", SX, "; Y = ", SY, ".\n"])
; io__write_string("Failure.\n")
).
-meta__parse_list(P, L, In, Out) :-
+meta_parse_list(P, L, In, Out) :-
( call(P, In, Out0, E) ->
- L = [E|L1], meta__parse_list(P, L1, Out0, Out)
+ L = [E|L1], meta_parse_list(P, L1, Out0, Out)
; L = [], Out = In
).
Index: general/partition.m
===================================================================
RCS file: /home/staff/zs/imp/tests/general/partition.m,v
retrieving revision 1.4
diff -u -r1.4 partition.m
--- partition.m 1996/03/22 02:28:33 1.4
+++ partition.m 1997/02/22 22:54:15
@@ -37,7 +37,7 @@
print_solnlist([Le - Gr | Rest]) -->
print_intlist(Le),
print_intlist(Gr),
- nl,
+ io__nl,
print_solnlist(Rest).
:- pred bug(pair(list(int))::out) is nondet.
@@ -53,11 +53,8 @@
part(X, [Y|L], Le, [Y|Gr]):-
Y > X, part(X, L, Le, Gr).
-:- pred nl(io__state::di, io__state::uo) is det.
-nl --> io__write_string("\n").
-
:- pred print_intlist(list(int)::in,io__state::di, io__state::uo) is det.
-print_intlist([])--> nl.
+print_intlist([])--> io__nl.
print_intlist([X|L])--> io__write_int(X), print_intlist(L).
:- end_module partition.
Index: general/semidet_map.m
===================================================================
RCS file: /home/staff/zs/imp/tests/general/semidet_map.m,v
retrieving revision 1.1
diff -u -r1.1 semidet_map.m
--- semidet_map.m 1995/10/06 18:11:58 1.1
+++ semidet_map.m 1997/02/23 00:08:05
@@ -10,14 +10,14 @@
:- pred main(io__state::di, io__state::uo) is det.
-:- pred meta__semidet_map(pred(X, Y), list(X), list(maybe(Y))).
-:- mode meta__semidet_map(pred(in, out) is semidet, in, out) is det.
+:- pred meta_semidet_map(pred(X, Y), list(X), list(maybe(Y))).
+:- mode meta_semidet_map(pred(in, out) is semidet, in, out) is det.
:- implementation.
:- import_module mercury_builtin, int, string.
main -->
- ( {meta__semidet_map(pos_inc, [0, 1], [X, Y])} ->
+ ( {meta_semidet_map(pos_inc, [0, 1], [X, Y])} ->
{maybe_to_string(string__int_to_string, X, SX)},
{maybe_to_string(string__int_to_string, Y, SY)},
io__write_strings(["Success: X = ", SX, "; Y = ", SY, ".\n"])
@@ -33,8 +33,8 @@
:- pred pos_inc(int::in, int::out) is semidet.
pos_inc(X, Y) :- X > 0, Y is X + 1.
-meta__semidet_map(_, [], []).
-meta__semidet_map(P, [H0|T0], [H|T]) :-
+meta_semidet_map(_, [], []).
+meta_semidet_map(P, [H0|T0], [H|T]) :-
( call(P, H0, H1) -> H = yes(H1) ; H = no ),
- meta__semidet_map(P, T0, T).
+ meta_semidet_map(P, T0, T).
cvs diff: Diffing hard_coded
Index: hard_coded/qual_adv_test.m
===================================================================
RCS file: /home/staff/zs/imp/tests/hard_coded/qual_adv_test.m,v
retrieving revision 1.2
diff -u -r1.2 qual_adv_test.m
--- qual_adv_test.m 1996/10/02 06:09:47 1.2
+++ qual_adv_test.m 1997/02/22 23:07:18
@@ -1,7 +1,7 @@
:- module qual_adv_test.
% A test using module qualification to resolve ambiguous overloading. The
-% three versions of string__format should all produce different output,
+% three versions of `format' should all produce different output,
% despite having the same name, and strang and strung both importing string.m
%
% The implementation predicates are mostly have the same names too, and
@@ -18,14 +18,14 @@
main -->
{ String = "asdfjkfhaslks" },
{ FString = "iii %s.\n"},
- { string:string__format(FString, [s(String)], Out1) },
- io:io__write_string(Out1),
- { qual_strang:string__format(FString, [s(String)], Out2) },
+ { string:format(FString, [s(String)], Out1) },
+ io:write_string(Out1),
+ { qual_strang:format(FString, [s(String)], Out2) },
io__write_string(Out2),
- { qual_strung:string__format(FString, [s(String)], Out3) },
+ { qual_strung:format(FString, [s(String)], Out3) },
io__write_string(Out3),
- { Out4 = qual_strang:string__format_func(FString, [s(String)]) },
- { Out5 = qual_strung:string__format_func(FString, [s(String)]) },
+ { Out4 = qual_strang:format_func(FString, [s(String)]) },
+ { Out5 = qual_strung:format_func(FString, [s(String)]) },
(
{ Out4 = Out2 },
{ Out5 = Out3 }
Index: hard_coded/qual_basic_test.m
===================================================================
RCS file: /home/staff/zs/imp/tests/hard_coded/qual_basic_test.m,v
retrieving revision 1.2
diff -u -r1.2 qual_basic_test.m
--- qual_basic_test.m 1996/10/02 06:09:49 1.2
+++ qual_basic_test.m 1997/02/22 23:15:56
@@ -14,15 +14,15 @@
:- import_module int.
qual_basic_test:main -->
- io:io__write_string("Gotcha1!\n"),
+ io:write_string("Gotcha1!\n"),
{ A is qual_basic_test:test },
{ X is int:(A + 2) },
- io:io__write_int(X),
+ io:write_int(X),
io__write_string("\n"),
- { Pred = int:int__max },
+ { Pred = int:max },
{ call(Pred, 1, 2, Y) },
io__write_int(Y),
- io__write_string("\n").
+ write_string("\n").
:- func test = int.
Index: hard_coded/qual_strang.m
===================================================================
RCS file: /home/staff/zs/imp/tests/hard_coded/qual_strang.m,v
retrieving revision 1.3
diff -u -r1.3 qual_strang.m
--- qual_strang.m 1996/10/02 06:09:50 1.3
+++ qual_strang.m 1997/02/22 23:12:10
@@ -1,5 +1,5 @@
%
-% A module similar to string, with only a string__format exported function.
+% A module similar to string, with only a format exported function.
% Prints everything out in uppercase.
:- module qual_strang.
@@ -7,27 +7,27 @@
:- interface.
:- import_module list, string.
-:- pred string__format(string, list(string__poly_type), string).
-:- mode string__format(in, in, out) is det.
+:- pred format(string, list(poly_type), string).
+:- mode format(in, in, out) is det.
-:- func string__format_func(string, list(string__poly_type)) = string.
-:- mode string__format_func(in, in) = out is det.
+:- func format_func(string, list(poly_type)) = string.
+:- mode format_func(in, in) = out is det.
:- implementation.
:- import_module std_util, char, int, float, require, bool.
-string__format_func(FString, PolyList) = String :-
- qual_strang:string__format(FString, PolyList, String).
+format_func(FString, PolyList) = String :-
+ qual_strang:format(FString, PolyList, String).
-string__format( Fstring, Poly_list, Ostring ) :-
- string__to_char_list(Fstring, Clist),
- string__format_2q(Clist, Poly_list, Ostring) .
+format( Fstring, Poly_list, Ostring ) :-
+ to_char_list(Fstring, Clist),
+ format_2q(Clist, Poly_list, Ostring) .
-:- pred string__format_2q(list(char), list(string__poly_type), string).
-:- mode string__format_2q(in, in, out) is det.
+:- pred format_2q(list(char), list(poly_type), string).
+:- mode format_2q(in, in, out) is det.
%
-% string__format_2q( stream, char_f, vars, IO, IO).
+% format_2q( stream, char_f, vars, IO, IO).
% The main function, with different input types.
%
% Accumulator recursion is not used, as it would involve adding a
@@ -35,73 +35,73 @@
% is not efficient. Instead, many short strings are added to the front
% of a (long) and growing string.
%
-string__format_2q( [], _, "").
-string__format_2q( [Achar|As], Vars_in, Ostring) :-
+format_2q( [], _, "").
+format_2q( [Achar|As], Vars_in, Ostring) :-
(
Achar = '%'
->
(
As = ['%' | Ass]
->
- string__format_2q(Ass, Vars_in, Temp_out),
- string__first_char(Ostring, '%', Temp_out)
+ format_2q(Ass, Vars_in, Temp_out),
+ first_char(Ostring, '%', Temp_out)
;
(
- string__format_top_convert_variable(As, As_out,
+ format_top_convert_variable(As, As_out,
Vars_in, Vars_out, String_1)
->
- string__format_2q(As_out, Vars_out, String_2),
- string__append(String_1, String_2, Ostring)
+ format_2q(As_out, Vars_out, String_2),
+ append(String_1, String_2, Ostring)
;
- error("string__format: Too few variables.")
+ error("format: Too few variables.")
)
)
;
- string__format_2q(As, Vars_in, Temp_out),
- string__first_char(Ostring, Bchar, Temp_out),
+ format_2q(As, Vars_in, Temp_out),
+ first_char(Ostring, Bchar, Temp_out),
char__to_upper(Achar, Bchar)
).
-:- pred string__format_top_convert_variable( list(char), list(char),
- list(string__poly_type), list(string__poly_type), string).
-:- mode string__format_top_convert_variable(in, out, in, out, out) is semidet.
+:- pred format_top_convert_variable( list(char), list(char),
+ list(poly_type), list(poly_type), string).
+:- mode format_top_convert_variable(in, out, in, out, out) is semidet.
%
-% string__format_top_convert_variable( formated string in, out, var in, out,
+% format_top_convert_variable( formated string in, out, var in, out,
% Out string)
% Return a string of the formatted variable.
%
-string__format_top_convert_variable(['%'|Bs], Bs, [], [], "%").
+format_top_convert_variable(['%'|Bs], Bs, [], [], "%").
% Above rule should not be executed... defensive rule.
-string__format_top_convert_variable( F_chars_in, F_chars_out,
+format_top_convert_variable( F_chars_in, F_chars_out,
[Var_in|Vars_l_in], Vars_out, Out_string ) :-
- string__format_takewhile1( F_chars_in, [Conv_char_0|F_chars_out],
+ format_takewhile1( F_chars_in, [Conv_char_0|F_chars_out],
Fmt_info),
% Seperate formatting info from formatting string.
% in, out, out
- string__format_get_optional_args( Fmt_info, Flags, Int_width,
+ format_get_optional_args( Fmt_info, Flags, Int_width,
Int_precis, Conv_modify),
% Parse formatting info.
% in, out, out, out, out.
- string__format_mod_conv_char( Precision, Var_in, Conv_char_1,
+ format_mod_conv_char( Precision, Var_in, Conv_char_1,
Conv_char_0),
% Modify(?) conversion character.
% in, in, out, in
- string__format_do_mod_char( Conv_modify, Conv_char_2, Conv_char_1),
+ format_do_mod_char( Conv_modify, Conv_char_2, Conv_char_1),
% Interperate input conversion modifiers.
% in, out, in
- string__format_read_star( Vars_out, Vars_l_in, Width, Int_width,
+ format_read_star( Vars_out, Vars_l_in, Width, Int_width,
Precision, Int_precis),
% Do something if a precision or width was '*'
% out, in, out, in, out, in
- string__format_do_conversion(Conv_char_2, Var_in, Ostring, Precision,
+ format_do_conversion(Conv_char_2, Var_in, Ostring, Precision,
Flags, Move_i0),
% Actually convert a Variable to a string
% in, out, in, in, out, in, in, out
- string__format_add_sign( Ostring2, Ostring, Flags, Var_in, Move_i0,
+ format_add_sign( Ostring2, Ostring, Flags, Var_in, Move_i0,
Move_i1),
% Adds an optional '+' or ' ' to string.
% out, in, in, in, in, out
- string__format_pad_width( Ostring2, Width, Flags, Out_string, Move_i1).
+ format_pad_width( Ostring2, Width, Flags, Out_string, Move_i1).
% Ensures that the string is at least width.
% in, in, in, out, in
@@ -111,15 +111,15 @@
% Ideally the outer "->" symbols could be removed, the last case given
% a guard, and the compiler accept this as det, rather than non-det.
%
-:- pred string__format_mod_conv_char( int, string__poly_type, char, char).
-:- mode string__format_mod_conv_char( in, in, out, in) is det.
-string__format_mod_conv_char( Precision, Poly_var, Conv_c_out, Conv_c_in) :-
+:- pred format_mod_conv_char( int, poly_type, char, char).
+:- mode format_mod_conv_char( in, in, out, in) is det.
+format_mod_conv_char( Precision, Poly_var, Conv_c_out, Conv_c_in) :-
( Conv_c_in = 'i' ->
Conv_c_out = 'd' % %d = %i
;
(Conv_c_in = 'g' -> %g is either %e of %f
(Poly_var = f(F) ->
- string__float_abs(F, Ft),
+ float_abs(F, Ft),
int__pow(10, Precision, P),
int__to_float(P, Pe),
(
@@ -131,12 +131,12 @@
Conv_c_out = 'e'
)
;
- error("string__format: %g without a f(Float).")
+ error("format: %g without a f(Float).")
)
;
(Conv_c_in = 'G' -> %G is either %E of %f
(Poly_var = f(F) ->
- string__float_abs(F, Ft),
+ float_abs(F, Ft),
int__pow(10, Precision, P),
int__to_float(P, Pe),
(
@@ -148,7 +148,7 @@
Conv_c_out = 'E'
)
;
- error("string__format: %G without a f(float).")
+ error("format: %G without a f(float).")
)
;
Conv_c_out = Conv_c_in
@@ -159,9 +159,9 @@
%
% Another function that would be better off as a switch.
%
-:- pred string__format_do_mod_char( char, char, char).
-:- mode string__format_do_mod_char( in, out, in) is det.
-string__format_do_mod_char( Char_mods, C_out, C_in) :-
+:- pred format_do_mod_char( char, char, char).
+:- mode format_do_mod_char( in, out, in) is det.
+format_do_mod_char( Char_mods, C_out, C_in) :-
(
Char_mods = 'h'
->
@@ -181,11 +181,11 @@
%
% Change Width or Precision value, if '*' was spcified
%
-:- pred string__format_read_star( list(string__poly_type), list(string__poly_type), int, int, int, int).
-:- mode string__format_read_star( out, in, out, in, out, in) is semidet.
-string__format_read_star( Polys_out, Polys_in, Width, Int_width, Precision, Int_precis) :-
+:- pred format_read_star( list(poly_type), list(poly_type), int, int, int, int).
+:- mode format_read_star( out, in, out, in, out, in) is semidet.
+format_read_star( Polys_out, Polys_in, Width, Int_width, Precision, Int_precis) :-
(
- string__special_precision_and_width(Int_width)
+ special_precision_and_width(Int_width)
->
Polys_in = [ i(Width) | Poly_temp]
;
@@ -193,7 +193,7 @@
Int_width = Width
),
(
- string__special_precision_and_width(Int_precis)
+ special_precision_and_width(Int_precis)
->
Poly_temp = [ i(Precision) | Polys_out]
;
@@ -205,39 +205,39 @@
%
% This function did the variable conversion to string.
-% Now done by string__do_conversion_0/6.
+% Now done by do_conversion_0/6.
%
%
% Mv_width records the length of the prefix in front of the number,
% so that it is more easy to insert width and precision padding and
% optional signs, in the correct place.
%
-:- pred string__format_do_conversion( char, string__poly_type, string, int,
+:- pred format_do_conversion( char, poly_type, string, int,
list(char), int).
-:- mode string__format_do_conversion( in, in, out, in, in, out)
+:- mode format_do_conversion( in, in, out, in, in, out)
is det.
-string__format_do_conversion( Conv_c, Poly_t, Ostring, Precision, Flags,
+format_do_conversion( Conv_c, Poly_t, Ostring, Precision, Flags,
Mv_width) :-
(
- string__do_conversion_0(Conv_c, Poly_t, Tstring, Precision,
+ do_conversion_0(Conv_c, Poly_t, Tstring, Precision,
Flags, TMv_width)
->
TMv_width = Mv_width,
Ostring = Tstring
;
- string__do_conversion_fail(Conv_c)
+ do_conversion_fail(Conv_c)
).
-:- pred string__do_conversion_0(char, string__poly_type, string, int,
+:- pred do_conversion_0(char, poly_type, string, int,
list(char), int).
-:- mode string__do_conversion_0(in, in, out, in, in, out) is semidet.
-string__do_conversion_0(Conv_c, Poly_t, Ostring, Precision, Flags,
+:- mode do_conversion_0(in, in, out, in, in, out) is semidet.
+do_conversion_0(Conv_c, Poly_t, Ostring, Precision, Flags,
Mv_width) :-
(
Conv_c = 'd',
Poly_t = i(I),
- string__int_to_string(I, S),
- string__format_int_precision(S, Ostring, Precision, _),
+ int_to_string(I, S),
+ format_int_precision(S, Ostring, Precision, _),
(
I < 0
->
@@ -251,13 +251,13 @@
Poly_t = i(I),
( I = 0 ->
S = "0",
- string__format_int_precision(S, Ostring, Precision, _),
+ format_int_precision(S, Ostring, Precision, _),
Pfix_len = 0
;
- string__int_to_base_string(I, 8, S),
- string__format_int_precision(S, SS, Precision, _),
+ int_to_base_string(I, 8, S),
+ format_int_precision(S, SS, Precision, _),
( list__member('#', Flags) ->
- string__first_char(Ostring, '0', SS),
+ first_char(Ostring, '0', SS),
Pfix_len = 1
;
Ostring = SS,
@@ -271,14 +271,14 @@
( I = 0 ->
SS = "0",
Pfix_len = 0,
- string__format_int_precision(SS, Ostring, Precision, _)
+ format_int_precision(SS, Ostring, Precision, _)
;
- string__int_to_base_string(I, 16, S),
- string__format_int_precision(S, SS, Precision, _),
+ int_to_base_string(I, 16, S),
+ format_int_precision(S, SS, Precision, _),
(
list__member( '#', Flags)
->
- string__append( "0x", SS, Ostring),
+ append( "0x", SS, Ostring),
Pfix_len = 2
;
Ostring = SS,
@@ -292,13 +292,13 @@
( I = 0 ->
SS = "0",
Pfix_len = 0,
- string__format_int_precision(SS, Ostring, Precision, _)
+ format_int_precision(SS, Ostring, Precision, _)
;
- string__int_to_base_string(I, 16, Otemp),
- string__to_upper(Otemp, S),
- string__format_int_precision(S, SS, Precision, _),
+ int_to_base_string(I, 16, Otemp),
+ to_upper(Otemp, S),
+ format_int_precision(S, SS, Precision, _),
( list__member( '#', Flags) ->
- string__append( "0X", SS, Ostring),
+ append( "0X", SS, Ostring),
Pfix_len = 2
;
SS = Ostring,
@@ -310,85 +310,85 @@
Conv_c = 'u' ,
Poly_t = i(I),
int__abs(I, J),
- string__int_to_string(J, S),
- string__format_int_precision(S, Ostring, Precision, Mvt),
+ int_to_string(J, S),
+ format_int_precision(S, Ostring, Precision, Mvt),
Mv_width = Mvt
;
Conv_c = 'c' ,
Poly_t = c(C),
- string__char_to_string( C, Ostring),
+ char_to_string( C, Ostring),
Mv_width = 0
;
Conv_c = 's' ,
Poly_t = s(S),
- ( string__default_precision_and_width(Precision) ->
- string__to_upper(S, T),
+ ( default_precision_and_width(Precision) ->
+ to_upper(S, T),
T = Ostring
;
- string__split(S, Precision, Ostring, _)
+ split(S, Precision, Ostring, _)
),
Mv_width = 0
;
Conv_c = 'f' ,
Poly_t = f(F),
- string__float_to_string(F, Fstring),
- string__format_calc_prec(Fstring, Ostring, Precision),
+ float_to_string(F, Fstring),
+ format_calc_prec(Fstring, Ostring, Precision),
(builtin_float_lt(F, 0.0)-> Mv_width = 1 ; Mv_width = 0)
;
Conv_c = 'e',
Poly_t = f(F),
- string__format_calc_exp(F, Ostring, Precision, 0),
+ format_calc_exp(F, Ostring, Precision, 0),
(builtin_float_lt(F, 0.0)-> Mv_width = 1 ; Mv_width = 0)
;
Conv_c = 'E' ,
Poly_t = f(F),
- string__format_calc_exp(F, Otemp, Precision, 0),
- string__to_upper(Otemp, Ostring),
+ format_calc_exp(F, Otemp, Precision, 0),
+ to_upper(Otemp, Ostring),
(builtin_float_lt(F, 0.0)-> Mv_width = 1 ; Mv_width = 0)
;
Conv_c = 'p' ,
Poly_t = i(I),
- string__int_to_string(I, Ostring),
+ int_to_string(I, Ostring),
((I < 0) -> Mv_width = 1 ; Mv_width = 0)
).
-:- pred string__do_conversion_fail(char).
-:- mode string__do_conversion_fail(in) is erroneous.
-string__do_conversion_fail(Conv_c) :-
- qual_strang:string__format("%s `%%%c', without a correct poly-variable.",
- [s("string__format: statement has used type"), c(Conv_c)],
+:- pred do_conversion_fail(char).
+:- mode do_conversion_fail(in) is erroneous.
+do_conversion_fail(Conv_c) :-
+ qual_strang:format("%s `%%%c', without a correct poly-variable.",
+ [s("format: statement has used type"), c(Conv_c)],
Error_message),
error(Error_message).
%
% Use precision information to modify string. - for integers
%
-:- pred string__format_int_precision(string, string, int, int).
-:- mode string__format_int_precision( in, out, in, out) is semidet.
-string__format_int_precision(S, Ostring, Precision, Added_width) :-
- ( string__default_precision_and_width(Precision) ->
+:- pred format_int_precision(string, string, int, int).
+:- mode format_int_precision( in, out, in, out) is semidet.
+format_int_precision(S, Ostring, Precision, Added_width) :-
+ ( default_precision_and_width(Precision) ->
Prec = 0
;
Prec = Precision
),
- string__length(S, L),
- ( string__first_char(S, '-', _) ->
+ length(S, L),
+ ( first_char(S, '-', _) ->
Xzeros is Prec - L + 1
;
Xzeros is Prec - L
),
Added_width = Xzeros,
( Xzeros > 0 ->
- string__duplicate_char( '0', Xzeros, Pfix),
- string__first_char(S, C, Rest),
+ duplicate_char( '0', Xzeros, Pfix),
+ first_char(S, C, Rest),
(
C \= ('-'),
C \= ('+')
->
- string__append(Pfix, S, Ostring)
+ append(Pfix, S, Ostring)
;
- string__append( Pfix, Rest, Temps),
- string__first_char( Ostring, C, Temps)
+ append( Pfix, Rest, Temps),
+ first_char( Ostring, C, Temps)
)
;
Ostring = S
@@ -396,33 +396,33 @@
% Function to calculate exponent for a %e conversion of a float
%
-:- pred string__format_calc_exp(float, string, int, int).
-:- mode string__format_calc_exp(in, out, in, in) is det.
-string__format_calc_exp(F, Fstring, Precision, Exp) :-
+:- pred format_calc_exp(float, string, int, int).
+:- mode format_calc_exp(in, out, in, in) is det.
+format_calc_exp(F, Fstring, Precision, Exp) :-
( builtin_float_lt(F, 0.0) ->
builtin_float_minus( 0.0, F, Tf),
- string__format_calc_exp( Tf, Tst, Precision, Exp),
- string__first_char(Fstring, '-', Tst)
+ format_calc_exp( Tf, Tst, Precision, Exp),
+ first_char(Fstring, '-', Tst)
;
( builtin_float_lt(F, 1.0) ->
Texp is Exp - 1,
builtin_float_times(F, 10.0, FF),
- string__format_calc_exp( FF, Fstring, Precision, Texp)
+ format_calc_exp( FF, Fstring, Precision, Texp)
;
( builtin_float_ge(F, 10.0) ->
Texp is Exp + 1,
builtin_float_divide(F, 10.0, FF),
- string__format_calc_exp( FF, Fstring, Precision, Texp)
+ format_calc_exp( FF, Fstring, Precision, Texp)
;
- string__float_to_string(F, Fs),
- string__format_calc_prec(Fs, Fs2, Precision),
- string__int_to_string(Exp, Exps),
+ float_to_string(F, Fs),
+ format_calc_prec(Fs, Fs2, Precision),
+ int_to_string(Exp, Exps),
( Exp < 0 ->
- string__append( "e", Exps, TFstring),
- string__append( Fs2, TFstring, Fstring)
+ append( "e", Exps, TFstring),
+ append( Fs2, TFstring, Fstring)
;
- string__append( "e+", Exps, TFstring),
- string__append( Fs2, TFstring, Fstring)
+ append( "e+", Exps, TFstring),
+ append( Fs2, TFstring, Fstring)
)
)
)
@@ -432,40 +432,40 @@
%
% This precision output-modification predicate handles floats.
%
-:- pred string__format_calc_prec(string, string, int).
-:- mode string__format_calc_prec(in, out, in) is det.
-string__format_calc_prec(Istring, Ostring, Precision) :-
+:- pred format_calc_prec(string, string, int).
+:- mode format_calc_prec(in, out, in) is det.
+format_calc_prec(Istring, Ostring, Precision) :-
(
- string__default_precision_and_width(Precision)
+ default_precision_and_width(Precision)
->
Prec = 6
;
Prec = Precision
),
(
- string__find_index( Istring, '.', Index)
+ find_index( Istring, '.', Index)
->
Spa is Prec + Index
;
- string__length(Istring, Spa_0),
+ length(Istring, Spa_0),
Spa is Spa_0 + 1
% This branch should never be called if mercury is implemented
% in ansi-C, according to Kernighan and Ritchie p244, as a
% float converted to a string using sprintf should always have
% a decimal point. (where specified precision != 0.
- % string__float_to_string doesn't specify a precision to be
+ % float_to_string doesn't specify a precision to be
% used.) If a future implementation changes the
- % way string__float_to_string is implemented, and a float can
+ % way float_to_string is implemented, and a float can
% be converted to a string without a decimal point, then this
% rule would be useful. It is not expected that
- % string__float_to_string will ever produce %e style output.
+ % float_to_string will ever produce %e style output.
),
(
- string__length(Istring, L1),
+ length(Istring, L1),
L1 < Spa
->
- string__duplicate_char('0', Precision, P0s),
- string__append( Istring, P0s, Mstring)
+ duplicate_char('0', Precision, P0s),
+ append( Istring, P0s, Mstring)
;
Mstring = Istring
),
@@ -476,73 +476,73 @@
;
Space = Spa
),
- string__split(Mstring, Space, Ostring, _).
+ split(Mstring, Space, Ostring, _).
-% string__find_index is a funky little predicate to find the first
+% find_index is a funky little predicate to find the first
% occurrence of a particular character in a string.
-:- pred string__find_index( string, char, int).
-:- mode string__find_index( in, in, out) is semidet.
-string__find_index(Str, C, Index) :-
- string__to_char_list(Str, List),
- string__find_index_2(List, C, Index).
-
-:- pred string__find_index_2(list(char), char, int).
-:- mode string__find_index_2(in, in, out) is semidet.
-string__find_index_2([], _C, _Index) :- fail.
-string__find_index_2([X|Xs], C, Index) :-
+:- pred find_index( string, char, int).
+:- mode find_index( in, in, out) is semidet.
+find_index(Str, C, Index) :-
+ to_char_list(Str, List),
+ find_index_2(List, C, Index).
+
+:- pred find_index_2(list(char), char, int).
+:- mode find_index_2(in, in, out) is semidet.
+find_index_2([], _C, _Index) :- fail.
+find_index_2([X|Xs], C, Index) :-
(
X = C
->
Index = 1
;
- string__find_index_2(Xs, C, Index0),
+ find_index_2(Xs, C, Index0),
Index is Index0 + 1
).
-%string__find_index( A, Ch, Check, Ret) :-
+%find_index( A, Ch, Check, Ret) :-
% (
-% string__length(A, Len),
+% length(A, Len),
% Len < Check
% ->
% fail
% ;
-% string__index(A, Check, Ch)
+% index(A, Check, Ch)
% ->
% Ret = Check
% ;
% Check2 is Check + 1,
-% string__find_index( A, Ch, Check2, Ret)
+% find_index( A, Ch, Check2, Ret)
% ).
%
% Add a '+' or ' ' sign, if it is needed in this output.
%
-:- pred string__format_add_sign( string, string, list(char), string__poly_type,
+:- pred format_add_sign( string, string, list(char), poly_type,
int, int).
-:- mode string__format_add_sign( out, in, in, in, in, out) is det.
+:- mode format_add_sign( out, in, in, in, in, out) is det.
% Mvw is the prefix-length in front of the number.
-string__format_add_sign( Ostring, Istring, Flags, _V, Mvw1, Mvw2) :-
+format_add_sign( Ostring, Istring, Flags, _V, Mvw1, Mvw2) :-
T1 is Mvw1 - 1,
(
- string__index(Istring, T1, '-')
+ index(Istring, T1, '-')
->
Ostring = Istring,
Mvw2 = Mvw1
;
- string__split(Istring, Mvw1, Lstring, Rstring),
+ split(Istring, Mvw1, Lstring, Rstring),
(
list__member(('+'), Flags)
->
- string__append( "+", Rstring, Astring),
- string__append( Lstring, Astring, Ostring),
+ append( "+", Rstring, Astring),
+ append( Lstring, Astring, Ostring),
Mvw2 is Mvw1 + 1
;
(
list__member(' ', Flags)
->
- string__append( " ", Rstring, Astring),
- string__append( Lstring, Astring, Ostring),
+ append( " ", Rstring, Astring),
+ append( Lstring, Astring, Ostring),
Mvw2 is Mvw1 + 1
;
Ostring = Istring,
@@ -555,11 +555,11 @@
% This function pads some characters to the left or right of a string that is
% shorter than it's width.
%
-:- pred string__format_pad_width( string, int, list(char), string, int).
-:- mode string__format_pad_width( in, in, in, out, in) is det.
+:- pred format_pad_width( string, int, list(char), string, int).
+:- mode format_pad_width( in, in, in, out, in) is det.
% ( String in, width, flags, Output string, #Moveables).
-string__format_pad_width( Istring, Width, Flags, Out_string, Mv_cs) :-
- string__length(Istring, Len),
+format_pad_width( Istring, Width, Flags, Out_string, Mv_cs) :-
+ length(Istring, Len),
(Len < Width ->
% time for some FLAG tests
Xspace is Width - Len,
@@ -570,29 +570,29 @@
;
Pad_char = ' '
),
- string__duplicate_char(Pad_char, Xspace, Pad_string),
+ duplicate_char(Pad_char, Xspace, Pad_string),
(
list__member('-', Flags)
->
- string__append(Istring, Pad_string, Out_string)
+ append(Istring, Pad_string, Out_string)
;
(
list__member('0', Flags)
->
- string__split(Istring, Mv_cs, B4, After),
- string__append( Pad_string, After, Astring),
- string__append( B4, Astring, Out_string)
+ split(Istring, Mv_cs, B4, After),
+ append( Pad_string, After, Astring),
+ append( B4, Astring, Out_string)
;
- string__append( Pad_string, Istring, Out_string)
+ append( Pad_string, Istring, Out_string)
)
)
;
Out_string = Istring
).
-:- pred string__format_get_optional_args( list(char), list(char), int, int, char).
-:- mode string__format_get_optional_args( in, out, out, out, out) is det.
-% string__format_get_optional_args( format info, flags, width, precision, modifier)
+:- pred format_get_optional_args( list(char), list(char), int, int, char).
+:- mode format_get_optional_args( in, out, out, out, out) is det.
+% format_get_optional_args( format info, flags, width, precision, modifier)
% format is assumed to be in ANSI C format.
% p243-4 of Kernighan & Ritchie 2nd Ed. 1988
% "Parse" format informtion.
@@ -603,16 +603,16 @@
% determinism checker does not `see' the equity tests that are hidden one layer
% further down.
%
-string__format_get_optional_args( [], Flags, Width, Precision, Mods) :-
+format_get_optional_args( [], Flags, Width, Precision, Mods) :-
Flags = [],
Width = 0,
- string__default_precision_and_width(Precision),
+ default_precision_and_width(Precision),
Mods = ' '.
-string__format_get_optional_args( [A|As], Flags, Width, Precision, Mods) :-
+format_get_optional_args( [A|As], Flags, Width, Precision, Mods) :-
(
(A = (-) ; A = (+) ; A = ' ' ; A = '0' ; A = '#' )
->
- string__format_get_optional_args( As, Oflags, Width, Precision, Mods),
+ format_get_optional_args( As, Oflags, Width, Precision, Mods),
UFlags = [A | Oflags],
list__sort_and_remove_dups(UFlags, Flags)
;
@@ -620,10 +620,10 @@
( A = (.) ; A = '1' ; A = '2' ; A = '3' ; A = '4' ;
A = '5' ; A = '6' ; A = '7' ; A = '8' ; A = '9' )
->
- string__format_string_to_ints([A|As], Bs, Numl1, Numl2, yes),
- string__format_int_from_char_list( Numl1, Width),
- string__format_int_from_char_list( Numl2, Prec),
- string__format_get_optional_args( Bs, Flags, _, Ptemp, Mods),
+ format_string_to_ints([A|As], Bs, Numl1, Numl2, yes),
+ format_int_from_char_list( Numl1, Width),
+ format_int_from_char_list( Numl2, Prec),
+ format_get_optional_args( Bs, Flags, _, Ptemp, Mods),
(Numl2 = [] ->
Precision = Ptemp
;
@@ -633,45 +633,45 @@
( ( A = 'h' ; A = 'l' ; A = 'L' )
->
Mods = A,
- string__format_get_optional_args( As, Flags, Width, Precision, _)
+ format_get_optional_args( As, Flags, Width, Precision, _)
;
( A = ('*')
->
- string__format_get_optional_args( As, Flags, W, P, Mods),
+ format_get_optional_args( As, Flags, W, P, Mods),
(
As = [(.)|_]
->
Precision = P,
- string__special_precision_and_width(Width)
+ special_precision_and_width(Width)
;
Width = W,
- string__special_precision_and_width(Precision)
+ special_precision_and_width(Precision)
)
% (
-% string__default_precision_and_width(P)
+% default_precision_and_width(P)
% ->
-% string__special_precision_and_width(Precision)
+% special_precision_and_width(Precision)
% ;
% Precision = P
% ),
-% string__special_precision_and_width(Width)
+% special_precision_and_width(Width)
;
- error("string__format: Unrecognised formatting information\n")
+ error("format: Unrecognised formatting information\n")
)
))) .
-:- pred string__format_takewhile1(list(char), list(char), list(char)).
-:- mode string__format_takewhile1(in, out, out) is det.
-% string__format_takewhile(formatted string in, out, format info).
-% A HACK. Would be much nicer with a proper string__takewhile.
+:- pred format_takewhile1(list(char), list(char), list(char)).
+:- mode format_takewhile1(in, out, out) is det.
+% format_takewhile(formatted string in, out, format info).
+% A HACK. Would be much nicer with a proper takewhile.
% Looses the format info from the front of the first argument,
% puts this in the last argument, while the second is the
% remainder of the string.
%
% XXXXXX
%
-string__format_takewhile1([], [], []).
-string__format_takewhile1( [A|As], Rem, Finf) :-
+format_takewhile1([], [], []).
+format_takewhile1( [A|As], Rem, Finf) :-
(
( A = 'd' ; A = 'i' ; A = 'o' ; A = 'x' ; A = 'X' ; A = 'u' ;
A = 's' ; A = '%' ; A = 'c' ; A = 'f' ; A = 'e' ; A = 'E' ;
@@ -680,30 +680,30 @@
Rem = [A|As],
Finf = []
;
- string__format_takewhile1(As, Rem, F),
+ format_takewhile1(As, Rem, F),
Finf = [A|F]
).
-:- pred string__format_string_to_ints(list(char), list(char), list(char), list(char), bool).
-:- mode string__format_string_to_ints(in, out, out, out, in) is det.
+:- pred format_string_to_ints(list(char), list(char), list(char), list(char), bool).
+:- mode format_string_to_ints(in, out, out, out, in) is det.
% ( String in, out, Number1, Number2, seen '.' yet?)
% Takes in a char list and splits off the rational number at the
% start of the list. This is split into 2 parts - an int and a
% fraction.
%
-string__format_string_to_ints( [], [], [], [], _).
-string__format_string_to_ints( [A|As], Bs, Int1, Int2, Bool) :-
+format_string_to_ints( [], [], [], [], _).
+format_string_to_ints( [A|As], Bs, Int1, Int2, Bool) :-
(char__is_digit(A) ->
( Bool = yes ->
- string__format_string_to_ints( As, Bs, I1, Int2, yes),
+ format_string_to_ints( As, Bs, I1, Int2, yes),
Int1 = [A|I1]
;
- string__format_string_to_ints(As, Bs, Int1, I2, no),
+ format_string_to_ints(As, Bs, Int1, I2, no),
Int2 = [A|I2]
)
;
( A = ('.') ->
- string__format_string_to_ints( As, Bs, Int1, Int2, no)
+ format_string_to_ints( As, Bs, Int1, Int2, no)
;
Bs = [A|As],
Int1 = [],
@@ -711,37 +711,37 @@
)
).
-:- pred string__format_int_from_char_list( list(char), int).
-:- mode string__format_int_from_char_list( in, out) is det.
+:- pred format_int_from_char_list( list(char), int).
+:- mode format_int_from_char_list( in, out) is det.
% Convert a char_list to an int
%
-string__format_int_from_char_list( [], 0).
-string__format_int_from_char_list( [L|Ls], I) :-
+format_int_from_char_list( [], 0).
+format_int_from_char_list( [L|Ls], I) :-
(
- string__from_char_list( [L|Ls], S),
- string__to_int( S, I_0)
+ from_char_list( [L|Ls], S),
+ to_int( S, I_0)
->
I = I_0
;
I = 0
).
-:- pred string__float_abs(float, float).
-:- mode string__float_abs(in, out) is det.
-string__float_abs(Fin, Fout) :-
+:- pred float_abs(float, float).
+:- mode float_abs(in, out) is det.
+float_abs(Fin, Fout) :-
( builtin_float_lt(Fin, 0.0) ->
builtin_float_minus(0.0, Fin, Fout)
;
Fout = Fin
).
-:- pred string__default_precision_and_width(int).
-:- mode string__default_precision_and_width(out) is det.
-string__default_precision_and_width(-6).
-
-:- pred string__special_precision_and_width(int).
-:- mode string__special_precision_and_width(out) is det.
-string__special_precision_and_width(-1).
+:- pred default_precision_and_width(int).
+:- mode default_precision_and_width(out) is det.
+default_precision_and_width(-6).
+
+:- pred special_precision_and_width(int).
+:- mode special_precision_and_width(out) is det.
+special_precision_and_width(-1).
Index: hard_coded/qual_strung.m
===================================================================
RCS file: /home/staff/zs/imp/tests/hard_coded/qual_strung.m,v
retrieving revision 1.3
diff -u -r1.3 qual_strung.m
--- qual_strung.m 1996/10/02 06:09:50 1.3
+++ qual_strung.m 1997/02/22 23:13:09
@@ -1,8 +1,8 @@
%
-% A test module similar to string, with only a string__format predicate.
+% A test module similar to string, with only a format predicate.
% Imports many things from string.m. Prints out every character in the
% format string twice (instead of once), and writes `Ostring' instead
-% of an arguement string.
+% of an argument string.
%
:- module qual_strung.
@@ -10,26 +10,26 @@
:- interface.
:- import_module list, string.
-:- pred string__format(string, list(string__poly_type), string).
-:- mode string__format(in, in, out) is det.
+:- pred format(string, list(poly_type), string).
+:- mode format(in, in, out) is det.
-:- func string__format_func(string, list(string__poly_type)) = string.
-:- mode string__format_func(in, in) = out is det.
+:- func format_func(string, list(poly_type)) = string.
+:- mode format_func(in, in) = out is det.
:- implementation.
:- import_module bool, char, int, float, require, std_util.
-string__format_func(FString, PolyList) = String :-
- qual_strung:string__format(FString, PolyList, String).
+format_func(FString, PolyList) = String :-
+ qual_strung:format(FString, PolyList, String).
-string__format( Fstring, Poly_list, Ostring ) :-
- string__to_char_list(Fstring, Clist),
- string__format_2a(Clist, Poly_list, Ostring) .
+format( Fstring, Poly_list, Ostring ) :-
+ to_char_list(Fstring, Clist),
+ format_2a(Clist, Poly_list, Ostring) .
-:- pred string__format_2a(list(char), list(string__poly_type), string).
-:- mode string__format_2a(in, in, out) is det.
+:- pred format_2a(list(char), list(poly_type), string).
+:- mode format_2a(in, in, out) is det.
%
-% string__format_2a( stream, char_f, vars, IO, IO).
+% format_2a( stream, char_f, vars, IO, IO).
% The main function, with different input types.
%
% Accumulator recursion is not used, as it would involve adding a
@@ -37,73 +37,73 @@
% is not efficient. Instead, many short strings are added to the front
% of a (long) and growing string.
%
-string__format_2a( [], _, "").
-string__format_2a( [Achar|As], Vars_in, Ostring) :-
+format_2a( [], _, "").
+format_2a( [Achar|As], Vars_in, Ostring) :-
(
Achar = '%'
->
(
As = ['%' | Ass]
->
- string__format_2a(Ass, Vars_in, Temp_out),
- string__first_char(Ostring, '%', Temp_out)
+ format_2a(Ass, Vars_in, Temp_out),
+ first_char(Ostring, '%', Temp_out)
;
(
- string__format_top_convert_variable(As, As_out,
+ format_top_convert_variable(As, As_out,
Vars_in, Vars_out, String_1)
->
- string__format_2a(As_out, Vars_out, String_2),
- string__append(String_1, String_2, Ostring)
+ format_2a(As_out, Vars_out, String_2),
+ append(String_1, String_2, Ostring)
;
- error("string__format: Too few variables.")
+ error("format: Too few variables.")
)
)
;
- string__format_2a(As, Vars_in, Temp_out),
- string__first_char(OOstring, Achar, Temp_out),
- string__first_char(Ostring, Achar, OOstring)
+ format_2a(As, Vars_in, Temp_out),
+ first_char(OOstring, Achar, Temp_out),
+ first_char(Ostring, Achar, OOstring)
).
-:- pred string__format_top_convert_variable( list(char), list(char),
- list(string__poly_type), list(string__poly_type), string).
-:- mode string__format_top_convert_variable(in, out, in, out, out) is semidet.
+:- pred format_top_convert_variable( list(char), list(char),
+ list(poly_type), list(poly_type), string).
+:- mode format_top_convert_variable(in, out, in, out, out) is semidet.
%
-% string__format_top_convert_variable( formated string in, out, var in, out,
+% format_top_convert_variable( formated string in, out, var in, out,
% Out string)
% Return a string of the formatted variable.
%
-string__format_top_convert_variable(['%'|Bs], Bs, [], [], "%").
+format_top_convert_variable(['%'|Bs], Bs, [], [], "%").
% Above rule should not be executed... defensive rule.
-string__format_top_convert_variable( F_chars_in, F_chars_out,
+format_top_convert_variable( F_chars_in, F_chars_out,
[Var_in|Vars_l_in], Vars_out, Out_string ) :-
- string__format_takewhile1( F_chars_in, [Conv_char_0|F_chars_out],
+ format_takewhile1( F_chars_in, [Conv_char_0|F_chars_out],
Fmt_info),
% Seperate formatting info from formatting string.
% in, out, out
- string__format_get_optional_args( Fmt_info, Flags, Int_width,
+ format_get_optional_args( Fmt_info, Flags, Int_width,
Int_precis, Conv_modify),
% Parse formatting info.
% in, out, out, out, out.
- string__format_mod_conv_char( Precision, Var_in, Conv_char_1,
+ format_mod_conv_char( Precision, Var_in, Conv_char_1,
Conv_char_0),
% Modify(?) conversion character.
% in, in, out, in
- string__format_do_mod_char( Conv_modify, Conv_char_2, Conv_char_1),
+ format_do_mod_char( Conv_modify, Conv_char_2, Conv_char_1),
% Interperate input conversion modifiers.
% in, out, in
- string__format_read_star( Vars_out, Vars_l_in, Width, Int_width,
+ format_read_star( Vars_out, Vars_l_in, Width, Int_width,
Precision, Int_precis),
% Do something if a precision or width was '*'
% out, in, out, in, out, in
- string__format_do_conversion(Conv_char_2, Var_in, Ostring, Precision,
+ format_do_conversion(Conv_char_2, Var_in, Ostring, Precision,
Flags, Move_i0),
% Actually convert a Variable to a string
% in, out, in, in, out, in, in, out
- string__format_add_sign( Ostring2, Ostring, Flags, Var_in, Move_i0,
+ format_add_sign( Ostring2, Ostring, Flags, Var_in, Move_i0,
Move_i1),
% Adds an optional '+' or ' ' to string.
% out, in, in, in, in, out
- string__format_pad_width( Ostring2, Width, Flags, Out_string, Move_i1).
+ format_pad_width( Ostring2, Width, Flags, Out_string, Move_i1).
% Ensures that the string is at least width.
% in, in, in, out, in
@@ -113,15 +113,15 @@
% Ideally the outer "->" symbols could be removed, the last case given
% a guard, and the compiler accept this as det, rather than non-det.
%
-:- pred string__format_mod_conv_char( int, string__poly_type, char, char).
-:- mode string__format_mod_conv_char( in, in, out, in) is det.
-string__format_mod_conv_char( Precision, Poly_var, Conv_c_out, Conv_c_in) :-
+:- pred format_mod_conv_char( int, poly_type, char, char).
+:- mode format_mod_conv_char( in, in, out, in) is det.
+format_mod_conv_char( Precision, Poly_var, Conv_c_out, Conv_c_in) :-
( Conv_c_in = 'i' ->
Conv_c_out = 'd' % %d = %i
;
(Conv_c_in = 'g' -> %g is either %e of %f
(Poly_var = f(F) ->
- string__float_abs(F, Ft),
+ float_abs(F, Ft),
int__pow(10, Precision, P),
int__to_float(P, Pe),
(
@@ -133,12 +133,12 @@
Conv_c_out = 'e'
)
;
- error("string__format: %g without a f(Float).")
+ error("format: %g without a f(Float).")
)
;
(Conv_c_in = 'G' -> %G is either %E of %f
(Poly_var = f(F) ->
- string__float_abs(F, Ft),
+ float_abs(F, Ft),
int__pow(10, Precision, P),
int__to_float(P, Pe),
(
@@ -150,7 +150,7 @@
Conv_c_out = 'E'
)
;
- error("string__format: %G without a f(float).")
+ error("format: %G without a f(float).")
)
;
Conv_c_out = Conv_c_in
@@ -161,9 +161,9 @@
%
% Another function that would be better off as a switch.
%
-:- pred string__format_do_mod_char( char, char, char).
-:- mode string__format_do_mod_char( in, out, in) is det.
-string__format_do_mod_char( Char_mods, C_out, C_in) :-
+:- pred format_do_mod_char( char, char, char).
+:- mode format_do_mod_char( in, out, in) is det.
+format_do_mod_char( Char_mods, C_out, C_in) :-
(
Char_mods = 'h'
->
@@ -183,11 +183,11 @@
%
% Change Width or Precision value, if '*' was spcified
%
-:- pred string__format_read_star( list(string__poly_type), list(string__poly_type), int, int, int, int).
-:- mode string__format_read_star( out, in, out, in, out, in) is semidet.
-string__format_read_star( Polys_out, Polys_in, Width, Int_width, Precision, Int_precis) :-
+:- pred format_read_star( list(poly_type), list(poly_type), int, int, int, int).
+:- mode format_read_star( out, in, out, in, out, in) is semidet.
+format_read_star( Polys_out, Polys_in, Width, Int_width, Precision, Int_precis) :-
(
- string__special_precision_and_width(Int_width)
+ special_precision_and_width(Int_width)
->
Polys_in = [ i(Width) | Poly_temp]
;
@@ -195,7 +195,7 @@
Int_width = Width
),
(
- string__special_precision_and_width(Int_precis)
+ special_precision_and_width(Int_precis)
->
Poly_temp = [ i(Precision) | Polys_out]
;
@@ -207,39 +207,39 @@
%
% This function did the variable conversion to string.
-% Now done by string__do_conversion_0/6.
+% Now done by do_conversion_0/6.
%
%
% Mv_width records the length of the prefix in front of the number,
% so that it is more easy to insert width and precision padding and
% optional signs, in the correct place.
%
-:- pred string__format_do_conversion( char, string__poly_type, string, int,
+:- pred format_do_conversion( char, poly_type, string, int,
list(char), int).
-:- mode string__format_do_conversion( in, in, out, in, in, out)
+:- mode format_do_conversion( in, in, out, in, in, out)
is det.
-string__format_do_conversion( Conv_c, Poly_t, Ostring, Precision, Flags,
+format_do_conversion( Conv_c, Poly_t, Ostring, Precision, Flags,
Mv_width) :-
(
- string__do_conversion_0(Conv_c, Poly_t, Tstring, Precision,
+ do_conversion_0(Conv_c, Poly_t, Tstring, Precision,
Flags, TMv_width)
->
TMv_width = Mv_width,
Ostring = Tstring
;
- string__do_conversion_fail(Conv_c)
+ do_conversion_fail(Conv_c)
).
-:- pred string__do_conversion_0(char, string__poly_type, string, int,
+:- pred do_conversion_0(char, poly_type, string, int,
list(char), int).
-:- mode string__do_conversion_0(in, in, out, in, in, out) is semidet.
-string__do_conversion_0(Conv_c, Poly_t, Ostring, Precision, Flags,
+:- mode do_conversion_0(in, in, out, in, in, out) is semidet.
+do_conversion_0(Conv_c, Poly_t, Ostring, Precision, Flags,
Mv_width) :-
(
Conv_c = 'd',
Poly_t = i(I),
- string__int_to_string(I, S),
- string__format_int_precision(S, Ostring, Precision, _),
+ int_to_string(I, S),
+ format_int_precision(S, Ostring, Precision, _),
(
I < 0
->
@@ -253,13 +253,13 @@
Poly_t = i(I),
( I = 0 ->
S = "0",
- string__format_int_precision(S, Ostring, Precision, _),
+ format_int_precision(S, Ostring, Precision, _),
Pfix_len = 0
;
- string__int_to_base_string(I, 8, S),
- string__format_int_precision(S, SS, Precision, _),
+ int_to_base_string(I, 8, S),
+ format_int_precision(S, SS, Precision, _),
( list__member('#', Flags) ->
- string__first_char(Ostring, '0', SS),
+ first_char(Ostring, '0', SS),
Pfix_len = 1
;
Ostring = SS,
@@ -273,14 +273,14 @@
( I = 0 ->
SS = "0",
Pfix_len = 0,
- string__format_int_precision(SS, Ostring, Precision, _)
+ format_int_precision(SS, Ostring, Precision, _)
;
- string__int_to_base_string(I, 16, S),
- string__format_int_precision(S, SS, Precision, _),
+ int_to_base_string(I, 16, S),
+ format_int_precision(S, SS, Precision, _),
(
list__member( '#', Flags)
->
- string__append( "0x", SS, Ostring),
+ append( "0x", SS, Ostring),
Pfix_len = 2
;
Ostring = SS,
@@ -294,13 +294,13 @@
( I = 0 ->
SS = "0",
Pfix_len = 0,
- string__format_int_precision(SS, Ostring, Precision, _)
+ format_int_precision(SS, Ostring, Precision, _)
;
- string__int_to_base_string(I, 16, Otemp),
- string__to_upper(Otemp, S),
- string__format_int_precision(S, SS, Precision, _),
+ int_to_base_string(I, 16, Otemp),
+ to_upper(Otemp, S),
+ format_int_precision(S, SS, Precision, _),
( list__member( '#', Flags) ->
- string__append( "0X", SS, Ostring),
+ append( "0X", SS, Ostring),
Pfix_len = 2
;
SS = Ostring,
@@ -312,84 +312,84 @@
Conv_c = 'u' ,
Poly_t = i(I),
int__abs(I, J),
- string__int_to_string(J, S),
- string__format_int_precision(S, Ostring, Precision, Mvt),
+ int_to_string(J, S),
+ format_int_precision(S, Ostring, Precision, Mvt),
Mv_width = Mvt
;
Conv_c = 'c' ,
Poly_t = c(C),
- string__char_to_string( C, Ostring),
+ char_to_string( C, Ostring),
Mv_width = 0
;
Conv_c = 's' ,
Poly_t = s(S),
- ( string__default_precision_and_width(Precision) ->
+ ( default_precision_and_width(Precision) ->
Ostring = "Ostring"
;
- string__split(S, Precision, Ostring, _)
+ split(S, Precision, Ostring, _)
),
Mv_width = 0
;
Conv_c = 'f' ,
Poly_t = f(F),
- string__float_to_string(F, Fstring),
- string__format_calc_prec(Fstring, Ostring, Precision),
+ float_to_string(F, Fstring),
+ format_calc_prec(Fstring, Ostring, Precision),
(builtin_float_lt(F, 0.0)-> Mv_width = 1 ; Mv_width = 0)
;
Conv_c = 'e',
Poly_t = f(F),
- string__format_calc_exp(F, Ostring, Precision, 0),
+ format_calc_exp(F, Ostring, Precision, 0),
(builtin_float_lt(F, 0.0)-> Mv_width = 1 ; Mv_width = 0)
;
Conv_c = 'E' ,
Poly_t = f(F),
- string__format_calc_exp(F, Otemp, Precision, 0),
- string__to_upper(Otemp, Ostring),
+ format_calc_exp(F, Otemp, Precision, 0),
+ to_upper(Otemp, Ostring),
(builtin_float_lt(F, 0.0)-> Mv_width = 1 ; Mv_width = 0)
;
Conv_c = 'p' ,
Poly_t = i(I),
- string__int_to_string(I, Ostring),
+ int_to_string(I, Ostring),
((I < 0) -> Mv_width = 1 ; Mv_width = 0)
).
-:- pred string__do_conversion_fail(char).
-:- mode string__do_conversion_fail(in) is erroneous.
-string__do_conversion_fail(Conv_c) :-
- qual_strung:string__format("%s `%%%c', without a correct poly-variable.",
- [s("string__format: statement has used type"), c(Conv_c)],
+:- pred do_conversion_fail(char).
+:- mode do_conversion_fail(in) is erroneous.
+do_conversion_fail(Conv_c) :-
+ qual_strung:format("%s `%%%c', without a correct poly-variable.",
+ [s("format: statement has used type"), c(Conv_c)],
Error_message),
error(Error_message).
%
% Use precision information to modify string. - for integers
%
-:- pred string__format_int_precision(string, string, int, int).
-:- mode string__format_int_precision( in, out, in, out) is semidet.
-string__format_int_precision(S, Ostring, Precision, Added_width) :-
- ( string__default_precision_and_width(Precision) ->
+:- pred format_int_precision(string, string, int, int).
+:- mode format_int_precision( in, out, in, out) is semidet.
+format_int_precision(S, Ostring, Precision, Added_width) :-
+ ( default_precision_and_width(Precision) ->
Prec = 0
;
Prec = Precision
),
- string__length(S, L),
- ( string__first_char(S, '-', _) ->
+ length(S, L),
+ ( first_char(S, '-', _) ->
Xzeros is Prec - L + 1
;
Xzeros is Prec - L
),
Added_width = Xzeros,
( Xzeros > 0 ->
- string__duplicate_char( '0', Xzeros, Pfix),
- string__first_char(S, C, Rest),
+ duplicate_char( '0', Xzeros, Pfix),
+ first_char(S, C, Rest),
(
C \= ('-'),
C \= ('+')
->
- string__append(Pfix, S, Ostring)
+ append(Pfix, S, Ostring)
;
- string__append( Pfix, Rest, Temps),
- string__first_char( Ostring, C, Temps)
+ append( Pfix, Rest, Temps),
+ first_char( Ostring, C, Temps)
)
;
Ostring = S
@@ -397,33 +397,33 @@
% Function to calculate exponent for a %e conversion of a float
%
-:- pred string__format_calc_exp(float, string, int, int).
-:- mode string__format_calc_exp(in, out, in, in) is det.
-string__format_calc_exp(F, Fstring, Precision, Exp) :-
+:- pred format_calc_exp(float, string, int, int).
+:- mode format_calc_exp(in, out, in, in) is det.
+format_calc_exp(F, Fstring, Precision, Exp) :-
( builtin_float_lt(F, 0.0) ->
builtin_float_minus( 0.0, F, Tf),
- string__format_calc_exp( Tf, Tst, Precision, Exp),
- string__first_char(Fstring, '-', Tst)
+ format_calc_exp( Tf, Tst, Precision, Exp),
+ first_char(Fstring, '-', Tst)
;
( builtin_float_lt(F, 1.0) ->
Texp is Exp - 1,
builtin_float_times(F, 10.0, FF),
- string__format_calc_exp( FF, Fstring, Precision, Texp)
+ format_calc_exp( FF, Fstring, Precision, Texp)
;
( builtin_float_ge(F, 10.0) ->
Texp is Exp + 1,
builtin_float_divide(F, 10.0, FF),
- string__format_calc_exp( FF, Fstring, Precision, Texp)
+ format_calc_exp( FF, Fstring, Precision, Texp)
;
- string__float_to_string(F, Fs),
- string__format_calc_prec(Fs, Fs2, Precision),
- string__int_to_string(Exp, Exps),
+ float_to_string(F, Fs),
+ format_calc_prec(Fs, Fs2, Precision),
+ int_to_string(Exp, Exps),
( Exp < 0 ->
- string__append( "e", Exps, TFstring),
- string__append( Fs2, TFstring, Fstring)
+ append( "e", Exps, TFstring),
+ append( Fs2, TFstring, Fstring)
;
- string__append( "e+", Exps, TFstring),
- string__append( Fs2, TFstring, Fstring)
+ append( "e+", Exps, TFstring),
+ append( Fs2, TFstring, Fstring)
)
)
)
@@ -433,40 +433,40 @@
%
% This precision output-modification predicate handles floats.
%
-:- pred string__format_calc_prec(string, string, int).
-:- mode string__format_calc_prec(in, out, in) is det.
-string__format_calc_prec(Istring, Ostring, Precision) :-
+:- pred format_calc_prec(string, string, int).
+:- mode format_calc_prec(in, out, in) is det.
+format_calc_prec(Istring, Ostring, Precision) :-
(
- string__default_precision_and_width(Precision)
+ default_precision_and_width(Precision)
->
Prec = 6
;
Prec = Precision
),
(
- string__find_index( Istring, '.', Index)
+ find_index( Istring, '.', Index)
->
Spa is Prec + Index
;
- string__length(Istring, Spa_0),
+ length(Istring, Spa_0),
Spa is Spa_0 + 1
% This branch should never be called if mercury is implemented
% in ansi-C, according to Kernighan and Ritchie p244, as a
% float converted to a string using sprintf should always have
% a decimal point. (where specified precision != 0.
- % string__float_to_string doesn't specify a precision to be
+ % float_to_string doesn't specify a precision to be
% used.) If a future implementation changes the
- % way string__float_to_string is implemented, and a float can
+ % way float_to_string is implemented, and a float can
% be converted to a string without a decimal point, then this
% rule would be useful. It is not expected that
- % string__float_to_string will ever produce %e style output.
+ % float_to_string will ever produce %e style output.
),
(
- string__length(Istring, L1),
+ length(Istring, L1),
L1 < Spa
->
- string__duplicate_char('0', Precision, P0s),
- string__append( Istring, P0s, Mstring)
+ duplicate_char('0', Precision, P0s),
+ append( Istring, P0s, Mstring)
;
Mstring = Istring
),
@@ -477,73 +477,73 @@
;
Space = Spa
),
- string__split(Mstring, Space, Ostring, _).
+ split(Mstring, Space, Ostring, _).
-% string__find_index is a funky little predicate to find the first
+% find_index is a funky little predicate to find the first
% occurrence of a particular character in a string.
-:- pred string__find_index( string, char, int).
-:- mode string__find_index( in, in, out) is semidet.
-string__find_index(Str, C, Index) :-
- string__to_char_list(Str, List),
- string__find_index_2(List, C, Index).
-
-:- pred string__find_index_2(list(char), char, int).
-:- mode string__find_index_2(in, in, out) is semidet.
-string__find_index_2([], _C, _Index) :- fail.
-string__find_index_2([X|Xs], C, Index) :-
+:- pred find_index( string, char, int).
+:- mode find_index( in, in, out) is semidet.
+find_index(Str, C, Index) :-
+ to_char_list(Str, List),
+ find_index_2(List, C, Index).
+
+:- pred find_index_2(list(char), char, int).
+:- mode find_index_2(in, in, out) is semidet.
+find_index_2([], _C, _Index) :- fail.
+find_index_2([X|Xs], C, Index) :-
(
X = C
->
Index = 1
;
- string__find_index_2(Xs, C, Index0),
+ find_index_2(Xs, C, Index0),
Index is Index0 + 1
).
-%string__find_index( A, Ch, Check, Ret) :-
+%find_index( A, Ch, Check, Ret) :-
% (
-% string__length(A, Len),
+% length(A, Len),
% Len < Check
% ->
% fail
% ;
-% string__index(A, Check, Ch)
+% index(A, Check, Ch)
% ->
% Ret = Check
% ;
% Check2 is Check + 1,
-% string__find_index( A, Ch, Check2, Ret)
+% find_index( A, Ch, Check2, Ret)
% ).
%
% Add a '+' or ' ' sign, if it is needed in this output.
%
-:- pred string__format_add_sign( string, string, list(char), string__poly_type,
+:- pred format_add_sign( string, string, list(char), poly_type,
int, int).
-:- mode string__format_add_sign( out, in, in, in, in, out) is det.
+:- mode format_add_sign( out, in, in, in, in, out) is det.
% Mvw is the prefix-length in front of the number.
-string__format_add_sign( Ostring, Istring, Flags, _V, Mvw1, Mvw2) :-
+format_add_sign( Ostring, Istring, Flags, _V, Mvw1, Mvw2) :-
T1 is Mvw1 - 1,
(
- string__index(Istring, T1, '-')
+ index(Istring, T1, '-')
->
Ostring = Istring,
Mvw2 = Mvw1
;
- string__split(Istring, Mvw1, Lstring, Rstring),
+ split(Istring, Mvw1, Lstring, Rstring),
(
list__member(('+'), Flags)
->
- string__append( "+", Rstring, Astring),
- string__append( Lstring, Astring, Ostring),
+ append( "+", Rstring, Astring),
+ append( Lstring, Astring, Ostring),
Mvw2 is Mvw1 + 1
;
(
list__member(' ', Flags)
->
- string__append( " ", Rstring, Astring),
- string__append( Lstring, Astring, Ostring),
+ append( " ", Rstring, Astring),
+ append( Lstring, Astring, Ostring),
Mvw2 is Mvw1 + 1
;
Ostring = Istring,
@@ -556,11 +556,11 @@
% This function pads some characters to the left or right of a string that is
% shorter than it's width.
%
-:- pred string__format_pad_width( string, int, list(char), string, int).
-:- mode string__format_pad_width( in, in, in, out, in) is det.
+:- pred format_pad_width( string, int, list(char), string, int).
+:- mode format_pad_width( in, in, in, out, in) is det.
% ( String in, width, flags, Output string, #Moveables).
-string__format_pad_width( Istring, Width, Flags, Out_string, Mv_cs) :-
- string__length(Istring, Len),
+format_pad_width( Istring, Width, Flags, Out_string, Mv_cs) :-
+ length(Istring, Len),
(Len < Width ->
% time for some FLAG tests
Xspace is Width - Len,
@@ -571,29 +571,29 @@
;
Pad_char = ' '
),
- string__duplicate_char(Pad_char, Xspace, Pad_string),
+ duplicate_char(Pad_char, Xspace, Pad_string),
(
list__member('-', Flags)
->
- string__append(Istring, Pad_string, Out_string)
+ append(Istring, Pad_string, Out_string)
;
(
list__member('0', Flags)
->
- string__split(Istring, Mv_cs, B4, After),
- string__append( Pad_string, After, Astring),
- string__append( B4, Astring, Out_string)
+ split(Istring, Mv_cs, B4, After),
+ append( Pad_string, After, Astring),
+ append( B4, Astring, Out_string)
;
- string__append( Pad_string, Istring, Out_string)
+ append( Pad_string, Istring, Out_string)
)
)
;
Out_string = Istring
).
-:- pred string__format_get_optional_args( list(char), list(char), int, int, char).
-:- mode string__format_get_optional_args( in, out, out, out, out) is det.
-% string__format_get_optional_args( format info, flags, width, precision, modifier)
+:- pred format_get_optional_args( list(char), list(char), int, int, char).
+:- mode format_get_optional_args( in, out, out, out, out) is det.
+% format_get_optional_args( format info, flags, width, precision, modifier)
% format is assumed to be in ANSI C format.
% p243-4 of Kernighan & Ritchie 2nd Ed. 1988
% "Parse" format informtion.
@@ -604,16 +604,16 @@
% determinism checker does not `see' the equity tests that are hidden one layer
% further down.
%
-string__format_get_optional_args( [], Flags, Width, Precision, Mods) :-
+format_get_optional_args( [], Flags, Width, Precision, Mods) :-
Flags = [],
Width = 0,
- string__default_precision_and_width(Precision),
+ default_precision_and_width(Precision),
Mods = ' '.
-string__format_get_optional_args( [A|As], Flags, Width, Precision, Mods) :-
+format_get_optional_args( [A|As], Flags, Width, Precision, Mods) :-
(
(A = (-) ; A = (+) ; A = ' ' ; A = '0' ; A = '#' )
->
- string__format_get_optional_args( As, Oflags, Width, Precision, Mods),
+ format_get_optional_args( As, Oflags, Width, Precision, Mods),
UFlags = [A | Oflags],
list__sort_and_remove_dups(UFlags, Flags)
;
@@ -621,10 +621,10 @@
( A = (.) ; A = '1' ; A = '2' ; A = '3' ; A = '4' ;
A = '5' ; A = '6' ; A = '7' ; A = '8' ; A = '9' )
->
- string__format_string_to_ints([A|As], Bs, Numl1, Numl2, yes),
- string__format_int_from_char_list( Numl1, Width),
- string__format_int_from_char_list( Numl2, Prec),
- string__format_get_optional_args( Bs, Flags, _, Ptemp, Mods),
+ format_string_to_ints([A|As], Bs, Numl1, Numl2, yes),
+ format_int_from_char_list( Numl1, Width),
+ format_int_from_char_list( Numl2, Prec),
+ format_get_optional_args( Bs, Flags, _, Ptemp, Mods),
(Numl2 = [] ->
Precision = Ptemp
;
@@ -634,45 +634,45 @@
( ( A = 'h' ; A = 'l' ; A = 'L' )
->
Mods = A,
- string__format_get_optional_args( As, Flags, Width, Precision, _)
+ format_get_optional_args( As, Flags, Width, Precision, _)
;
( A = ('*')
->
- string__format_get_optional_args( As, Flags, W, P, Mods),
+ format_get_optional_args( As, Flags, W, P, Mods),
(
As = [(.)|_]
->
Precision = P,
- string__special_precision_and_width(Width)
+ special_precision_and_width(Width)
;
Width = W,
- string__special_precision_and_width(Precision)
+ special_precision_and_width(Precision)
)
% (
-% string__default_precision_and_width(P)
+% default_precision_and_width(P)
% ->
-% string__special_precision_and_width(Precision)
+% special_precision_and_width(Precision)
% ;
% Precision = P
% ),
-% string__special_precision_and_width(Width)
+% special_precision_and_width(Width)
;
- error("string__format: Unrecognised formatting information\n")
+ error("format: Unrecognised formatting information\n")
)
))) .
-:- pred string__format_takewhile1(list(char), list(char), list(char)).
-:- mode string__format_takewhile1(in, out, out) is det.
-% string__format_takewhile(formatted string in, out, format info).
-% A HACK. Would be much nicer with a proper string__takewhile.
+:- pred format_takewhile1(list(char), list(char), list(char)).
+:- mode format_takewhile1(in, out, out) is det.
+% format_takewhile(formatted string in, out, format info).
+% A HACK. Would be much nicer with a proper takewhile.
% Looses the format info from the front of the first argument,
% puts this in the last argument, while the second is the
% remainder of the string.
%
% XXXXXX
%
-string__format_takewhile1([], [], []).
-string__format_takewhile1( [A|As], Rem, Finf) :-
+format_takewhile1([], [], []).
+format_takewhile1( [A|As], Rem, Finf) :-
(
( A = 'd' ; A = 'i' ; A = 'o' ; A = 'x' ; A = 'X' ; A = 'u' ;
A = 's' ; A = '%' ; A = 'c' ; A = 'f' ; A = 'e' ; A = 'E' ;
@@ -681,30 +681,30 @@
Rem = [A|As],
Finf = []
;
- string__format_takewhile1(As, Rem, F),
+ format_takewhile1(As, Rem, F),
Finf = [A|F]
).
-:- pred string__format_string_to_ints(list(char), list(char), list(char), list(char), bool).
-:- mode string__format_string_to_ints(in, out, out, out, in) is det.
+:- pred format_string_to_ints(list(char), list(char), list(char), list(char), bool).
+:- mode format_string_to_ints(in, out, out, out, in) is det.
% ( String in, out, Number1, Number2, seen '.' yet?)
% Takes in a char list and splits off the rational number at the
% start of the list. This is split into 2 parts - an int and a
% fraction.
%
-string__format_string_to_ints( [], [], [], [], _).
-string__format_string_to_ints( [A|As], Bs, Int1, Int2, Bool) :-
+format_string_to_ints( [], [], [], [], _).
+format_string_to_ints( [A|As], Bs, Int1, Int2, Bool) :-
(char__is_digit(A) ->
( Bool = yes ->
- string__format_string_to_ints( As, Bs, I1, Int2, yes),
+ format_string_to_ints( As, Bs, I1, Int2, yes),
Int1 = [A|I1]
;
- string__format_string_to_ints(As, Bs, Int1, I2, no),
+ format_string_to_ints(As, Bs, Int1, I2, no),
Int2 = [A|I2]
)
;
( A = ('.') ->
- string__format_string_to_ints( As, Bs, Int1, Int2, no)
+ format_string_to_ints( As, Bs, Int1, Int2, no)
;
Bs = [A|As],
Int1 = [],
@@ -712,37 +712,37 @@
)
).
-:- pred string__format_int_from_char_list( list(char), int).
-:- mode string__format_int_from_char_list( in, out) is det.
+:- pred format_int_from_char_list( list(char), int).
+:- mode format_int_from_char_list( in, out) is det.
% Convert a char_list to an int
%
-string__format_int_from_char_list( [], 0).
-string__format_int_from_char_list( [L|Ls], I) :-
+format_int_from_char_list( [], 0).
+format_int_from_char_list( [L|Ls], I) :-
(
- string__from_char_list( [L|Ls], S),
- string__to_int( S, I_0)
+ from_char_list( [L|Ls], S),
+ to_int( S, I_0)
->
I = I_0
;
I = 0
).
-:- pred string__float_abs(float, float).
-:- mode string__float_abs(in, out) is det.
-string__float_abs(Fin, Fout) :-
+:- pred float_abs(float, float).
+:- mode float_abs(in, out) is det.
+float_abs(Fin, Fout) :-
( builtin_float_lt(Fin, 0.0) ->
builtin_float_minus(0.0, Fin, Fout)
;
Fout = Fin
).
-:- pred string__default_precision_and_width(int).
-:- mode string__default_precision_and_width(out) is det.
-string__default_precision_and_width(-6).
-
-:- pred string__special_precision_and_width(int).
-:- mode string__special_precision_and_width(out) is det.
-string__special_precision_and_width(-1).
+:- pred default_precision_and_width(int).
+:- mode default_precision_and_width(out) is det.
+default_precision_and_width(-6).
+
+:- pred special_precision_and_width(int).
+:- mode special_precision_and_width(out) is det.
+special_precision_and_width(-1).
Index: hard_coded/string_alignment.m
===================================================================
RCS file: /home/staff/zs/imp/tests/hard_coded/string_alignment.m,v
retrieving revision 1.1
diff -u -r1.1 string_alignment.m
--- string_alignment.m 1996/05/14 13:10:24 1.1
+++ string_alignment.m 1997/02/22 23:14:09
@@ -20,12 +20,8 @@
:- pred show(t::in, io__state::di, io__state::uo) is det.
-show(f1(S)) --> io__write_string("f1: "), io__write_string(S), nl.
-show(f2(S)) --> io__write_string("f2: "), io__write_string(S), nl.
-show(f3(S)) --> io__write_string("f3: "), io__write_string(S), nl.
-show(f4(S)) --> io__write_string("f4: "), io__write_string(S), nl.
-
-:- pred nl(io__state::di, io__state::uo) is det.
-
-nl --> io__write_string("\n").
+show(f1(S)) --> io__write_string("f1: "), io__write_string(S), io__nl.
+show(f2(S)) --> io__write_string("f2: "), io__write_string(S), io__nl.
+show(f3(S)) --> io__write_string("f3: "), io__write_string(S), io__nl.
+show(f4(S)) --> io__write_string("f4: "), io__write_string(S), io__nl.
cvs diff: Diffing invalid
cvs diff: Diffing misc_tests
cvs diff: Diffing valid
Index: valid/middle_rec_labels.m
===================================================================
RCS file: /home/staff/zs/imp/tests/valid/middle_rec_labels.m,v
retrieving revision 1.1
diff -u -r1.1 middle_rec_labels.m
--- middle_rec_labels.m 1996/11/04 07:25:24 1.1
+++ middle_rec_labels.m 1997/02/22 23:19:30
@@ -28,17 +28,17 @@
; nondeterministic
; commit.
-:- pred garbage_out__get_det(list(liveinfo), maybe(det), det).
-:- mode garbage_out__get_det(in, in, out) is det.
+:- pred garbage_out_get_det(list(liveinfo), maybe(det), det).
+:- mode garbage_out_get_det(in, in, out) is det.
:- implementation.
-garbage_out__get_det([], no, nondeterministic).
-garbage_out__get_det([], yes(commit), commit).
-garbage_out__get_det([], yes(nondeterministic), nondeterministic).
-garbage_out__get_det([], yes(deterministic), deterministic).
+garbage_out_get_det([], no, nondeterministic).
+garbage_out_get_det([], yes(commit), commit).
+garbage_out_get_det([], yes(nondeterministic), nondeterministic).
+garbage_out_get_det([], yes(deterministic), deterministic).
-garbage_out__get_det([L | Ls], OldD, NewDet) :-
+garbage_out_get_det([L | Ls], OldD, NewDet) :-
(
L = live_lvalue(stackvar(_), _, _)
->
@@ -74,4 +74,4 @@
;
Det = OldD
),
- garbage_out__get_det(Ls, Det, NewDet).
+ garbage_out_get_det(Ls, Det, NewDet).
cvs diff: Diffing warnings
Index: warnings/pragma_source_file.exp
===================================================================
RCS file: /home/staff/zs/imp/tests/warnings/pragma_source_file.exp,v
retrieving revision 1.1
diff -u -r1.1 pragma_source_file.exp
--- pragma_source_file.exp 1996/07/04 09:01:17 1.1
+++ pragma_source_file.exp 1997/02/22 23:24:08
@@ -1,4 +1,4 @@
-foo.m:002: In clause for predicate `pragma_source_file:append/3':
+foo.m:002: In clause for predicate `pragma_source_file:my_append/3':
foo.m:002: Warning: variables `L1, L2' occur only once in this scope.
-foo.m:011: In clause for predicate `pragma_source_file:append/3':
+foo.m:011: In clause for predicate `pragma_source_file:my_append/3':
foo.m:011: Warning: variables `X, Y' occur only once in this scope.
Index: warnings/pragma_source_file.m
===================================================================
RCS file: /home/staff/zs/imp/tests/warnings/pragma_source_file.m,v
retrieving revision 1.1
diff -u -r1.1 pragma_source_file.m
--- pragma_source_file.m 1996/07/04 09:01:18 1.1
+++ pragma_source_file.m 1997/02/22 23:22:41
@@ -3,17 +3,17 @@
:- interface.
-:- pred append(list(int), list(int), list(int)).
-:- mode append(in, in, out) is det.
+:- pred my_append(list(int), list(int), list(int)).
+:- mode my_append(in, in, out) is det.
:- implementation.
:- pragma source_file("foo.m").
#1
-append([], L, L) :-
+my_append([], L, L) :-
#2
L1 = L2.
#10
-append([H | T], L, [H | NT]) :-
+my_append([H | T], L, [H | NT]) :-
X = Y,
- append(T, L, NT).
+ my_append(T, L, NT).
Index: warnings/singleton_test.exp
===================================================================
RCS file: /home/staff/zs/imp/tests/warnings/singleton_test.exp,v
retrieving revision 1.1
diff -u -r1.1 singleton_test.exp
--- singleton_test.exp 1996/05/13 05:11:20 1.1
+++ singleton_test.exp 1997/02/22 23:48:49
@@ -1,2 +1,2 @@
-singleton_test.m:012: In clause for predicate `singleton_test:append/3':
+singleton_test.m:012: In clause for predicate `singleton_test:my_append/3':
singleton_test.m:012: Warning: variables `L1, L2' occur only once in this scope.
Index: warnings/singleton_test.m
===================================================================
RCS file: /home/staff/zs/imp/tests/warnings/singleton_test.m,v
retrieving revision 1.1
diff -u -r1.1 singleton_test.m
--- singleton_test.m 1996/05/13 05:11:20 1.1
+++ singleton_test.m 1997/02/22 23:22:17
@@ -3,12 +3,12 @@
:- interface.
-:- pred append(list(int), list(int), list(int)).
-:- mode append(in, in, out) is det.
+:- pred my_append(list(int), list(int), list(int)).
+:- mode my_append(in, in, out) is det.
:- implementation.
-append([], L, L) :-
+my_append([], L, L) :-
L1 = L2.
-append([H | T], L, [H | NT]) :-
- append(T, L, NT).
+my_append([H | T], L, [H | NT]) :-
+ my_append(T, L, NT).
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
More information about the developers
mailing list