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/compiler/TopLevel/interact/interact.sml
ViewVC logotype

Annotation of /sml/trunk/src/compiler/TopLevel/interact/interact.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1712 - (view) (download)

1 : monnier 16 (* COPYRIGHT (c) 1996 Bell Laboratories. *)
2 :     (* interact.sml *)
3 :    
4 :     functor Interact(EvalLoop : EVALLOOP) : INTERACT =
5 :     struct
6 :     exception Interrupt = EvalLoop.Interrupt
7 :    
8 :     type envref = EnvRef.envref
9 :    
10 : mblume 1393 val installCompManagers = EvalLoop.installCompManagers
11 : monnier 16
12 : blume 905 fun interact() = (EvalLoop.interact (); OS.Process.exit OS.Process.success)
13 : monnier 16
14 : mblume 1712 val withErrorHandling = EvalLoop.withErrorHandling
15 :    
16 : blume 905 fun useFile fname =
17 : monnier 16 (app Control.Print.say ["[opening ",fname,"]\n"];
18 : blume 905 EvalLoop.evalStream
19 :     (fname, (TextIO.openIn fname
20 :     handle e as IO.Io _ =>
21 :     (app Control.Print.say["[use failed: ",
22 :     General.exnMessage e,
23 :     "]\n"];
24 :     raise ErrorMsg.Error))))
25 : monnier 16
26 : blume 905 fun useStream stream = EvalLoop.evalStream ("<instream>", stream)
27 : monnier 16
28 : blume 905 fun evalStream (stream, baseEnv) = let
29 :     val r = ref Environment.emptyEnv
30 :     val base = { set = fn _ => raise Fail "evalStream: #set base",
31 :     get = fn () => baseEnv }
32 :     val loc = { set = fn e => r := e,
33 :     get = fn () => !r }
34 :     val props = PropList.newHolder ()
35 :     val state = { loc = loc, base = base, props = props }
36 :     in
37 :     EnvRef.locally (state,
38 :     fn () => (EvalLoop.evalStream ("<instream>", stream);
39 :     !r))
40 :     end
41 : monnier 16
42 :     end (* functor Interact *)

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