We planned to upgrade GitLab and Mattermost to the latest version this Friday morning. Expect some downtime!

SaplStruct.dcl 2.07 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 20 21

:: SaplTerm = SLit Literal
			| SVar SaplVar
			| SApplication SaplVar [SaplTerm]
			| SIf SaplTerm SaplTerm SaplTerm
22
			| SSelector SaplTerm
23 24 25 26
			| SSelect SaplTerm [(SaplPattern, SaplTerm)]
			| SLet SaplTerm [SaplLetDef]
			| SAbortBody			

27
:: SaplLetDef = SaplLetDef SaplTypedVar SaplTerm
28

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

:: SaplVar = NormalVar SaplName Int 
		   | StrictVar SaplName Int

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

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

40 41
:: SaplType = Type String | NoType

42 43 44 45 46 47 48
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
49

50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
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
68

69
unpackBindVar  :: !SaplLetDef -> SaplTypedVar
70
unpackConsName :: !SaplPattern -> Maybe String
71
toStrictBind   :: !SaplLetDef -> SaplLetDef
72

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