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/ml-burg/main.sml
ViewVC logotype

Annotation of /sml/trunk/src/ml-burg/main.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 228 - (view) (download)

1 : monnier 2 (* main.sml
2 :     *
3 :     * COPYRIGHT (c) 1994 AT&T Bell Laboratories.
4 :     *
5 :     * $Log$
6 : monnier 227 * Revision 1.1.1.6 1999/04/17 17:10:41 monnier
7 :     * version 110.12
8 : monnier 2 *
9 : monnier 8 * Revision 1.1.1.1 1997/01/14 01:37:59 george
10 :     * Version 109.24
11 :     *
12 : monnier 2 * Revision 1.1.1.2 1997/01/11 18:52:31 george
13 :     * ml-burg Version 109.24
14 :     *
15 :     * Revision 1.3 1996/02/26 16:55:12 jhr
16 :     * Moved exportFn/exportML to SMLofNJ structure.
17 :     *
18 :     * Revision 1.2 1996/02/26 15:02:06 george
19 :     * print no longer overloaded.
20 :     * use of makestring has been removed and replaced with Int.toString ..
21 :     * use of IO replaced with TextIO
22 :     *
23 :     * Revision 1.1.1.1 1996/01/31 16:01:25 george
24 :     * Version 109
25 :     *
26 :     *)
27 :    
28 :     structure Main =
29 :     struct
30 :    
31 :     fun main (cmdName, argv) = let
32 :     fun help () = (
33 :     TextIO.output (TextIO.stdErr, "usage: mlburg [<filename>.burg]\n");
34 :     OS.Process.failure)
35 :     in
36 :     case argv
37 :     of [] => (
38 :     BurgEmit.emit (TextIO.stdIn, (fn () => TextIO.stdOut));
39 :     OS.Process.success)
40 :     | ("-h"::_) => help ()
41 :     | ("-help"::_) => help ()
42 :     | files => let
43 :     fun findname file = let
44 :     val {base, ext} = OS.Path.splitBaseExt file
45 :     in
46 :     case ext
47 :     of (SOME("brg" | "burg")) =>
48 :     OS.Path.joinBaseExt{base=base, ext=SOME "sml"}
49 :     | _ => file ^ ".sml"
50 :     (* end case *)
51 :     end
52 :     val names = map (fn n => (n,findname n)) files
53 :     fun emit (inname, outname) = (let
54 :     val s_in = TextIO.openIn inname
55 :     in
56 :     BurgEmit.emit (s_in, (fn () => (TextIO.openOut outname)))
57 :     end)
58 :     handle err => (TextIO.output (TextIO.stdErr, exnMessage err^"\n");
59 :     raise err)
60 :     in
61 :     app emit names;
62 :     OS.Process.success
63 :     end
64 :     end
65 :    
66 :     (*
67 :     * This is the function to call in an interactive session.
68 :     * Takes a filename (something.burg) as argument, and produces something.sml
69 :     *)
70 :     fun doit s = main ("", [s])
71 :    
72 :     (* create a stand-alone executable *)
73 :     fun export name = SMLofNJ.exportFn (name, main)
74 :    
75 :     end;
76 :    

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