SaplStruct.dcl 2.08 KB
Newer Older
1 2 3 4 5 6 7 8 9
definition module Sapl.SaplStruct

import StdString, StdOverloaded
import Sapl.SaplTokenizer
import Data.Maybe

/**
* Possible function types and language constructs.
*/
10
:: FuncType = FTRecord SaplVar [SaplTypedVar]
11
			| FTADT SaplVar [SaplConstructor]
12 13 14
			| FTCAF SaplTypedVar SaplTerm
			| FTMacro SaplTypedVar SaplTerm [SaplTypedVar]
			| FTFunc SaplTypedVar SaplTerm [SaplTypedVar]
15

16
:: SaplConstructor 	= SaplConstructor SaplVar Int [SaplTypedVar]
17 18 19

:: SaplTerm = SLit Literal
			| SVar SaplVar
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
20 21
			| SApplication SaplTerm [SaplTerm]
			| SCase SaplTerm [(SaplPattern, SaplTerm)]
22
			| SLet SaplTerm [SaplLetDef]
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
23
			| SSelect SaplTerm Int
24 25
			| SAbortBody			

26
:: SaplLetDef = SaplLetDef SaplTypedVar SaplTerm
27

28 29 30 31 32 33
:: SaplName :== String

:: SaplVar = NormalVar SaplName Int 
		   | StrictVar SaplName Int

:: SaplTypedVar = TypedVar SaplVar SaplType
34 35 36 37 38

:: SaplPattern = PCons String [SaplVar]
			   | PLit Literal
			   | PDefault

39 40
:: SaplType = Type String | NoType

41 42 43 44 45 46 47
instance toString SaplVar

// I don't provide instances of (==) and (<) here because multiple good way can be imagined...
eqVarByName :: !SaplVar !SaplVar -> Bool
ltVarByName :: !SaplVar !SaplVar -> Bool
eqVarByNameLevel :: !SaplVar !SaplVar -> Bool
ltVarByNameLevel :: !SaplVar !SaplVar -> Bool
48

49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
removeTypeInfo :: !SaplTypedVar -> SaplVar

class eqStrictVar v :: !String !v -> Bool
class isStrictVar v :: !v -> Bool
class toNormalVar v :: !v -> v
class toStrictVar v :: !v -> v
class unpackVar v :: !v -> String

instance eqStrictVar SaplVar
instance eqStrictVar SaplTypedVar
instance isStrictVar SaplVar
instance isStrictVar SaplTypedVar
instance toNormalVar SaplVar
instance toNormalVar SaplTypedVar
instance toStrictVar SaplVar
instance toStrictVar SaplTypedVar
instance unpackVar SaplVar
instance unpackVar SaplTypedVar
67

68
unpackBindVar  :: !SaplLetDef -> SaplTypedVar
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
69
unpackBindExpr :: !SaplLetDef -> SaplTerm
70
unpackConsName :: !SaplPattern -> Maybe String
71
toStrictBind   :: !SaplLetDef -> SaplLetDef
72

73 74
isConsPattern    :: !SaplPattern -> Bool
isDefaultPattern :: !SaplPattern -> Bool
75