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/tools/main/core-tools.sig
ViewVC logotype

Annotation of /sml/trunk/src/cm/tools/main/core-tools.sig

Parent Directory Parent Directory | Revision Log Revision Log


Revision 742 - (view) (download) (as text)

1 : blume 742 (*
2 :     * The common core of both public and private interface to CM's tools
3 :     * mechanism.
4 :     *
5 :     * (C) 2000 Lucent Technologies, Bell Laboratories
6 :     *
7 :     * Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)
8 :     *)
9 :     signature CORETOOLS = sig
10 :    
11 :     (* We don't make classes abstract. It doesn't look like there
12 :     * would be much point to it. *)
13 :     type class = string
14 :    
15 :     (* We keep source paths abstract. Tool writers should not mess
16 :     * with their internals.
17 :     * The function that makes a srcpath from a string is passed as
18 :     * part of the input specification (type "spec"). Which function
19 :     * is originally being passed depends on which syntax was used for
20 :     * this member in its .cm-file. Most tools will want to work on
21 :     * native pathname syntax (function "outdated" -- see below -- depends
22 :     * on native syntax!). In these cases the tool should first convert
23 :     * the name to a srcpath and then get the native string back by
24 :     * applying "nativeSpec". *)
25 :     type srcpath
26 :     type presrcpath
27 :    
28 :     type rebindings = { anchor: string, value: presrcpath } list
29 :    
30 :     val nativeSpec : srcpath -> string
31 :    
32 :     val nativePre : presrcpath -> string
33 :    
34 :     val srcpath : presrcpath -> srcpath
35 :    
36 :     exception ToolError of { tool: string, msg: string }
37 :    
38 :     type pathmaker = string -> presrcpath
39 :    
40 :     (* case-by-case parameters that can be passed to tools... *)
41 :     datatype toolopt =
42 :     STRING of { name: string, mkpath: pathmaker }
43 :     | SUBOPTS of { name: string, opts: toolopts }
44 :     withtype toolopts = toolopt list
45 :    
46 :     type tooloptcvt = toolopts option -> toolopts option
47 :    
48 :     (* A member specification consists of the actual string, an optional
49 :     * class name, (optional) tool options, a function to convert a
50 :     * string to its corresponding srcpath, and information about whether
51 :     * or not this source is an "original" source or a derived source
52 :     * (i.e., output of some tool). *)
53 :     type spec = { name: string,
54 :     mkpath: pathmaker,
55 :     class: class option,
56 :     opts: toolopts option,
57 :     derived: bool }
58 :    
59 :     type setup = string option * string option (* (pre, post) *)
60 :    
61 :     (* The goal of applying tools to members is to obtain an "expansion",
62 :     * i.e., a list of ML-files and a list of .cm-files. We also
63 :     * obtain a list of "sources". This is used to implement CM.sources,
64 :     * i.e., to generate dependency information etc. *)
65 :     type expansion =
66 :     { smlfiles: (srcpath * Sharing.request * setup) list,
67 :     cmfiles: (srcpath * Version.t option * rebindings) list,
68 :     sources: (srcpath * { class: class, derived: bool}) list }
69 :    
70 :     (* A partial expansion is an expansion with a list of things yet to be
71 :     * expanded... *)
72 :     type partial_expansion = expansion * spec list
73 :    
74 :     (* A rule takes a spec and a rulecontext where the name contained
75 :     * in the spec -- if relative -- is considered relative to the directory
76 :     * of the corresponding description file. In general,
77 :     * when coding a rule one would write a rule function and pass it to
78 :     * the context, which will temporarily change the current working
79 :     * directory to the one that holds the description file ("the context").
80 :     * If this is not necessary for the rule to work correctly, then
81 :     * one can simply ignore the context (this saves system call overhead
82 :     * during dependency analysis).
83 :     * If the rule yields a genuine partial expansion (where the resulting
84 :     * spec list is not empty), then it must pass the proper "path maker"
85 :     * along with each new name. For most cases this will be the given
86 :     * "native path maker" because most rules work on native path names.
87 :     * Some rules, however, might want to use the same convention for
88 :     * derived specs that was used for the original spec. *)
89 :     type rulefn = unit -> partial_expansion
90 :     type rulecontext = rulefn -> partial_expansion
91 :     type rule =
92 :     { spec: spec, mkNativePath: pathmaker, context: rulecontext } ->
93 :     partial_expansion
94 :    
95 :     (* install a class *)
96 :     val registerClass : class * rule -> unit
97 :    
98 :     (* classifiers are used when the class is not given explicitly *)
99 :     datatype classifier =
100 :     SFX_CLASSIFIER of string -> class option
101 :     | GEN_CLASSIFIER of string -> class option
102 :    
103 :     (* make a classifier which looks for a specific file name suffix *)
104 :     val stdSfxClassifier : { sfx: string , class: class } -> classifier
105 :    
106 :     (* two standard ways of dealing with filename extensions...
107 :     * (Tool options can be calculated from the options that we have.) *)
108 :     datatype extensionStyle =
109 :     EXTEND of (string * class option * tooloptcvt) list
110 :     | REPLACE of string list * (string * class option * tooloptcvt) list
111 :    
112 :     (* perform filename extension *)
113 :     val extend : extensionStyle ->
114 :     (string * toolopts option) ->
115 :     (string * class option * toolopts option) list
116 :    
117 :     (* check for outdated files; the pathname strings must be in
118 :     * native syntax! *)
119 :     val outdated : string -> string list * string -> bool
120 :    
121 :     (* Alternative way of checking for outdated-ness using a "witness"
122 :     * file. The idea is that if both tgt (target) and wtn (witness)
123 :     * exist, then tgt is considered outdated if wtn is older than src.
124 :     * Otherwise, if tgt exists but wtn does not, then tgt is considered
125 :     * outdated if it is older than src. If tgt does not exist, it is
126 :     * always considered outdated. *)
127 :     val outdated' : string ->
128 :     { src: string, wtn: string, tgt: string } -> bool
129 :    
130 :     (* open output file; make all necessary directories for it *)
131 :     val openTextOut : string -> TextIO.outstream
132 :    
133 :     (* make all directories leading up to a given file; the file itself
134 :     * is to be left alone *)
135 :     val makeDirs : string -> unit
136 :    
137 :     (* install a classifier *)
138 :     val registerClassifier : classifier -> unit
139 :    
140 :     (* grab all named options... *)
141 :     val parseOptions :
142 :     { tool : string, keywords : string list, options : toolopts } ->
143 :     { matches : string -> toolopts option, restoptions : string list }
144 :     end

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