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-yacc/src/export-yacc.sml
ViewVC logotype

Annotation of /sml/trunk/src/ml-yacc/src/export-yacc.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 250 - (view) (download)

1 : monnier 249 (* export-yacc.sml
2 :     *
3 :     * ML-Yacc Parser Generator (c) 1991 Andrew W. Appel, David R. Tarditi
4 :     *
5 :     * $Log$
6 :     * Revision 1.1.1.10 1999/04/17 18:56:11 monnier
7 :     * version 110.16
8 :     *
9 :     * Revision 1.1.1.1 1998/04/08 18:40:16 george
10 :     * Version 110.5
11 :     *
12 :     * Revision 1.2 1997/03/03 17:10:37 george
13 :     * moved callcc related functions to SMLofNJ.Cont
14 :     *
15 :     # Revision 1.1.1.1 1997/01/14 01:38:05 george
16 :     # Version 109.24
17 :     #
18 :     * Revision 1.3 1996/02/26 16:55:22 jhr
19 :     * Moved exportFn/exportML to SMLofNJ structure.
20 :     *
21 :     * Revision 1.2 1996/02/26 15:02:32 george
22 :     * print no longer overloaded.
23 :     * use of makestring has been removed and replaced with Int.toString ..
24 :     * use of IO replaced with TextIO
25 :     *
26 :     * Revision 1.1.1.1 1996/01/31 16:01:45 george
27 :     * Version 109
28 :     *
29 :     *)
30 :    
31 :     structure ExportParseGen : sig
32 :    
33 :     val parseGen : (string * string list) -> OS.Process.status
34 :     val export : string -> unit
35 :    
36 :     end = struct
37 :     fun err msg = TextIO.output (TextIO.stdErr, msg)
38 :    
39 :     exception Interrupt;
40 :    
41 :     (* This function applies operation to (). If it handles an interrupt
42 :     signal (Control-C), it raises the exception Interrupt. Example:
43 :     (handleInterrupt foo) handle Interrupt => print "Bang!\n" *)
44 :    
45 :     fun handleInterrupt (operation : unit -> unit) =
46 :     let exception Done
47 :     val old'handler = Signals.inqHandler(Signals.sigINT)
48 :     fun reset'handler () =
49 :     Signals.setHandler(Signals.sigINT, old'handler)
50 :     in (SMLofNJ.Cont.callcc (fn k =>
51 :     (Signals.setHandler(Signals.sigINT, Signals.HANDLER(fn _ => k));
52 :     operation ();
53 :     raise Done));
54 :     err ("\n--- Interrupt ml-yacc ---\n");
55 :     raise Interrupt)
56 :     handle Done => (reset'handler ())
57 :     | exn => (reset'handler (); raise exn)
58 :     end
59 :    
60 :     val exit = OS.Process.exit
61 :    
62 :     fun parseGen (_, argv) = let
63 :     fun parse_gen () = (case argv
64 :     of [file] => (ParseGen.parseGen file; exit OS.Process.success)
65 :     | _ => (err("Usage: ml-yacc filename\n"); exit OS.Process.failure)
66 :     (* end case *))
67 :     in
68 :     (handleInterrupt parse_gen; OS.Process.success)
69 :     handle Interrupt => OS.Process.failure
70 :     | ex => (
71 :     err (String.concat[
72 :     "? ml-yacc: uncaught exception ", exnMessage ex, "\n"
73 :     ]);
74 :     OS.Process.failure)
75 :     end
76 :    
77 :     fun export heap = SMLofNJ.exportFn(heap, parseGen);
78 :    
79 :     end;
80 :    
81 :    

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