####### DOCUMENTATIATOIAITAT ION ######## Files: Typechecker.hs: Simple modification of the bnfc-generated Testsyntax which calls the type-checking functions. Typecheck.hs: Contains the type-checking functions typeCheckExp, typeCheckVar and typeCheckStm and some utility functions, responsible for the entire type-checking process. 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. typing rules ++++++++++++ (v is used for values, e for expressions, s for statements, c is the context) [Eq, NEq, Plus, Minus, Times, Div, Lt, ELt, Gt, EGt] => <= => => v is the result of using operator o on v1 and v2 [Assignment] => c'[i -> v] <= => Assign the value v to i in the first scope i is found in. [ENeg] => <-v,c'> <= => [ENot] => <= => [EVar] => [EInt] => [EBool] => [EReadI,EReadB] => <= => [EPost] => v']> <= c(i) => v, v±1 => v' Look up the variable, add/subtract 1 from the value then return the old value and context with modified value [SExp] => c' <= => [SBlock] => c''' <= push(c) => c' => c'' pop(c'') => c''' Push a new scope onto the context, execute the statements in this context and the pop the scope from the context [SEQ] => c'' <= => c' => c'' [SIf] => pop(c''') <= => push(c') => c''' => pop(c''') <= => push(c') => c''' [SWhile] => c' => => => pop(c''') => => push(c') => c'' => c''' [SDecl] => c'[i->v] <= => Adds i with value v to the current scope in the context [SDeclD] => c[i->0] => c[i->false] Adds i with default value in the current scope [SNoop] => c SNoops does nothing so the same context is returned [SPrint] => c'' <= => => c''