1 ####### DOCUMENTATIATOIAITAT ION ########
5 Typechecker.hs: Simple modification of the bnfc-generated Testsyntax which calls the type-checking functions.
7 Typecheck.hs: Contains the type-checking functions typeCheckExp, typeCheckVar and typeCheckStm and some utility functions, responsible for the entire type-checking process.
9 Abssyntax.hs, Parsyntax.y, Lexsyntax.x,ErrM.hs,Printsyntax.hs,Skelsyntax.hs: The files generated by bnfc, only modification is the removal of the Bool type in Abssyntx.hs so haskell's internal type can be used.
16 (t is little tau, T is large tau, E is 'in', and + is that other symbol)
21 T+ e1 Eq e2:bool <= T+ e1:t & T+ e2:t
23 If e1 and e2 are of the same type, then Eq or NEq return bool
26 [Plus, Minus, Times, Div]
28 T+ e1 Plus e2:int <= T+ e1:int & T+ e2:int
30 The operators Plus/Minus/Times/Div return int if both operands are ints
35 T+ e1 Lt e2:bool <= T+ e1:int & T+ e2:int
37 The operators Lt/ELt/Gt/EGt return bool if both operands are ints
42 T+ i := e:t <= i:t E T & T+ e:t
44 The assignemnt of e to i returns type t if both i and e have type t.
49 T+ ENeg e:int <= T+ e:int
51 ENeg e returns int if e is of type int
55 T+ ENot e:bool <= e:bool
57 ENot e returns bool if e is of type bool
63 i has type t if i is defined in the context with type t.
91 T+ EPost i:int <= i:int E T
93 EPost i is of type int if i is defined in T with type int.
101 T+ s;SBlock ss <= T+ s => T' , T'+ ss => T''
103 the first statment s, in the block, is typechecked in the context T and returns the context T', the rest of the block is then recursively typeckecked in the context T'
108 T+ if e then s1 else s2 <= T+ e:bool & T+ s1 & T+ s2
110 if e is of type bool and s1 and and s2 typechecks in the context T, then the same context is returned
115 T+ while e do s <= T+ e:bool & T+ s
117 If e is of type bool and s typechecks in context T then the same context is returned
123 T+ t i = e => T,i:t <= i!ET & e:t
125 if i and e are of the same type and i is not declared in the current scope then i is added with type t to the context.
129 T+ t i => T,i:t <= i!ET
131 if i is not declared in the current scope, then i is added to the context with type t
137 SNoops does nothing so the same context is returned
143 if e has type t then SPrint returns the same context