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 (v is used for values, e for expressions, s for statements, c is the context)
19 [Eq, NEq, Plus, Minus, Times, Div, Lt, ELt, Gt, EGt]
21 <e1 o e2,c> => <v,c''> <= <e1,c> => <v1,c'> <e2,c'> => <v2,c''> v is the result of using operator o on v1 and v2
26 <i := e,c> => c'[i -> v] <= <e,c> => <v,c'>
28 Assign the value v to i in the first scope i is found in.
32 <e,c> => <-v,c'> <= <e,c> => <v,c'>
37 <e,c> => <not v,c'> <= <e,c> => <v,c'>
53 <c> => <v,c'> <= <IO,c> => <v,c'>
57 <i,c> => <v,c[i->v']> <= c(i) => v, v±1 => v'
59 Look up the variable, add/subtract 1 from the value then return the old value and context with modified value
63 <e,c> => c' <= <e,c> => <v,c'>
67 <SBlock s,c> => c''' <= push(c) => c' <s,c'> => c'' pop(c'') => c'''
69 Push a new scope onto the context, execute the statements in this context and the pop the scope from the context
73 <s1;s2,c> => c'' <= <s1,c> => c' <s2,c'> => c''
77 <if e s1 s2,c> => pop(c''') <= <e,c> => <true,c'> push(c') <s1,c''> => c'''
79 <if e s1 s2,c> => pop(c''') <= <e,c> => <false,c'> push(c') <s2,c''> => c'''
84 <while e s,c> => c' => <e,c> => <false,c'>
86 <while e s,c> => pop(c''') => <e,c> => <true,c'> push(c') => c'' <s,c''> => c'''
91 <i := e,c> => c'[i->v] <= <e,c> => <v,c'>
93 Adds i with value v to the current scope in the context
98 <bool i,c> => c[i->false]
100 Adds i with default value in the current scope
106 SNoops does nothing so the same context is returned
110 <e,c> => c'' <= <e,c> => <v,c'> <IO v,c'> => c''