SCM Repository
Annotation of /sml/trunk/src/cm/paths/pathconfig.sml
Parent Directory
|
Revision Log
Revision 366 - (view) (download)
1 : | blume | 267 | (* |
2 : | * Configurable path anchors for new CM. | ||
3 : | * | ||
4 : | * (C) 1999 Lucent Technologies, Bell Laboratories | ||
5 : | * | ||
6 : | * Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp) | ||
7 : | *) | ||
8 : | |||
9 : | blume | 265 | signature PATHCONFIG = sig |
10 : | blume | 321 | |
11 : | blume | 318 | type mode |
12 : | |||
13 : | blume | 361 | val new : unit -> mode |
14 : | val set : mode * string * string -> unit | ||
15 : | blume | 318 | |
16 : | val configAnchor : mode -> string -> (unit -> string) option | ||
17 : | blume | 361 | |
18 : | val processSpecFile : mode * string -> unit | ||
19 : | blume | 265 | end |
20 : | |||
21 : | blume | 309 | (* |
22 : | * The names of config anchors must be names of actual files. | ||
23 : | * Function configAnchor will map the name of the anchor to | ||
24 : | * the directory that contains the corresponding file. | ||
25 : | *) | ||
26 : | blume | 265 | structure PathConfig :> PATHCONFIG = struct |
27 : | blume | 318 | |
28 : | blume | 361 | type mode = string StringMap.map ref |
29 : | blume | 318 | |
30 : | blume | 361 | fun set (m, a, s) = m := StringMap.insert (!m, a, s) |
31 : | blume | 321 | |
32 : | blume | 361 | fun new () = ref (StringMap.empty) |
33 : | blume | 321 | |
34 : | blume | 361 | fun configAnchor m s = |
35 : | case StringMap.find (!m, s) of | ||
36 : | NONE => NONE | ||
37 : | | SOME _ => SOME (fn () => valOf (StringMap.find (!m, s))) | ||
38 : | |||
39 : | fun processSpecFile (m, f) = let | ||
40 : | fun work s = let | ||
41 : | fun loop () = let | ||
42 : | val line = TextIO.inputLine s | ||
43 : | in | ||
44 : | if line = "" then () | ||
45 : | else case String.tokens Char.isSpace line of | ||
46 : | [a, d] => (set (m, a, d); | ||
47 : | loop ()) | ||
48 : | | _ => (Say.say [f, ": malformed line (ignored)\n"]; | ||
49 : | loop ()) | ||
50 : | end | ||
51 : | in | ||
52 : | loop () | ||
53 : | end | ||
54 : | blume | 360 | in |
55 : | blume | 361 | SafeIO.perform { openIt = fn () => TextIO.openIn f, |
56 : | closeIt = TextIO.closeIn, | ||
57 : | work = work, | ||
58 : | cleanup = fn () => () } | ||
59 : | blume | 360 | end |
60 : | blume | 265 | end |
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |