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 369 - (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 369 fun set (m, a, s) = m := (Era.newEra (); StringMap.insert (!m, a, s))
33 :     fun reset m = m := (Era.newEra (); StringMap.empty)
34 :     fun cancel (m, a) =
35 :     (Era.newEra ();
36 :     (m := #1 (StringMap.remove (!m, a)))
37 :     handle LibBase.NotFound => ())
38 : blume 321
39 : blume 368 fun new () = ref StringMap.empty
40 : blume 321
41 : blume 361 fun configAnchor m s =
42 :     case StringMap.find (!m, s) of
43 :     NONE => NONE
44 :     | SOME _ => SOME (fn () => valOf (StringMap.find (!m, s)))
45 :    
46 :     fun processSpecFile (m, f) = let
47 :     fun work s = let
48 :     fun loop () = let
49 :     val line = TextIO.inputLine s
50 :     in
51 :     if line = "" then ()
52 :     else case String.tokens Char.isSpace line of
53 : blume 368 [a, d] => (set (m, a, d); loop ())
54 :     | ["-"] => (reset m; loop ())
55 :     | [a] => (cancel (m, a); loop ())
56 :     | _ => (Say.say [f, ": malformed line (ignored)\n"]; loop ())
57 : blume 361 end
58 :     in
59 :     loop ()
60 :     end
61 : blume 360 in
62 : blume 361 SafeIO.perform { openIt = fn () => TextIO.openIn f,
63 :     closeIt = TextIO.closeIn,
64 :     work = work,
65 :     cleanup = fn () => () }
66 : blume 360 end
67 : blume 265 end

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