Flavour.dcl 1.58 KB
Newer Older
1
definition module Sapl.Target.Flavour
2

3
import Sapl.SaplParser, Text.StringAppender
Jurriën Stutterheim's avatar
Jurriën Stutterheim committed
4
from Data.Map import :: Map (..)
5
from Data.Set import :: Set
6 7 8 9 10 11 12

:: Arity :== Int

/**
* Describes a function which generates code from an AST using a specific strategy.
* (normal, force, ...)
*/
13
:: TermCoderFun :== SaplTerm StringAppender -> StringAppender
14 15 16

/**
* Describes a function which generates inline code using the elements of its
17 18
* third argument as the arguments of the inline function. The two TermCoderFun are the normal one (first)
* and a the one which forces the evaluation (brings it to HNF) of the given term.
19
*/
20
:: InlineCoderFun :== TermCoderFun TermCoderFun [SaplTerm] StringAppender -> StringAppender
21 22

:: InlineFunDef = 
23 24 25 26
		{ fun		 :: !InlineCoderFun
		, arity		 :: !Arity
		, strictness :: !{#Char}	// '1','0'		
		, data_cons  :: !Bool
27
		}
28 29 30

:: Flavour = { fun_prefix       :: String

31 32 33
			 // Optional flags to tune the compiler
			 , options			:: Set String

34 35 36 37 38 39 40 41 42 43
			 /**
			 * Returns a map of function names which are built-in. For every such function
			 * a implementation specific name and its arity is provided.
			 */
		     , builtInFunctions :: Map String (String, Arity)
		     
			 /**
			 * Returns a map of function names which are built-in and can be inlined. For every such function
			 * a generator function, the arity of the built-in functions and strictness information is provided.
			 */		     		     
44
		     , inlineFunctions  :: Map String InlineFunDef
45 46 47
			 }
         
toFlavour :: !String -> Maybe Flavour
48 49 50 51 52

// Check if a given flag is set or not in the flavour file
isSet :: !Flavour !String -> Bool