checkStatement Statement FunDef ProcDef State Either Error Type checkS

1
2
3
4
5
6
7
checkStatement :: Statement -> [FunDef] -> [ProcDef] -> State -> Either Error Type
checkStatement (Assign varId expresion) funDef _ state | isLeft checkExp = checkExp
| maybeVar == Nothing = Left $ NotInState varId
| getTypeOf(maybeVar) /= getTypeExpOf(checkExp) = Left ( Mismatch (getTypeOf(maybeVar)) (getTypeExpOf(checkExp)) (show (Assign varId expresion)))
| otherwise = Right (getTypeOf(maybeVar))
where maybeVar = lookup varId state
checkExp = checkExpresion expresion funDef state