mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-28 15:54:18 +00:00
Branches: main
Change the argument order of many of the predicates in the map, bimap, and
multi_map modules so they are more conducive to the use of state variable
notation, i.e. make the order the same as in the sv* modules.
Prepare for the deprecation of the sv{bimap,map,multi_map} modules by
removing their use throughout the system.
library/bimap.m:
library/map.m:
library/multi_map.m:
As above.
NEWS:
Announce the change.
Separate out the "highlights" from the "detailed listing" for
the post-11.01 NEWS.
Reorganise the announcement of the Unicode support.
benchmarks/*/*.m:
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
extras/*/*.m:
mdbcomp/*.m:
profiler/*.m:
tests/*/*.m:
ssdb/*.m:
samples/*/*.m
slice/*.m:
Conform to the above change.
Remove any dependencies on the sv{bimap,map,multi_map} modules.
93 lines
2.1 KiB
Mathematica
93 lines
2.1 KiB
Mathematica
:- module deforest_bug.
|
|
|
|
:- interface.
|
|
|
|
:- import_module list, char, map.
|
|
|
|
:- type catalog ---> catalog(publicId -> systemId).
|
|
|
|
:- type [] ---> [].
|
|
:- type [T1|T2] == list(T1).
|
|
:- type (A -> B) == map(A, B).
|
|
|
|
:- type dirs == [path].
|
|
|
|
:- type publicId == string.
|
|
|
|
:- type systemId == string.
|
|
|
|
:- type path == string.
|
|
|
|
:- type catRes(T)
|
|
---> ok(T)
|
|
; error(string)
|
|
.
|
|
|
|
:- pred deforest_load([(int, [char])], [string], catalog).
|
|
:- mode deforest_load(in, out, out) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module int, std_util, string.
|
|
|
|
:- type entry
|
|
---> dtd(publicId, systemId)
|
|
; none
|
|
.
|
|
|
|
:- pragma no_inline(deforest_load/3).
|
|
deforest_load(CatLines, Errors, Cat) :-
|
|
parse(Entries, Errors, CatLines),
|
|
init(Cat0),
|
|
my_foldl(addEntry, Entries, catalog(Cat0), Cat).
|
|
|
|
:- type (A, B) ---> (A, B).
|
|
|
|
:- pred parse([entry], [string], [(int, [char])]).
|
|
:- mode parse(out, out, in) is det.
|
|
|
|
parse([], [], []).
|
|
parse(Entries, Errors, [Line|Lines]) :-
|
|
Line = (N, Cs),
|
|
( parseEntry(Entry, Cs, _) ->
|
|
Entries = [Entry|Entries0],
|
|
parse(Entries0, Errors, Lines)
|
|
;
|
|
format("%d: syntax error", [i(N)], Msg),
|
|
Errors = [Msg|Errors0],
|
|
parse(Entries, Errors0, Lines)
|
|
).
|
|
|
|
:- pred addEntry(entry, catalog, catalog).
|
|
:- mode addEntry(in, in, out) is det.
|
|
|
|
addEntry(none, Cat, Cat).
|
|
addEntry(dtd(PublicId, SystemId), catalog(Cat0), catalog(Cat)) :-
|
|
det_insert(PublicId, SystemId, Cat0, Cat).
|
|
|
|
:- pred parseEntry(entry, [char], [char]).
|
|
:- mode parseEntry(out, in, out) is semidet.
|
|
|
|
parseEntry(Entry) -->
|
|
( ['P'], string(PublicId), string(SystemId) ->
|
|
{ Entry = dtd(PublicId, SystemId) }
|
|
; =([]) ->
|
|
{ Entry = none }
|
|
;
|
|
{ fail }
|
|
).
|
|
|
|
:- pred string(string, [char], [char]).
|
|
:- mode string(out, in, out) is semidet.
|
|
:- pragma no_inline(string/3).
|
|
|
|
string("") --> { semidet_succeed }.
|
|
|
|
:- pred my_foldl(pred(T, U, U), list(T), U, U).
|
|
:- mode my_foldl(pred(in, in, out) is det, in, in, out) is det.
|
|
|
|
my_foldl(_, [], A, A).
|
|
my_foldl(P, [Head | Tail], A0, A) :-
|
|
P(Head, A0, A1),
|
|
my_foldl(P, Tail, A1, A).
|