Commit | Line | Data |
---|---|---|
a3698041 AC |
1 | (* HCoop Domtool (http://hcoop.sourceforge.net/) |
2 | * Copyright (c) 2006, Adam Chlipala | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or | |
5 | * modify it under the terms of the GNU General Public License | |
6 | * as published by the Free Software Foundation; either version 2 | |
7 | * of the License, or (at your option) any later version. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * along with this program; if not, write to the Free Software | |
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 | *) | |
18 | ||
19 | (* Domain-related primitive actions *) | |
20 | ||
21 | structure Domain :> DOMAIN = struct | |
22 | ||
23 | open Ast | |
24 | ||
25 | val befores = ref (fn (_ : string) => ()) | |
26 | val afters = ref (fn (_ : string) => ()) | |
27 | ||
28 | fun registerBefore f = | |
29 | let | |
30 | val old = !befores | |
31 | in | |
32 | befores := (fn x => (old x; f x)) | |
33 | end | |
34 | ||
35 | fun registerAfter f = | |
36 | let | |
37 | val old = !afters | |
38 | in | |
39 | afters := (fn x => (old x; f x)) | |
40 | end | |
41 | ||
42 | val current = ref "" | |
43 | ||
44 | val _ = Env.registerContainer ("domain", | |
45 | fn (_, [(EString dom, _)]) => (current := dom; | |
46 | !befores dom; | |
47 | StringMap.empty) | |
48 | | _ => Env.badArgs "domain", | |
49 | fn () => !afters (!current)) | |
50 | ||
51 | end |