]> ruin.nu Git - proglang.git/blob - documentation
typing rules in documentation
[proglang.git] / documentation
1 ####### DOCUMENTATIATOIAITAT ION ########
2
3
4 a simple c-like language with support for if/else-statements, while-loops and the standard arithmetic (+, -, /, *) and comparison expressions (<, >, <=, >=, ==, !=). also, post increase/decrease expressions (++, --) are supported. Assignments are allowed in expressions, but they are only allowed on the right side of arithmetic/comparision operators if they are put inside parenthesis
5
6
7 data types:
8 integers and booleans.
9
10 comments:
11 // and /* */ comments are allowed.
12
13 (For compilation to work the Bool type in Abssyntax has to be removed so the internal haskell type is used)
14
15 shift/reduce conflicts:
16
17 if with else: 1 conflict
18 An if statement before the else could be reduced to an if statement lacking the else, but the correct thing is to shift it onto the stack.
19
20
21
22
23 typing rules
24 ++++++++++++
25
26
27 (t is little tau, T is large tau, E is 'in', and + is that other symbol)
28
29
30
31 [Eq, Neq]
32
33 e:bool  <=  e1:t  &  e2:t
34 where e is e1 Eq e2.
35
36
37 [Plus, Minus, Times, Div]
38
39 e:int  <=  e1:int  &  e2:int
40 where e is e1 Plus e2.
41
42
43 [Lt, ELt, Gt, EGt]
44
45 e:bool  <=  e1:int  &  e2:int
46 where e is e1 Lt e2.
47
48
49 [Assignment]
50
51 T+ i := e:t  <=  i:t E T  &  T+ e:t
52 where the assignment is identifier i = expression e.
53
54
55 [ExpT]
56
57 u,e:t  <=  e:t  &  u:t
58 where the expression is type u expression e.
59
60
61 [ENeg]
62
63 e:int  <=  e:int
64
65
66 [ENot]
67
68 e:bool  <=  e:bool
69
70
71 [SExp, SBlock]
72
73 S:NoType  <=  e:t
74
75
76 [SIf]
77
78 T+ if e then s1 else s2  <=  T+ e:bool  &  T+ s1  &  T+ s2
79
80
81 [SWhile]
82
83 T+ while e do s  <=  T+ e:bool  &  T+ s
84
85
86 [SDecl]
87
88 T+ i:t => T', i:t  <=  i!ET  &  e:t  &  u:t
89
90 (Type u Ident i = Exp e)
91
92
93
94
95
96
97