]> ruin.nu Git - proglang.git/commitdiff
typing rules in documentation
authorFredrik Möllerstrand <mollerst@itstud.chalmers.se>
Tue, 28 Feb 2006 21:01:44 +0000 (21:01 +0000)
committerFredrik Möllerstrand <mollerst@itstud.chalmers.se>
Tue, 28 Feb 2006 21:01:44 +0000 (21:01 +0000)
Typecheck.hs
documentation
syntax.cf

index 770c079e4bf73259e4a77d36cabc4aaccb310c1e..6f65d6e2f538d18d554787225c4aa138918a586f 100644 (file)
@@ -1,5 +1,6 @@
 module Typecheck (typeCheckExp, typeCheckStm, typeCheckVar) where 
 
 module Typecheck (typeCheckExp, typeCheckStm, typeCheckVar) where 
 
+
 import Abssyntax
 import Control.Monad.State
 import Data.Map as Map
 import Abssyntax
 import Control.Monad.State
 import Data.Map as Map
index 28be8953c583ac46e7fc73b3998982312167a67d..70bd0c818b7f8c298ca3658a67729c6413db122b 100644 (file)
@@ -16,3 +16,82 @@ 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.
 
 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]
+
+S:NoType  <=  e:t
+
+
+[SIf]
+
+T+ if e then s1 else s2  <=  T+ e:bool  &  T+ s1  &  T+ s2
+
+
+[SWhile]
+
+T+ while e do s  <=  T+ e:bool  &  T+ s
+
+
+[SDecl]
+
+T+ i:t => T', i:t  <=  i!ET  &  e:t  &  u:t
+
+(Type u Ident i = Exp e)
+
+
+
+
+
+
+
index de173e86a1fc5cd4f98b837cdd8b3622478bf0b2..d09a25c33849d524632a0b352994da59b2cf60b6 100644 (file)
--- a/syntax.cf
+++ b/syntax.cf
@@ -63,7 +63,7 @@ _. Op ::= Op0;
 
 
 
 
 
 
-TInt.     Type  ::= "int" ;
+TInt.   Type  ::= "int" ;
 TBool.  Type  ::= "bool" ;
 
 -- pragmas
 TBool.  Type  ::= "bool" ;
 
 -- pragmas