Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/gen/fragments/mkfrags.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/gen/fragments/mkfrags.sml

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

revision 3815, Wed May 4 15:06:28 2016 UTC revision 3816, Wed May 4 16:34:21 2016 UTC
# Line 11  Line 11 
11    
12  structure MkFrags : sig  structure MkFrags : sig
13    
14      val doit : string -> unit      val mkFragments : string -> unit
15    
16      val main : string * string list -> OS.Process.status      val mkMakefile : string -> unit
17    
18    end = struct    end = struct
19    
20      structure F = Format      structure F = Format
21    
     val smlHead = "\  
           \(* %s\n\  
           \ *\n\  
           \ * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)\n\  
           \ *\n\  
           \ * COPYRIGHT (c) 2016 The University of Chicago\n\  
           \ * All rights reserved.\n\  
           \ *\n\  
           \ * !!! THIS FILE WAS GENERATED; DO NOT EDIT !!!\n\  
           \ *)\n\  
           \\n\  
           \structure Fragments =\n\  
           \  struct\n\  
           \"  
   
     val smlFoot = "\  
           \\n\  
           \  end\n\  
           \"  
   
22    (* load the catalog from the file *)    (* load the catalog from the file *)
23      fun loadCatalog file = let      fun loadCatalog file = let
24            val inS = TextIO.openIn file            val inS = TextIO.openIn file
# Line 61  Line 41 
41                handle ex => (TextIO.closeIn inS; raise ex)                handle ex => (TextIO.closeIn inS; raise ex)
42            end            end
43    
44        val smlHead = "\
45              \(* %s\n\
46              \ *\n\
47              \ * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)\n\
48              \ *\n\
49              \ * COPYRIGHT (c) 2016 The University of Chicago\n\
50              \ * All rights reserved.\n\
51              \ *\n\
52              \ * !!! THIS FILE WAS GENERATED; DO NOT EDIT !!!\n\
53              \ *)\n\
54              \\n\
55              \structure Fragments =\n\
56              \  struct\n\
57              \"
58    
59        val smlFoot = "\
60              \\n\
61              \  end\n\
62              \"
63    
64    (* load the contents of an ".in" file *)    (* load the contents of an ".in" file *)
65      fun load srcFile = let      fun load srcFile = let
66            val inS = TextIO.openIn srcFile            val inS = TextIO.openIn srcFile
# Line 85  Line 85 
85              prf ("          \\\"\n", [])              prf ("          \\\"\n", [])
86            end            end
87    
88      fun doit dir = let      fun mkFragments dir = let
89            val fragDir = OS.Path.concat(dir, "fragments")            val fragDir = OS.Path.concat(dir, "fragments")
90            val catalogFile = OS.Path.concat(fragDir, "CATALOG")            val catalogFile = OS.Path.concat(fragDir, "CATALOG")
91            val fragFile = OS.Path.concat(dir, "fragments.sml")            val fragFile = OS.Path.concat(dir, "fragments.sml")
# Line 101  Line 101 
101              TextIO.closeOut outS              TextIO.closeOut outS
102            end            end
103    
104      fun main (_, [srcDir]) = (      val mkHead = "\
105            (doit srcDir; OS.Process.success) handle _ => OS.Process.failure)            \# fragments.gmk\n\
106        | main _ = (            \#\n\
107            TextIO.output(TextIO.stdErr, "usage: mkfrags <dir>\n");            \# This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)\n\
108            OS.Process.failure)            \#\n\
109              \# COPYRIGHT (c) 2016 The University of Chicago\n\
110              \# All rights reserved.\n\
111              \#\n\
112              \# !!! THIS FILE WAS GENERATED; DO NOT EDIT !!!\n\
113              \#\n\
114              \\n\
115              \"
116    
117        fun mkMakefile dir = let
118              val fragDir = OS.Path.concat(dir, "fragments")
119              val catalogFile = OS.Path.concat(fragDir, "CATALOG")
120              val makefile = OS.Path.concat(dir, "fragments.gmk")
121              val catalog = if OS.FileSys.access(catalogFile, [OS.FileSys.A_READ])
122                    then loadCatalog catalogFile
123                    else raise Fail(concat["cannot find \"", catalogFile, "\""])
124              val outS = TextIO.openOut makefile
125              fun prf (fmt, items) = TextIO.output(outS, F.format fmt items)
126              fun prDep file = prf(" \\\n    %s/fragments/%s", [F.STR dir, F.STR file])
127              in
128                prf (mkHead, []);
129                prf ("%s/fragments.sml:", [F.STR dir]);
130                prDep "CATALOG";
131                List.app (fn (srcFile, _) => prDep srcFile) catalog;
132                prf ("\n", []);
133                TextIO.closeOut outS
134              end
135    
136    end    end

Legend:
Removed from v.3815  
changed lines
  Added in v.3816

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