repositories
/
cc1516.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a363f87
)
add type of vardecl expr to gamma
author
Mart Lubbers
<mart@martlubbers.net>
Sun, 10 Apr 2016 19:37:58 +0000
(21:37 +0200)
committer
Mart Lubbers
<mart@martlubbers.net>
Sun, 10 Apr 2016 19:37:58 +0000
(21:37 +0200)
sem.icl
patch
|
blob
|
history
diff --git
a/sem.icl
b/sem.icl
index
7132135
..
1a2ed00
100644
(file)
--- a/
sem.icl
+++ b/
sem.icl
@@
-61,21
+61,19
@@
semFunDecl f = pure $ Right f
semVarDecl :: VarDecl -> Env VarDecl
semVarDecl vd=:(VarDecl pos type ident ex) = unify type ex
semVarDecl :: VarDecl -> Env VarDecl
semVarDecl vd=:(VarDecl pos type ident ex) = unify type ex
- >>= \et->pure (
- et >>= \t->pure $ VarDecl pos t ident ex)
+ >>= \et->case et of
+ Left err = pure $ Left err
+ Right t = putIdent ident t >>| pure (Right $ VarDecl pos t ident ex)
//Right v
// //TODO ident in de environment
// Right e = Right $ pure vd
//Right v
// //TODO ident in de environment
// Right e = Right $ pure vd
-typeOp1 :: Pos Expr Type -> Env Type
-typeOp1 p expr rtype = unify rtype expr
-
typeExpr :: Expr -> Env Type
typeExpr (IntExpr _ _) = pure $ Right IntType
typeExpr (CharExpr _ _) = pure $ Right CharType
typeExpr (BoolExpr _ _) = pure $ Right BoolType
typeExpr :: Expr -> Env Type
typeExpr (IntExpr _ _) = pure $ Right IntType
typeExpr (CharExpr _ _) = pure $ Right CharType
typeExpr (BoolExpr _ _) = pure $ Right BoolType
-typeExpr (Op1Expr p UnNegation expr) =
typeOp1 p expr BoolType
-typeExpr (Op1Expr p UnMinus expr) =
typeOp1 p expr IntType
+typeExpr (Op1Expr p UnNegation expr) =
unify BoolType expr
+typeExpr (Op1Expr p UnMinus expr) =
unify IntType expr
typeExpr (TupleExpr p (e1, e2)) = typeExpr e1
>>= \ete1->typeExpr e2 >>= \ete2->pure (
ete1 >>= \te1->ete2 >>= \te2->Right $ TupleType (te1, te2))
typeExpr (TupleExpr p (e1, e2)) = typeExpr e1
>>= \ete1->typeExpr e2 >>= \ete2->pure (
ete1 >>= \te1->ete2 >>= \te2->Right $ TupleType (te1, te2))