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

SCM Repository

[smlnj] Diff of /sml/trunk/src/cm/main/envcfg.sml
ViewVC logotype

Diff of /sml/trunk/src/cm/main/envcfg.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 275, Sat May 15 09:54:52 1999 UTC revision 276, Mon May 17 06:01:28 1999 UTC
# Line 1  Line 1 
1  (*  (*
2   * CM parameters that are configurable via shell-environment variables.   * Mechanism for shell-environment configurable parameters.
3   *   *
4   *   Copyright (c) 1999 by Lucent Technologies, Bell Laboratories.   *   Copyright (c) 1999 by Lucent Technologies, Bell Laboratories.
5   *   *
6   * author: Matthias Blume (blume@cs.princeton.edu)   * author: Matthias Blume (blume@cs.princeton.edu)
7   *)   *)
8  structure EnvConfig = struct  signature ENVCONFIG = sig
9      local  
10          fun cfg cvt reg session fallback = let      type 'a getterSetter = 'a option -> 'a
11    
12        val new : (string -> 'a option) -> string * 'a -> 'a getterSetter
13    
14        val init : unit -> unit
15    end
16    
17    structure EnvConfig :> ENVCONFIG = struct
18    
19        type 'a getterSetter = 'a option -> 'a
20    
21        fun cfg cvt reg session0 fallback = let
22            val session = "CM_" ^ session0
23              val default = session ^ "_DEFAULT"              val default = session ^ "_DEFAULT"
24              val getEnv = Option.join o (Option.map cvt) o OS.Process.getEnv              val getEnv = Option.join o (Option.map cvt) o OS.Process.getEnv
25              val r = ref (getOpt (getEnv default, fallback))              val r = ref (getOpt (getEnv default, fallback))
# Line 17  Line 29 
29          in          in
30              (getterSetter, reg)              (getterSetter, reg)
31          end          end
         val bool = Bool.fromString  
         fun string s = SOME s  
         val int = Int.fromString  
     in  
         val r = fn () => ()  
   
         val (verbose, r) = cfg bool r "CM_VERBOSE" true  
         val (debug, r) = cfg bool r "CM_DEBUG" false  
         val (keep_going, r) = cfg bool r "CM_KEEP_GOING" false  
         val (show_exports, r) = cfg bool r "CM_SHOW_EXPORTS" false  
32    
33          val (lex, r) = cfg string r "CM_LEX" "ml-lex"      val chain = ref (fn () => ())
         val (yacc, r) = cfg string r "CM_YACC" "ml-yacc"  
         val (burg, r) = cfg string r "CM_BURG" "ml-burg"  
         val (rcsco, r) = cfg string r "CM_RCSCO" "co -q"  
34    
35          val (parse_caching, r) = cfg int r "CM_PARSE_CACHING" 100      fun new cvt (session0, fallback) = let
36            val (getterSetter, newChain) = cfg cvt (!chain) session0 fallback
37          val register_all = r      in
38            chain := newChain;
39            getterSetter
40      end      end
41    
42        fun init () = !chain ()
43  end  end

Legend:
Removed from v.275  
changed lines
  Added in v.276

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