]> ruin.nu Git - proglang.git/blob - documentation
updating documentation
[proglang.git] / documentation
1 ####### DOCUMENTATIATOIAITAT ION ########
2
3 Usage:
4
5 ./CompInt [-c] [file]
6
7 -c : Compile [file], interprets if it isn't specified
8
9 if no arguments are specified then the file is interpreted
10
11 Files:
12 Interpret.hs: Handles the interpretation of a program
13
14 Compile.hs: Compiles the program into a c program
15
16 Typechecker.hs: Simple modification of the bnfc-generated Testsyntax which calls the type-checking functions.
17
18 Typecheck.hs: Contains the type-checking functions typeCheckExp, typeCheckVar and typeCheckStm and some utility functions, responsible for the entire type-checking process.
19
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.
21
22
23 Additions which comes from the extension:
24
25 typing rules
26 ++++++++++++
27
28 [EFunc]
29
30 (t is used for types, T is the context, and + is used for in)
31
32 T+ i (es) : t <= i(ts):t in T & T+ es:ts 
33
34 The functioncall of i returns t if i is in the context with returntype t and the types of the argument expressions matches those in the parameter list
35
36 [SReturn]
37
38 T+ return e <= e:t & ret(t) in T
39
40 return typechecks if e returns the same type as the current context
41
42 [Func]
43
44 T+ t i (ds) ss <= T,novariables,ret(t),ds => T' & T'+ss & last(ss) => return:t
45
46 the function i typechecks if the body typechecks in the context where all other variables has been removed and the return type and paramters has been added and that the last statement is a return with the right type
47
48 semantic rules
49 ++++++++++++
50
51
52 (v is used for values, e for expressions, s for statements, c is the context)
53
54
55