]> ruin.nu Git - proglang.git/blob - documentation
interpreter seems to work
[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
20 [Eq, Neq]
21
22 e:bool  <=  e1:t  &  e2:t
23 where e is e1 Eq e2.
24
25
26 [Plus, Minus, Times, Div]
27
28 e:int  <=  e1:int  &  e2:int
29 where e is e1 Plus e2.
30
31
32 [Lt, ELt, Gt, EGt]
33
34 e:bool  <=  e1:int  &  e2:int
35 where e is e1 Lt e2.
36
37
38 [Assignment]
39
40 T+ i := e:t  <=  i:t E T  &  T+ e:t
41 where the assignment is identifier i = expression e.
42
43
44 [ExpT]
45
46 u,e:t  <=  e:t  &  u:t
47 where the expression is type u expression e.
48
49
50 [ENeg]
51
52 e:int  <=  e:int
53
54
55 [ENot]
56
57 e:bool  <=  e:bool
58
59
60 [SExp, SBlock]
61
62 S:NoType  <=  e:t
63
64
65 [SIf]
66
67 T+ if e then s1 else s2  <=  T+ e:bool  &  T+ s1  &  T+ s2
68
69
70 [SWhile]
71
72 T+ while e do s  <=  T+ e:bool  &  T+ s
73
74
75 [SDecl]
76
77 T+ i:t => T', i:t  <=  i!ET  &  e:t  &  u:t
78
79 (Type u Ident i = Exp e)
80
81
82
83
84
85
86