]> ruin.nu Git - proglang.git/blob - documentation
YEAH
[proglang.git] / documentation
1 ####### DOCUMENTATIATOIAITAT ION ########
2
3
4 Files:
5 Typechecker.hs: Simple modification of the bnfc-generated Testsyntax which calls the type-checking functions.
6
7 Typecheck.hs: Contains the type-checking functions typeCheckExp, typeCheckVar and typeCheckStm and some utility functions, responsible for the entire type-checking process.
8
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.
10
11
12 typing rules
13 ++++++++++++
14
15
16 (t is little tau, T is large tau, E is 'in', and + is that other symbol)
17
18
19 [Eq, Neq]
20
21 e:bool  <=  e1:t  &  e2:t
22 where e is e1 Eq e2.
23
24
25 [Plus, Minus, Times, Div]
26
27 e:int  <=  e1:int  &  e2:int
28 where e is e1 Plus e2.
29
30
31 [Lt, ELt, Gt, EGt]
32
33 e:bool  <=  e1:int  &  e2:int
34 where e is e1 Lt e2.
35
36
37 [Assignment]
38
39 T+ i := e:t  <=  i:t E T  &  T+ e:t
40 where the assignment is identifier i = expression e.
41
42
43 [ExpT]
44
45 u,e:t  <=  e:t  &  u:t
46 where the expression is type u expression e.
47
48
49 [ENeg]
50
51 e:int  <=  e:int
52
53
54 [ENot]
55
56 e:bool  <=  e:bool
57
58
59 [SExp, SBlock]
60
61 S:NoType  <=  e:t
62
63
64 [SIf]
65
66 T+ if e then s1 else s2  <=  T+ e:bool  &  T+ s1  &  T+ s2
67
68
69 [SWhile]
70
71 T+ while e do s  <=  T+ e:bool  &  T+ s
72
73
74 [SDecl]
75
76 T+ i:t => T', i:t  <=  i!ET  &  e:t  &  u:t
77
78 (Type u Ident i = Exp e)
79
80
81
82
83
84
85