-
Notifications
You must be signed in to change notification settings - Fork 1
/
StaticCheckTypes.hs
33 lines (27 loc) · 926 Bytes
/
StaticCheckTypes.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
module StaticCheckTypes where
import AbsXYZgrammar
import Data.Map as Map
import Data.Maybe
import Control.Monad.Reader
import Control.Monad.Except
data StaticCheckMemory =
Var Type
| GenVar Type -- return types
| Func (Type, [Type]) -- return type, arg types
| Gen (Type, [Type])
type StaticCheckEnv = Map String StaticCheckMemory
type ExtendedEnv = (StaticCheckEnv, Type, Bool) -- Bool - isFunction
type StaticCheckMonad = ReaderT ExtendedEnv (ExceptT StaticCheckException IO)
data StaticCheckException =
WrongTypeException String
| UndefinedException String
| FunctionHasNotValueException
| CanNotMakeVariableApplicationException
| WrongArgsCountException String
| ReturnNotInFunctionException
| YieldNotInGeneratorException
| GeneratorHasNotValueException
| GeneratorVarHasNotValueException
| NextNotOnGeneratorException
| ForGenOnlyOverGeneratorException
| VoidVariableException