AsToLe.hs revision eca4db63ed0bdbd93b62678feea6e3eb80aa47bb
8b054cade993ef373d564b2d74c9c5a2da48f8b7Kristina SojakovaModule : $Header$
097b7fb3f8f90e87120d30bf37a1d89fe0ddfaf0Kristina SojakovaCopyright : (c) Christian Maeder and Uni Bremen 2003-2005
097b7fb3f8f90e87120d30bf37a1d89fe0ddfaf0Kristina SojakovaLicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
8b054cade993ef373d564b2d74c9c5a2da48f8b7Kristina SojakovaMaintainer : maeder@tzi.de
8b054cade993ef373d564b2d74c9c5a2da48f8b7Kristina SojakovaStability : experimental
8b054cade993ef373d564b2d74c9c5a2da48f8b7Kristina SojakovaPortability : portable
8b054cade993ef373d564b2d74c9c5a2da48f8b7Kristina Sojakovaconversion from As to Le
51bbd37b3957f301b2628422e161aac2cbd46f1cKristina Sojakovaimport qualified Common.Lib.Rel as Rel
51bbd37b3957f301b2628422e161aac2cbd46f1cKristina Sojakovaimport qualified Common.Lib.Map as Map
8b054cade993ef373d564b2d74c9c5a2da48f8b7Kristina Sojakovaimport qualified Common.Lib.Set as Set
51bbd37b3957f301b2628422e161aac2cbd46f1cKristina Sojakova-- * extract predicate ids from As for mixfix analysis
8b054cade993ef373d564b2d74c9c5a2da48f8b7Kristina Sojakovaunite :: [Ids] -> Ids
81d28e8372831ae5e6054d8d2212f0114b09b79aKristina SojakovaidsOfBasicSpec :: BasicSpec -> Ids
81d28e8372831ae5e6054d8d2212f0114b09b79aKristina SojakovaidsOfBasicSpec (BasicSpec l) = unite $ map (idsOfBasicItem . item) l
81d28e8372831ae5e6054d8d2212f0114b09b79aKristina SojakovaidsOfBasicItem :: BasicItem -> Ids
81d28e8372831ae5e6054d8d2212f0114b09b79aKristina SojakovaidsOfBasicItem (SigItems i) = idsOfSigItems i
81d28e8372831ae5e6054d8d2212f0114b09b79aKristina SojakovaidsOfBasicItem (ClassItems _ l _ ) = unite $ map (idsOfClassItem . item) l
81d28e8372831ae5e6054d8d2212f0114b09b79aKristina SojakovaidsOfBasicItem (GenItems l _) = unite $ map (idsOfSigItems . item) l
51bbd37b3957f301b2628422e161aac2cbd46f1cKristina SojakovaidsOfBasicItem (Internal l _) = unite $ map (idsOfBasicItem . item) l
81d28e8372831ae5e6054d8d2212f0114b09b79aKristina SojakovaidsOfBasicItem _ = Set.empty
81d28e8372831ae5e6054d8d2212f0114b09b79aKristina SojakovaidsOfClassItem :: ClassItem -> Ids
81d28e8372831ae5e6054d8d2212f0114b09b79aKristina SojakovaidsOfClassItem (ClassItem _ l _) = unite $ map (idsOfBasicItem . item) l
81d28e8372831ae5e6054d8d2212f0114b09b79aKristina SojakovaidsOfSigItems :: SigItems -> Ids
51bbd37b3957f301b2628422e161aac2cbd46f1cKristina SojakovaidsOfSigItems (TypeItems _ _ _) = Set.empty
345d3dcc9f809776009851c446916fc770aa428dKristina SojakovaidsOfSigItems (OpItems b l _) = unite $ map (idsOfOpItem b . item) l
345d3dcc9f809776009851c446916fc770aa428dKristina SojakovaidsOfOpItem :: OpBrand -> OpItem -> Ids
345d3dcc9f809776009851c446916fc770aa428dKristina SojakovaidsOfOpItem b (OpDecl os _ _ _) =
345d3dcc9f809776009851c446916fc770aa428dKristina Sojakova let ois = Set.fromList $ map ( \ (OpId i _ _) -> i) os
345d3dcc9f809776009851c446916fc770aa428dKristina SojakovaidsOfOpItem b (OpDefn (OpId i _ _) _ _ _ _ _) =
8b054cade993ef373d564b2d74c9c5a2da48f8b7Kristina Sojakova-- * basic analysis
8b054cade993ef373d564b2d74c9c5a2da48f8b7Kristina Sojakova-- | basic analysis
8b054cade993ef373d564b2d74c9c5a2da48f8b7Kristina SojakovabasicAnalysis :: (BasicSpec, Env, GlobalAnnos) ->
51bbd37b3957f301b2628422e161aac2cbd46f1cKristina Sojakova Result (BasicSpec, Env, [Named Sentence])
51bbd37b3957f301b2628422e161aac2cbd46f1cKristina SojakovabasicAnalysis (b, e, ga) =
51bbd37b3957f301b2628422e161aac2cbd46f1cKristina Sojakova let (nb, ne) = runState (anaBasicSpec ga b) e
345d3dcc9f809776009851c446916fc770aa428dKristina Sojakova in Result (reverse $ envDiags ne) $
51bbd37b3957f301b2628422e161aac2cbd46f1cKristina Sojakova Just (nb, cleanEnv ne, reverse $ sentences ne)
51bbd37b3957f301b2628422e161aac2cbd46f1cKristina Sojakova-- | is the signature empty?
51bbd37b3957f301b2628422e161aac2cbd46f1cKristina SojakovaisEmptyEnv :: Env -> Bool
51bbd37b3957f301b2628422e161aac2cbd46f1cKristina SojakovaisEmptyEnv e = Map.null (classMap e)
&& Map.null (typeMap e)
&& Map.null (assumps e)
{ classMap = Map.differenceWith diffClass (classMap e1) (classMap e2)
, typeMap = Map.differenceWith diffType (typeMap e1) tm
, assumps = Map.differenceWith (diffAss $ addUnit tm)
rels = Set.union preds newPreds