mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-30 16:54:41 +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.
70 lines
1.5 KiB
Mathematica
70 lines
1.5 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% Copyright (C) 2000, 2011 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.
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% Main author: conway@cs.mu.oz.au.
|
|
%
|
|
%---------------------------------------------------------------------------%
|
|
:- module xml.doc.
|
|
|
|
:- interface.
|
|
|
|
:- import_module array, list, map.
|
|
|
|
:- type document
|
|
---> doc(
|
|
prestuff :: list(ref(content)),
|
|
root :: ref(content),
|
|
poststuff :: list(ref(content)),
|
|
content :: array(content)
|
|
).
|
|
|
|
:- type content
|
|
---> element(element)
|
|
; pi(string, string)
|
|
; comment(string)
|
|
; data(string)
|
|
.
|
|
|
|
:- type contentStore
|
|
---> content(
|
|
eNext :: ref(content),
|
|
eMap :: map(ref(content), content)
|
|
).
|
|
|
|
:- type element
|
|
---> element(
|
|
eName :: string,
|
|
eAttrs :: list(attribute),
|
|
eContent :: list(ref(content))
|
|
).
|
|
|
|
:- type attribute
|
|
---> attribute(
|
|
aName :: string,
|
|
aValue :: string
|
|
).
|
|
|
|
:- type ref(T) == int.
|
|
|
|
:- func ref(contentStore, ref(content)) = content.
|
|
|
|
:- pred add(content, ref(content), contentStore, contentStore).
|
|
:- mode add(in, out, in, out) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module int.
|
|
|
|
ref(Elems, Ref) = Elem :-
|
|
lookup(Elems^eMap, Ref, Elem).
|
|
|
|
add(Elem, Ref, Elems0, Elems) :-
|
|
Ref = Elems0^eNext,
|
|
Elems1 = Elems0^eNext := Ref + 1,
|
|
map.set(Ref, Elem, Elems1^eMap, Map),
|
|
Elems = Elems1^eMap := Map.
|
|
|