Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/src/cm/paths/pathconfig.sml
ViewVC logotype

Annotation of /sml/trunk/src/cm/paths/pathconfig.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 368 - (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 368 val cancel : mode * string -> unit
16 :     val reset : mode -> unit
17 : blume 318
18 :     val configAnchor : mode -> string -> (unit -> string) option
19 : blume 361
20 :     val processSpecFile : mode * string -> unit
21 : blume 265 end
22 :    
23 : blume 309 (*
24 :     * The names of config anchors must be names of actual files.
25 :     * Function configAnchor will map the name of the anchor to
26 :     * the directory that contains the corresponding file.
27 :     *)
28 : blume 265 structure PathConfig :> PATHCONFIG = struct
29 : blume 318
30 : blume 361 type mode = string StringMap.map ref
31 : blume 318
32 : blume 361 fun set (m, a, s) = m := StringMap.insert (!m, a, s)
33 : blume 368 fun reset m = m := StringMap.empty
34 :     fun cancel (m, a) = (m := #1 (StringMap.remove (!m, a)))
35 :     handle LibBase.NotFound => ()
36 : blume 321
37 : blume 368 fun new () = ref StringMap.empty
38 : blume 321
39 : blume 361 fun configAnchor m s =
40 :     case StringMap.find (!m, s) of
41 :     NONE => NONE
42 :     | SOME _ => SOME (fn () => valOf (StringMap.find (!m, s)))
43 :    
44 :     fun processSpecFile (m, f) = let
45 :     fun work s = let
46 :     fun loop () = let
47 :     val line = TextIO.inputLine s
48 :     in
49 :     if line = "" then ()
50 :     else case String.tokens Char.isSpace line of
51 : blume 368 [a, d] => (set (m, a, d); loop ())
52 :     | ["-"] => (reset m; loop ())
53 :     | [a] => (cancel (m, a); loop ())
54 :     | _ => (Say.say [f, ": malformed line (ignored)\n"]; loop ())
55 : blume 361 end
56 :     in
57 :     loop ()
58 :     end
59 : blume 360 in
60 : blume 361 SafeIO.perform { openIt = fn () => TextIO.openIn f,
61 :     closeIt = TextIO.closeIn,
62 :     work = work,
63 :     cleanup = fn () => () }
64 : blume 360 end
65 : blume 265 end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0