AS_BASIC_CSL.hs revision e9458b1a7a19a63aa4c179f9ab20f4d50681c168
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay{-# LANGUAGE TypeSynonymInstances, FlexibleInstances, DeriveDataTypeable #-}
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemayDescription : Abstract syntax for EnCL
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemayCopyright : (c) Dominik Dietrich, Ewaryst Schulz, DFKI Bremen 2010
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemayLicense : GPLv2 or higher, see LICENSE.txt
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemayMaintainer : Ewaryst.Schulz@dfki.de
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemayStability : experimental
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemayPortability : portable
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemayThis module contains the abstract syntax types for EnCL as well as the
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemaypredefined operator configuration.
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay ( EXPRESSION (..) {- datatype for numerical expressions
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay (e.g. polynomials) -}
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , EXTPARAM (..) -- datatype for extended parameters (e.g. [I=0])
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , BASIC_ITEM (..) -- Items of a Basic Spec
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , BASIC_SPEC (..) -- Basic Spec
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , SYMB_ITEMS (..) -- List of symbols
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , SYMB (..) -- Symbols
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , SYMB_MAP_ITEMS (..) -- Symbol map
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , SYMB_OR_MAP (..) -- Symbol or symbol map
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , OPNAME (..) -- predefined operator names
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , OPID (..) -- identifier for operators
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , ConstantName (..) -- names of user-defined constants
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , OP_ITEM (..) -- operator declaration
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , VAR_ITEM (..) -- variable declaration
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , VarDecl (..) -- variable declaration in assignment
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , OpDecl (..) -- operator declaration in assignment
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , EPDecl (..) -- extparam declaration
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , EPVal (..) -- extparam values
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , getEPVarRef
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , Domain -- domains for variable declarations
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , EPDomain -- domains for extended parameter declarations
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , GroundConstant (..) -- constants for domain formation
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , cmpFloatToInt -- comparer for APFloat with APInt
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , AssDefinition (..) -- A function or constant definition
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , InstantiatedConstant (..) {- for function constants we need to store the
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay instantiation -}
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , CMD (..) -- Command datatype
35a0c21a3150b1c01572f6075d6240eebd301415Jason Lemay , OperatorState (..) -- Class providing operator lookup
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , OpInfo (..) -- Type for Operator information
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , BindInfo (..) -- Type for Binder information
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , operatorInfo {- Operator information for pretty printing
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay and static analysis -}
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , operatorInfoMap -- allows efficient lookup of ops by printname
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , operatorInfoNameMap -- allows efficient lookup of ops by opname
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , operatorBindInfoMap
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , mergeOpArityMap -- for combining two operator arity maps
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , getOpInfoMap
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , getOpInfoNameMap
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay , getBindInfoMap
import Common.Id as Id
import Common.AS_Annotation as AS_Anno
import Data.Data
import qualified Data.Map as Map
import Data.Ratio
import CSL.TreePO
newtype BASIC_SPEC = Basic_spec [AS_Anno.Annoted BASIC_ITEM]
| EP_decl [(Id.Token, EPDomain)]
| EP_domdecl [(Id.Token, APInt)]
| EP_defval [(Id.Token, APInt)]
| Axiom_item (AS_Anno.Annoted CMD)
data EXTPARAM = EP Id.Token String APInt
data EPDecl = EPDecl Id.Token -- name
data EPVal = EPVal APInt | EPConstRef Id.Token
getEPVarRef :: EPVal -> Maybe Id.Token
Var Id.Token
| Op OPID [EXTPARAM] [EXPRESSION] Id.Range
| List [EXPRESSION] Id.Range
| Interval Double Double Id.Range
| Int APInt Id.Range
| Rat APFloat Id.Range
data VarDecl = VarDecl Id.Token (Maybe Domain)
data OpDecl = OpDecl ConstantName [EXTPARAM] [VarDecl] Id.Range
data SYMB_ITEMS = Symb_items [SYMB] Id.Range
newtype SYMB = Symb_id Id.Token
data SYMB_MAP_ITEMS = Symb_map_items [SYMB_OR_MAP] Id.Range
| Symb_map SYMB SYMB Id.Range
Predefined Operators: info for parsing/printing and static analysis
type ArityMap = Map.Map Int OpInfo
type OpInfoArityMap a = Map.Map a ArityMap
type BindInfoMap = Map.Map String OpInfo
getOpInfoMap pf = foldl f Map.empty
(Map.fromList [(arity oi, oi)]) m
getOpInfoNameMap = foldl f Map.empty
(Map.fromList [(arity oi, oi)]) m
getBindInfoMap = foldl f Map.empty
Map.insertWith cf (show $ opname oi) oi m
lookupBinder _ = flip Map.lookup operatorBindInfoMap
lookupBinder = flip Map.lookup . snd
case Map.lookup op oiMap of
case Map.lookup arit oim of
case Map.lookup (-1) oim of
case Map.lookup op oinm of
case Map.lookup arit oim of
case Map.lookup (-1) oim of
case Map.lookup op oinm of
case Map.lookup arit oim of