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

SaplStruct.dcl 1.45 KB
Newer Older
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 34
definition module Sapl.SaplStruct

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

/**
* Possible function types and language constructs.
*/
:: FuncType = FTRecord SaplVar [SaplVar]
			| FTADT SaplVar [SaplConstructor]
			| FTCAF SaplVar SaplTerm
			| FTMacro SaplVar SaplTerm [SaplVar]
			| FTFunc SaplVar SaplTerm [SaplVar]

:: SaplConstructor 	= SaplConstructor SaplVar Int [SaplVar]

:: SaplTerm = SLit Literal
			| SVar SaplVar
			| SApplication SaplVar [SaplTerm]
			| SIf SaplTerm SaplTerm SaplTerm
			| SSelect SaplTerm [(SaplPattern, SaplTerm)]
			| SLet SaplTerm [SaplLetDef]
			| SAbortBody			

:: SaplLetDef = SaplLetDef SaplVar SaplTerm

:: SaplVar = NormalVar String Int 
		   | StrictVar String Int

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

35 36 37 38 39 40 41
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
42 43 44 45 46 47 48 49 50 51 52 53

eqStrictVar :: !String !SaplVar -> Bool
isStrictVar :: !SaplVar -> Bool
toNormalVar :: !SaplVar -> SaplVar
toStrictVar :: !SaplVar -> SaplVar

unpackVar      :: !SaplVar -> String
unpackBindVar  :: !SaplLetDef -> SaplVar
unpackConsName :: !SaplPattern -> Maybe String

isConsPattern :: !SaplPattern -> Bool