1 ####### DOCUMENTATIATOIAITAT ION ########
7 -c : Compile [file], interprets if it isn't specified
9 if no arguments are specified then the file is interpreted
12 Interpret.hs: Handles the interpretation of a program
14 Compile.hs: Compiles the program into a c program
16 Typechecker.hs: Simple modification of the bnfc-generated Testsyntax which calls the type-checking functions.
18 Typecheck.hs: Contains the type-checking functions typeCheckExp, typeCheckVar and typeCheckStm and some utility functions, responsible for the entire type-checking process.
20 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.
27 (v is used for values, e for expressions, s for statements, c is the context)
30 [Eq, NEq, Plus, Minus, Times, Div, Lt, ELt, Gt, EGt]
32 <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
37 <i := e,c> => c'[i -> v] <= <e,c> => <v,c'>
39 Assign the value v to i in the first scope i is found in.
43 <e,c> => <-v,c'> <= <e,c> => <v,c'>
48 <e,c> => <not v,c'> <= <e,c> => <v,c'>
64 <c> => <v,c'> <= <IO,c> => <v,c'>
68 <i,c> => <v,c[i->v']> <= c(i) => v, v±1 => v'
70 Look up the variable, add/subtract 1 from the value then return the old value and context with modified value
74 <e,c> => c' <= <e,c> => <v,c'>
78 <SBlock s,c> => c''' <= push(c) => c' <s,c'> => c'' pop(c'') => c'''
80 Push a new scope onto the context, execute the statements in this context and the pop the scope from the context
84 <s1;s2,c> => c'' <= <s1,c> => c' <s2,c'> => c''
88 <if e s1 s2,c> => pop(c''') <= <e,c> => <true,c'> push(c') <s1,c''> => c'''
90 <if e s1 s2,c> => pop(c''') <= <e,c> => <false,c'> push(c') <s2,c''> => c'''
95 <while e s,c> => c' => <e,c> => <false,c'>
97 <while e s,c> => pop(c''') => <e,c> => <true,c'> push(c') => c'' <s,c''> => c'''
102 <i := e,c> => c'[i->v] <= <e,c> => <v,c'>
104 Adds i with value v to the current scope in the context
109 <bool i,c> => c[i->false]
111 Adds i with default value in the current scope
117 SNoops does nothing so the same context is returned
121 <e,c> => c'' <= <e,c> => <v,c'> <IO v,c'> => c''