(* * ElabMain.elabMain reads an expression from stdIn and returns * a new static environment and Absyn.dec. *) signature ELABMAIN = sig (* Elaborate first declaration then quit *) val elabMain1 : string option -> Absyn.dec * StaticEnv.staticEnv (* Elaborate all declarations in source *) val elabMain : string option -> Absyn.dec * StaticEnv.staticEnv end (* sig *) structure ElabMain : ELABMAIN = struct local structure Instantiate = InstantiateFn (InstantiateParam) structure EvalEntity = EvalEntityFn (structure I = Instantiate) structure SigMatch = SigMatchFn (structure EV = EvalEntity) structure Typecheck = TypecheckFn (fun ii_ispure _ = true val ii2ty = InstantiateParam.ii2ty) structure ElabMod = ElabModFn (structure SM = SigMatch structure Typecheck = Typecheck) structure ElabTop = ElabTopFn (structure ElabMod = ElabMod) structure PU = PEUtil in fun elabMainP parse strOpt = let val {exportLvars=_,exportPid=_,newenv=theBaseEnv,pickle=_,pid=_} = Pup.pickBase(SavedEnv.makeSavedEnv ()) val source = ParserInterface.whichSource strOpt val astdec = parse source val cinfo = CompInfo.mkCompInfo {source = source, transform = fn x : Absyn.dec => x, mkMkStamp = Stamps.newGenerator} val (newast, newenv) = ElabTop.elabTop (astdec, theBaseEnv, cinfo) in if CompInfo.anyErrors cinfo then raise PU.ElaborationError else (newast, newenv) end val elabMain1 = elabMainP ParserInterface.parseOne val elabMain = elabMainP ParserInterface.parseAll end (* local *) end (* struct *)