Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Annotation of /trunk/src/compiler/typechecker/typechecker.sml
ViewVC logotype

Annotation of /trunk/src/compiler/typechecker/typechecker.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 171 - (view) (download)

1 : jhr 69 (* typechecker.sml
2 :     *
3 :     * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)
4 :     * All rights reserved.
5 :     *)
6 :    
7 :     structure Typechecker : sig
8 :    
9 : jhr 88 exception Error
10 :    
11 : jhr 86 val check : Error.err_stream -> ParseTree.program -> AST.program
12 : jhr 69
13 :     end = struct
14 :    
15 : jhr 70 structure PT = ParseTree
16 : jhr 69 structure Ty = Types
17 : jhr 96 structure TU = TypeUtil
18 : jhr 81 structure U = Util
19 : jhr 69
20 : jhr 169 type env = {globalScope : bool, env : Env.env}
21 :    
22 : jhr 88 exception Error
23 :    
24 : jhr 86 type context = Error.err_stream * Error.span
25 :    
26 :     fun withContext ((errStrm, _), {span, tree}) =
27 :     ((errStrm, span), tree)
28 :     fun withEnvAndContext (env, (errStrm, _), {span, tree}) =
29 :     (env, (errStrm, span), tree)
30 :    
31 : jhr 88 fun error ((errStrm, span), msg) = (
32 :     Error.errorAt(errStrm, span, msg);
33 :     raise Error)
34 : jhr 86
35 : jhr 88 datatype token
36 :     = S of string | A of Atom.atom
37 :     | V of AST.var | TY of Types.ty | TYS of Types.ty list
38 :    
39 :     fun err (cxt, toks) = let
40 :     fun tok2str (S s) = s
41 :     | tok2str (A a) = Atom.toString a
42 :     | tok2str (V x) = Var.nameOf x
43 : jhr 96 | tok2str (TY ty) = TU.toString ty
44 : jhr 88 | tok2str (TYS []) = "()"
45 : jhr 96 | tok2str (TYS[ty]) = TU.toString ty
46 : jhr 88 | tok2str (TYS tys) = String.concat[
47 : jhr 96 "(", String.concatWith " * " (List.map TU.toString tys), ")"
48 : jhr 88 ]
49 :     in
50 :     error(cxt, List.map tok2str toks)
51 :     end
52 :    
53 : jhr 83 val realZero = AST.E_Lit(Literal.Float(FloatLit.zero true))
54 :    
55 : jhr 70 (* check a differentiation level, which muse be >= 0 *)
56 :     fun checkDiff (cxt, k) =
57 :     if (k < 0)
58 :     then raise Fail "differentiation must be >= 0"
59 : jhr 75 else Ty.DiffConst(IntInf.toInt k)
60 : jhr 70
61 :     (* check a dimension, which must be 2 or 3 *)
62 :     fun checkDim (cxt, d) =
63 : jhr 82 if (d <= 0)
64 :     then raise Fail "invalid dimension; must be > 0"
65 : jhr 75 else Ty.DimConst(IntInf.toInt d)
66 : jhr 70
67 :     (* check a shape *)
68 :     fun checkShape (cxt, shape) = let
69 :     fun chkDim d = if (d < 1)
70 :     then raise Fail "invalid shape dimension; must be >= 1"
71 : jhr 75 else Ty.DimConst(IntInf.toInt d)
72 : jhr 70 in
73 :     Ty.Shape(List.map chkDim shape)
74 :     end
75 :    
76 : jhr 69 (* check the well-formedness of a type and translate it to an AST type *)
77 : jhr 70 fun checkTy (cxt, ty) = (case ty
78 : jhr 86 of PT.T_Mark m => checkTy(withContext(cxt, m))
79 : jhr 70 | PT.T_Bool => Ty.T_Bool
80 :     | PT.T_Int => Ty.T_Int
81 :     | PT.T_Real => Ty.realTy
82 :     | PT.T_String => Ty.T_String
83 :     | PT.T_Vec n => (* NOTE: the parser guarantees that 2 <= n <= 4 *)
84 :     Ty.vecTy(IntInf.toInt n)
85 :     | PT.T_Kernel k => Ty.T_Kernel(checkDiff(cxt, k))
86 :     | PT.T_Field{diff, dim, shape} => Ty.T_Field{
87 :     diff = checkDiff (cxt, diff),
88 :     dim = checkDim (cxt, dim),
89 :     shape = checkShape (cxt, shape)
90 :     }
91 :     | PT.T_Tensor shape => Ty.T_Tensor(checkShape(cxt, shape))
92 :     | PT.T_Image{dim, shape} => Ty.T_Image{
93 :     dim = checkDim (cxt, dim),
94 :     shape = checkShape (cxt, shape)
95 :     }
96 : jhr 99 | PT.T_Array(ty, dims) => raise Fail "Array type not supported"
97 : jhr 69 (* end case *))
98 :    
99 : jhr 71 fun checkLit lit = (case lit
100 :     of (Literal.Int _) => (AST.E_Lit lit, Ty.T_Int)
101 :     | (Literal.Float _) => (AST.E_Lit lit, Ty.realTy)
102 :     | (Literal.String s) => (AST.E_Lit lit, Ty.T_String)
103 :     | (Literal.Bool _) => (AST.E_Lit lit, Ty.T_Bool)
104 :     (* end case *))
105 :    
106 : jhr 85 (* resolve overloading: we use a simple scheme that selects the first operator in the
107 :     * list that matches the argument types.
108 :     *)
109 : jhr 91 fun resolveOverload (cxt, rator, argTys, args, candidates) = let
110 :     fun tryCandidates [] = err(cxt, [
111 :     S "unable to resolve overloaded operator \"", A rator, S "\"\n",
112 :     S " argument type is: ", TYS argTys, S "\n"
113 : jhr 85 ])
114 :     | tryCandidates (x::xs) = let
115 :     val (tyArgs, Ty.T_Fun(domTy, rngTy)) = Util.instantiate(Var.typeOf x)
116 :     in
117 :     if U.tryMatchTypes(domTy, argTys)
118 :     then (AST.E_Apply(x, tyArgs, args, rngTy), rngTy)
119 :     else tryCandidates xs
120 :     end
121 :     in
122 :     tryCandidates candidates
123 :     end
124 :    
125 : jhr 70 (* typecheck an expression and translate it to AST *)
126 : jhr 169 fun checkExpr (env : env, cxt, e) = (case e
127 : jhr 86 of PT.E_Mark m => checkExpr (withEnvAndContext (env, cxt, m))
128 : jhr 169 | PT.E_Var x => (case Env.findVar (#env env, x)
129 : jhr 171 of SOME x' => (AST.E_Var x', Var.monoTypeOf x')
130 : jhr 88 | NONE => err(cxt, [S "undeclared variable ", A x])
131 : jhr 71 (* end case *))
132 :     | PT.E_Lit lit => checkLit lit
133 : jhr 81 | PT.E_OrElse(e1, e2) => let
134 :     val (e1', ty1) = checkExpr(env, cxt, e1)
135 :     val (e2', ty2) = checkExpr(env, cxt, e2)
136 :     in
137 :     case (ty1, ty2)
138 :     of (Ty.T_Bool, Ty.T_Bool) =>
139 :     (AST.E_Cond(e1', AST.E_Lit(Literal.Bool true), e2'), Ty.T_Bool)
140 : jhr 99 | _ => err (cxt, [S "arguments to \"||\" must have bool type"])
141 : jhr 81 (* end case *)
142 :     end
143 :     | PT.E_AndAlso(e1, e2) => let
144 :     val (e1', ty1) = checkExpr(env, cxt, e1)
145 :     val (e2', ty2) = checkExpr(env, cxt, e2)
146 :     in
147 :     case (ty1, ty2)
148 :     of (Ty.T_Bool, Ty.T_Bool) =>
149 :     (AST.E_Cond(e1', e2', AST.E_Lit(Literal.Bool false)), Ty.T_Bool)
150 : jhr 99 | _ => err (cxt, [S "arguments to \"&&\" must have bool type"])
151 : jhr 81 (* end case *)
152 :     end
153 :     | PT.E_BinOp(e1, rator, e2) => let
154 :     val (e1', ty1) = checkExpr(env, cxt, e1)
155 :     val (e2', ty2) = checkExpr(env, cxt, e2)
156 :     in
157 :     case Basis.findOp rator
158 :     of [rator] => let
159 :     val (tyArgs, Ty.T_Fun(domTy, rngTy)) = Util.instantiate(Var.typeOf rator)
160 :     in
161 :     if U.matchTypes(domTy, [ty1, ty2])
162 :     then (AST.E_Apply(rator, tyArgs, [e1', e2'], rngTy), rngTy)
163 : jhr 89 else err (cxt, [
164 :     S "type error for binary operator \"", V rator, S "\"\n",
165 :     S " expected: ", TYS domTy, S "\n",
166 :     S " but found: ", TYS[ty1, ty2], S "\n"
167 : jhr 85 ])
168 : jhr 81 end
169 : jhr 91 | ovldList => resolveOverload (cxt, rator, [ty1, ty2], [e1', e2'], ovldList)
170 : jhr 81 (* end case *)
171 :     end
172 :     | PT.E_UnaryOp(rator, e) => let
173 :     val (e', ty) = checkExpr(env, cxt, e)
174 :     in
175 :     case Basis.findOp rator
176 :     of [rator] => let
177 :     val (tyArgs, Ty.T_Fun([domTy], rngTy)) = Util.instantiate(Var.typeOf rator)
178 :     in
179 :     if U.matchType(domTy, ty)
180 :     then (AST.E_Apply(rator, tyArgs, [e'], rngTy), rngTy)
181 : jhr 89 else err (cxt, [
182 :     S "type error for unary operator \"", V rator, S "\"\n",
183 :     S " expected: ", TY domTy, S "\n",
184 :     S " but found: ", TY ty, S "\n"
185 : jhr 85 ])
186 : jhr 81 end
187 : jhr 91 | ovldList => resolveOverload (cxt, rator, [ty], [e'], ovldList)
188 : jhr 81 (* end case *)
189 :     end
190 :     | PT.E_Tuple args => let
191 :     val (args, tys) = checkExprList (env, cxt, args)
192 :     in
193 :     raise Fail "E_Tuple not yet implemented"
194 :     end
195 :     | PT.E_Apply(f, args) => let
196 :     val (args, tys) = checkExprList (env, cxt, args)
197 :     in
198 : jhr 169 case Env.findFunc (#env env, f)
199 :     of SOME f =>
200 :     if (#globalScope env) orelse not(Basis.isRestricted f)
201 :     then (case Util.instantiate(Var.typeOf f)
202 :     of (tyArgs, Ty.T_Fun(domTy, rngTy)) =>
203 :     if U.matchTypes(domTy, tys)
204 :     then (AST.E_Apply(f, tyArgs, args, rngTy), rngTy)
205 :     else err(cxt, [
206 :     S "type error in application of ", V f, S "\n",
207 :     S " expected: ", TYS domTy, S "\n",
208 :     S " but found: ", TYS tys, S "\n"
209 :     ])
210 :     | _ => err(cxt, [S "application of non-function ", V f])
211 :     (* end case *))
212 :     else err(cxt, [S "use of restricted operation ", V f, S " in actor body"])
213 : jhr 99 | NONE => err(cxt, [S "unknown function ", A f])
214 : jhr 81 (* end case *)
215 :     end
216 : jhr 86 | PT.E_Cons args => let
217 :     val (args, ty::tys) = checkExprList (env, cxt, args)
218 : jhr 81 in
219 : jhr 96 case TU.pruneHead ty
220 : jhr 86 of Ty.T_Tensor shape => let
221 :     fun chkTy ty' = U.matchType(ty, ty')
222 :     val resTy = Ty.T_Tensor(Ty.shapeExt(shape, Ty.DimConst(List.length args)))
223 : jhr 83 in
224 : jhr 86 if List.all chkTy tys
225 :     then (AST.E_Cons args, resTy)
226 : jhr 99 else err(cxt, [S "arguments of tensor construction must have same type"])
227 : jhr 83 end
228 : jhr 99 | _ => err(cxt, [S "Invalid argument type for tensor construction"])
229 : jhr 83 (* end case *)
230 : jhr 81 end
231 : jhr 86 | PT.E_Real e => (case checkExpr (env, cxt, e)
232 :     of (e', Ty.T_Int) =>
233 :     (AST.E_Apply(BasisVars.i2r, [], [e'], Ty.realTy), Ty.realTy)
234 : jhr 99 | _ => err(cxt, [S "argument of real conversion must be int"])
235 : jhr 86 (* end case *))
236 : jhr 70 (* end case *))
237 :    
238 : jhr 81 (* typecheck a list of expressions returning a list of AST expressions and a list
239 :     * of types of the expressions.
240 :     *)
241 :     and checkExprList (env, cxt, exprs) = let
242 :     fun chk (e, (es, tys)) = let
243 :     val (e, ty) = checkExpr (env, cxt, e)
244 :     in
245 :     (e::es, ty::tys)
246 :     end
247 :     in
248 :     List.foldr chk ([], []) exprs
249 :     end
250 :    
251 : jhr 72 fun checkVarDecl (env, cxt, kind, d) = (case d
252 : jhr 86 of PT.VD_Mark m => checkVarDecl (env, (#1 cxt, #span m), kind, #tree m)
253 : jhr 72 | PT.VD_Decl(ty, x, e) => let
254 : jhr 81 val ty = checkTy (cxt, ty)
255 : jhr 72 val x' = Var.new (x, kind, ty)
256 :     val (e', ty') = checkExpr (env, cxt, e)
257 :     in
258 : jhr 99 (* FIXME: this check is not flexible enough; should allow lhs type to support
259 :     * fewer levels of differentiation than rhs provides.
260 :     *)
261 :     if U.matchType(ty, ty')
262 :     then (x, x', e')
263 :     else err(cxt, [
264 :     S "type of variable ", A x,
265 :     S " does not match type of initializer\n",
266 :     S " expected: ", TY ty, S "\n",
267 :     S " but found: ", TY ty', S "\n"
268 :     ])
269 : jhr 72 end
270 :     (* end case *))
271 :    
272 : jhr 169 fun checkGlobalExpr (env, cxt, exp) = checkExpr ({globalScope=true, env=env}, cxt, exp)
273 :     fun checkLocalExpr (env, cxt, exp) = checkExpr ({globalScope=false, env=env}, cxt, exp)
274 :     fun checkLocalExprList (env, cxt, exp) = checkExprList ({globalScope=false, env=env}, cxt, exp)
275 :    
276 : jhr 70 (* typecheck a statement and translate it to AST *)
277 : jhr 71 fun checkStmt (env, cxt, s) = (case s
278 : jhr 86 of PT.S_Mark m => checkStmt (withEnvAndContext (env, cxt, m))
279 : jhr 72 | PT.S_Block stms => let
280 :     fun chk (_, [], stms) = AST.S_Block(List.rev stms)
281 :     | chk (env, s::ss, stms) = let
282 :     val (s', env') = checkStmt (env, cxt, s)
283 :     in
284 : jhr 81 chk (env', ss, s'::stms)
285 : jhr 72 end
286 :     in
287 :     (chk (env, stms, []), env)
288 :     end
289 :     | PT.S_Decl vd => let
290 : jhr 169 val (x, x', e) = checkVarDecl ({globalScope=false, env=env}, cxt, Var.LocalVar, vd)
291 : jhr 72 in
292 : jhr 81 (AST.S_Decl(AST.VD_Decl(x', e)), Env.insertLocal(env, x, x'))
293 : jhr 72 end
294 :     | PT.S_IfThen(e, s) => let
295 : jhr 169 val (e', ty) = checkLocalExpr (env, cxt, e)
296 : jhr 81 val (s', _) = checkStmt (env, cxt, s)
297 : jhr 72 in
298 :     (* check that condition has bool type *)
299 :     case ty
300 :     of Ty.T_Bool => ()
301 : jhr 99 | _ => err(cxt, [S "condition not boolean type"])
302 : jhr 72 (* end case *);
303 :     (AST.S_IfThenElse(e', s', AST.S_Block[]), env)
304 :     end
305 :     | PT.S_IfThenElse(e, s1, s2) => let
306 : jhr 169 val (e', ty) = checkLocalExpr (env, cxt, e)
307 : jhr 81 val (s1', _) = checkStmt (env, cxt, s1)
308 :     val (s2', _) = checkStmt (env, cxt, s2)
309 : jhr 72 in
310 :     (* check that condition has bool type *)
311 :     case ty
312 :     of Ty.T_Bool => ()
313 : jhr 99 | _ => err(cxt, [S "condition not boolean type"])
314 : jhr 72 (* end case *);
315 :     (AST.S_IfThenElse(e', s1', s2'), env)
316 :     end
317 :     | PT.S_Assign(x, e) => (case Env.findVar (env, x)
318 : jhr 99 of NONE => err(cxt, [
319 :     S "undefined variable ", A x
320 :     ])
321 : jhr 72 | SOME x' => let
322 : jhr 99 (* FIXME: check for polymorphic variables *)
323 :     val ([], ty) = Var.typeOf x'
324 : jhr 169 val (e', ty') = checkLocalExpr (env, cxt, e)
325 : jhr 72 in
326 : jhr 99 if U.matchType(ty, ty')
327 :     then (x, x', e')
328 :     else err(cxt, [
329 :     S "type of assigned variable ", A x,
330 :     S " does not match type of rhs\n",
331 :     S " expected: ", TY ty, S "\n",
332 :     S " but found: ", TY ty', S "\n"
333 :     ]);
334 : jhr 72 (* check that x' is mutable *)
335 :     case Var.kindOf x'
336 :     of Var.ActorStateVar => ()
337 :     | Var.LocalVar => ()
338 : jhr 99 | _ => err(cxt, [
339 :     S "assignment to immutable variable ", A x
340 :     ])
341 : jhr 72 (* end case *);
342 :     (AST.S_Assign(x', e'), env)
343 :     end
344 :     (* end case *))
345 :     | PT.S_New(actor, args) => let
346 : jhr 169 val argsAndTys' = List.map (fn e => checkLocalExpr(env, cxt, e)) args
347 : jhr 81 val (args', tys') = ListPair.unzip argsAndTys'
348 : jhr 72 in
349 :     (* FIXME: check that actor is defined and has the argument types match *)
350 : jhr 81 (AST.S_New(actor, args'), env)
351 : jhr 72 end
352 :     | PT.S_Die => (AST.S_Die, env)
353 :     | PT.S_Stabilize => (AST.S_Stabilize, env)
354 : jhr 70 (* end case *))
355 :    
356 : jhr 82 fun checkParams (env, cxt, params) = let
357 :     fun chkParam (env, cxt, param) = (case param
358 : jhr 86 of PT.P_Mark m => chkParam (withEnvAndContext (env, cxt, m))
359 : jhr 82 | PT.P_Param(ty, x) => let
360 :     val x' = Var.new(x, AST.ActorParam, checkTy (cxt, ty))
361 :     in
362 :     (x', Env.insertLocal(env, x, x'))
363 :     end
364 :     (* end case *))
365 :     fun chk (param, (xs, env)) = let
366 :     val (x, env) = chkParam (env, cxt, param)
367 :     in
368 :     (x::xs, env)
369 :     end
370 :     in
371 :     (* FIXME: need to check for multiple occurences of the same parameter name! *)
372 :     List.foldr chk ([], env) params
373 :     end
374 :    
375 :     fun checkMethod (env, cxt, meth) = (case meth
376 : jhr 86 of PT.M_Mark m => checkMethod (withEnvAndContext (env, cxt, m))
377 : jhr 82 | PT.M_Method(name, body) => let
378 :     val (body, _) = checkStmt(env, cxt, body)
379 :     in
380 :     AST.M_Method(name, body)
381 :     end
382 :     (* end case *))
383 :    
384 :     fun checkActor (env, cxt, {name, params, state, methods}) = let
385 :     (* check the actor parameters *)
386 :     val (params, env) = checkParams (env, cxt, params)
387 :     (* check the actor state variable definitions *)
388 :     val (vds, env) = let
389 : jhr 164 fun checkStateVar ((isOut, vd), (vds, env)) = let
390 : jhr 169 val (x, x', e') = checkVarDecl ({globalScope=false, env=env}, cxt, AST.ActorStateVar, vd)
391 : jhr 82 in
392 : jhr 164 ((isOut, AST.VD_Decl(x', e'))::vds, Env.insertLocal(env, x, x'))
393 : jhr 82 end
394 :     val (vds, env) = List.foldl checkStateVar ([], env) state
395 :     in
396 :     (List.rev vds, env)
397 :     end
398 :     (* check the actor methods *)
399 :     val methods = List.map (fn m => checkMethod (env, cxt, m)) methods
400 :     in
401 :     AST.D_Actor{name = name, params = params, state = vds, methods = methods}
402 :     end
403 :    
404 : jhr 89 fun checkCreate (env, cxt, PT.C_Mark m) = checkCreate (withEnvAndContext (env, cxt, m))
405 :     | checkCreate (env, cxt, PT.C_Create(actor, args)) = let
406 : jhr 169 val (args, tys) = checkLocalExprList (env, cxt, args)
407 : jhr 89 in
408 :     (* FIXME: check against actor definition *)
409 :     AST.C_Create(actor, args)
410 :     end
411 :    
412 :     fun checkIter (env, cxt, PT.I_Mark m) = checkIter (withEnvAndContext (env, cxt, m))
413 :     | checkIter (env, cxt, PT.I_Range(x, e1, e2)) = let
414 : jhr 169 val (e1', ty1) = checkLocalExpr (env, cxt, e1)
415 :     val (e2', ty2) = checkLocalExpr (env, cxt, e2)
416 : jhr 89 val x' = Var.new(x, Var.LocalVar, Ty.T_Int)
417 :     val env' = Env.insertLocal(env, x, x')
418 :     in
419 :     case (ty1, ty2)
420 :     of (Ty.T_Int, Ty.T_Int) => (AST.I_Range(x', e1', e2'), env')
421 :     | _ => err(cxt, [
422 :     S "range expressions must have integer type\n",
423 :     S " but found: ", TY ty1, S " .. ", TY ty2, S "\n"
424 :     ])
425 :     (* end case *)
426 :     end
427 :    
428 :     fun checkIters (env, cxt, iters) = let
429 :     fun chk (env, [], iters) = (List.rev iters, env)
430 :     | chk (env, iter::rest, iters) = let
431 :     val (iter, env) = checkIter (env, cxt, iter)
432 :     in
433 :     chk (env, rest, iter::iters)
434 :     end
435 :     in
436 :     chk (env, iters, [])
437 :     end
438 :    
439 : jhr 71 fun checkDecl (env, cxt, d) = (case d
440 : jhr 86 of PT.D_Mark m => checkDecl (withEnvAndContext (env, cxt, m))
441 : jhr 72 | PT.D_Input(ty, x, optExp) => let
442 : jhr 71 val ty = checkTy(cxt, ty)
443 :     val x' = Var.new(x, Var.InputVar, ty)
444 :     val dcl = (case optExp
445 :     of NONE => AST.D_Input(x', NONE)
446 :     | SOME e => let
447 : jhr 169 val (e', ty') = checkGlobalExpr (env, cxt, e)
448 : jhr 71 in
449 : jhr 89 if U.matchType (ty, ty')
450 :     then AST.D_Input(x', SOME e')
451 :     else err(cxt, [
452 :     S "definition of ", V x', S " has wrong type\n",
453 :     S " expected: ", TY ty, S "\n",
454 :     S " but found: ", TY ty', S "\n"
455 :     ])
456 : jhr 71 end
457 :     (* end case *))
458 :     in
459 :     (dcl, Env.insertGlobal(env, x, x'))
460 :     end
461 : jhr 72 | PT.D_Var vd => let
462 : jhr 169 val (x, x', e') = checkVarDecl ({globalScope=true, env=env}, cxt, Var.GlobalVar, vd)
463 : jhr 72 in
464 : jhr 81 (AST.D_Var(AST.VD_Decl(x', e')), Env.insertGlobal(env, x, x'))
465 : jhr 72 end
466 : jhr 82 | PT.D_Actor arg => (checkActor(env, cxt, arg), env)
467 : jhr 89 | PT.D_InitialArray(create, iterators) => let
468 :     val (iterators, env') = checkIters (env, cxt, iterators)
469 :     val create = checkCreate (env', cxt, create)
470 :     in
471 :     (AST.D_InitialArray(create, iterators), env)
472 :     end
473 :     | PT.D_InitialCollection(create, iterators) => let
474 :     val (iterators, env') = checkIters (env, cxt, iterators)
475 :     val create = checkCreate (env', cxt, create)
476 :     in
477 :     (AST.D_InitialCollection(create, iterators), env)
478 :     end
479 : jhr 70 (* end case *))
480 :    
481 : jhr 86 fun check errStrm (PT.Program{span, tree}) = let
482 :     val cxt = (errStrm, span)
483 : jhr 81 fun chk (env, [], dcls') = AST.Program(List.rev dcls')
484 :     | chk (env, dcl::dcls, dcls') = let
485 : jhr 86 val (dcl', env) = checkDecl (env, cxt, dcl)
486 : jhr 81 in
487 :     chk (env, dcls, dcl'::dcls')
488 :     end
489 :     in
490 :     chk (Basis.env, tree, [])
491 :     end
492 : jhr 70
493 : jhr 69 end

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