Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /sml/trunk/src/compiler/TopLevel/interact/interact.sml
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1712 - (download) (annotate)
Tue Nov 23 20:44:10 2004 UTC (15 years, 2 months ago) by mblume
File size: 1231 byte(s)
problem with unhelpful error messages addressed
(* COPYRIGHT (c) 1996 Bell Laboratories. *)
(* interact.sml *)

functor Interact(EvalLoop : EVALLOOP) : INTERACT =
struct
  exception Interrupt = EvalLoop.Interrupt

  type envref = EnvRef.envref

  val installCompManagers = EvalLoop.installCompManagers

  fun interact() = (EvalLoop.interact (); OS.Process.exit OS.Process.success)

  val withErrorHandling = EvalLoop.withErrorHandling

  fun useFile fname =
      (app Control.Print.say ["[opening ",fname,"]\n"];
       EvalLoop.evalStream
	   (fname, (TextIO.openIn fname
		    handle e as IO.Io _ =>
			   (app Control.Print.say["[use failed: ",
						  General.exnMessage e,
						  "]\n"];
			    raise ErrorMsg.Error))))

  fun useStream stream = EvalLoop.evalStream ("<instream>", stream)

  fun evalStream (stream, baseEnv) = let
      val r = ref Environment.emptyEnv
      val base = { set = fn _ => raise Fail "evalStream: #set base",
		   get = fn () => baseEnv }
      val loc = { set = fn e => r := e,
		  get = fn () => !r }
      val props = PropList.newHolder ()
      val state = { loc = loc, base = base, props = props }
  in
      EnvRef.locally (state,
		      fn () => (EvalLoop.evalStream ("<instream>", stream);
				!r))
  end

end (* functor Interact *)

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