####### DOCUMENTATIATOIAITAT ION ########
+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
-a simple c-like language with support for if/else-statements, while-loops and the standard arithmetic (+, -, /, *) and comparison expressions (<, >, <=, >=, ==, !=). also, increase/decrease expressions (++, --) are supported.
-
data types:
integers and booleans.
comments:
// and /* */ comments are allowed.
+(For compilation to work the Bool type in Abssyntax has to be removed so the internal haskell type is used)
+
+shift/reduce conflicts:
+
+if with else: 1 conflict
+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.
+
+
+
+
+typing rules
+++++++++++++
+
+
+(t is little tau, T is large tau, E is 'in', and + is that other symbol)
+
+
+
+[Eq, Neq]
+
+e:bool <= e1:t & e2:t
+where e is e1 Eq e2.
+
+
+[Plus, Minus, Times, Div]
+
+e:int <= e1:int & e2:int
+where e is e1 Plus e2.
+
+
+[Lt, ELt, Gt, EGt]
+
+e:bool <= e1:int & e2:int
+where e is e1 Lt e2.
+
+
+[Assignment]
+
+T+ i := e:t <= i:t E T & T+ e:t
+where the assignment is identifier i = expression e.
+[ExpT]
+u,e:t <= e:t & u:t
+where the expression is type u expression e.
+[ENeg]
+e:int <= e:int
+[ENot]
+e:bool <= e:bool
+[SExp, SBlock]
-examples:
+S:NoType <= e:t
-fib
----
-int n1 = 0;
-int n2 = 1;
-int n = readInt;
-while(n-- > 0){
- int temp = n1+n2;
- n1 = n2;
- n2 = temp;
-}
-print n2;
+[SIf]
+T+ if e then s1 else s2 <= T+ e:bool & T+ s1 & T+ s2
-tests while, decr and assignment.
+[SWhile]
+T+ while e do s <= T+ e:bool & T+ s
-if
---
-if (readBool) {
- if (readInt < 0)
- print true;
- else
- print false;
-}
+[SDecl]
-tests if and if/else.
+T+ i:t => T', i:t <= i!ET & e:t & u:t
+(Type u Ident i = Exp e)
-sum
----
-int n;
-int sum = 0;
-while ((n = readInt) != -1) sum = sum + n;
-print sum;
-var
----
-int a = 3;
-int b = a - 5;
-int c = a + b*7;
-bool d = a == b;
-tests simple variable operations.
\ No newline at end of file