-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTypeChecker.hs
More file actions
22 lines (17 loc) · 852 Bytes
/
TypeChecker.hs
File metadata and controls
22 lines (17 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module TypeChecker where
import Text.Megaparsec.Pos
import Types
import ErrorWarTypes
import Errors
import Warnings
----------------------------------------------------------------------------------------------------------------------------------
checker :: (TypeDef,TypeDic, Prog) -> Report
checker (typsdef, typdec, prolog ) = R (errors typsdef typdec prolog ) (warnings prolog typdec typsdef )
-- combine errors
errors :: TypeDef -> TypeDic -> Prog -> Maybe [Err]
errors f d p = let empty = [] in combineTwoMaybe ( multConErr f, combineTwoMaybe (unknowType d f , combineTwoMaybe (duplicateDef f ,combineTwoMaybe (duplicateDec d, typeErrs p d f))))
-- combine warnings
warnings:: Prog -> TypeDic -> TypeDef -> Maybe [War]
warnings p d f = case nonDecWarning p d f of
Nothing -> Nothing
Just x -> conflict x x