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/load
ViewVC logotype

Annotation of /sml/trunk/src/ml-burg/load

Parent Directory Parent Directory | Revision Log Revision Log


Revision 250 - (view) (download)

1 : monnier 249 (*
2 :     * Load the files that make up mlburg, and prepare for use in
3 :     * an interactive session.
4 :     * You may need to change the path to the SML/NJ Library.
5 :     *
6 :     * To export an executable, *in an sml-noshare* :
7 :     * exportFn ("mlburg", Burg.prog);
8 :     *)
9 :    
10 :     let
11 :     val smlnjLibDir = "../smlnj-lib/"
12 :     in
13 :    
14 :     app use [
15 :     "errormsg.sml",
16 :     "burg-ast.sml",
17 :     "mlyacc-base.sml",
18 :     "burg-gram.sig",
19 :     "burg-lex.sml",
20 :     "burg-gram.sml",
21 :     "parse.sml",
22 :     smlnjLibDir ^ "hash-key-sig.sml",
23 :     smlnjLibDir ^ "hash-table-sig.sml",
24 :     smlnjLibDir ^ "hash-table.sml",
25 :     smlnjLibDir ^ "hash-string.sml",
26 :     "burg.sml"
27 :     ]
28 :     end;
29 :    
30 :     structure Burg = struct
31 :     fun prog (argv, _) =
32 :     let
33 :     fun help () = output (std_err, "usage: mlburg [<filename>.burg]\n")
34 :     in
35 :     case argv of
36 :     [] => output (std_err, "?? argv is []\n")
37 :     | [_] => BurgEmit.emit (std_in, (fn () => std_out))
38 :     | (_::"-h"::_) => help ()
39 :     | (_::"-help"::_) => help ()
40 :     | (_::files) => let
41 :     (**
42 :     fun findfile file = let
43 :     val {dir, name, ext} = OS.Path.splitPath file
44 :     in
45 :     case ext
46 :     of (OS.Path.EXT("brg" | "burg")) =>
47 :     OS.Path.makePath{dir=dir, name=name, ext="sml"}
48 :     | _ => file ^ ".sml"
49 :     (* end case *)
50 :     end
51 :     **)
52 :     fun findname file =
53 :     let
54 :     val lenfile = String.length file
55 :     in
56 :     (if ((lenfile>4) andalso (substring (file, lenfile-4, 4)=".brg"))
57 :     then substring (file, 0, lenfile-4)
58 :     else if ((lenfile>5) andalso (substring (file, lenfile-5, 5)=".burg"))
59 :     then substring (file, 0, lenfile-5)
60 :     else file)
61 :     ^".sml"
62 :     end
63 :     val names = map (fn n => (n,findname n)) files
64 :     fun emit (inname, outname) =
65 :     (let
66 :     val s_in = open_in inname
67 :     in
68 :     BurgEmit.emit (s_in, (fn () => (open_out outname)))
69 :     end)
70 :     handle (err as (Io s)) => (output (std_err, s^"\n"); raise err)
71 :     in
72 :     app emit names
73 :     end
74 :     end
75 :     (*
76 :     * This is the function to call in an interactive session.
77 :     * Takes a filename (something.burg) as argument, and produces something.sml
78 :     *)
79 :     fun doit s = prog (["",s],())
80 :    
81 :     end
82 :    

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