LibName.hs revision 92dc581bf568c9e225aa9d0570ab0a4b6ebdab69
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshikiModule : $Header$
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshikiDescription : library names for HetCASL and development graphs
353bea4bd4f2d567232d91686f797810bc176f2etakashiCopyright : (c) Christian Maeder, DFKI GmbH 2008
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshikiLicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdndMaintainer : Christian.Maeder@dfki.de
031b91a62d25106ae69d4693475c79618dd5e884fieldingStability : provisional
031b91a62d25106ae69d4693475c79618dd5e884fieldingPortability : portable
031b91a62d25106ae69d4693475c79618dd5e884fieldingAbstract syntax of HetCASL specification libraries
031b91a62d25106ae69d4693475c79618dd5e884fielding Follows Sect. II:2.2.5 of the CASL Reference Manual.
208651a016b098f4fa1f6279559f104d70f1632dtakashimkQualName :: SIMPLE_ID -> LIB_ID -> Id -> Id
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshikimkQualName nodeId libId i =
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshiki Id [genToken "OM"] [i, simpleIdToId nodeId, libIdToId libId] $ posOfId i
208651a016b098f4fa1f6279559f104d70f1632dtakashilibIdToId :: LIB_ID -> Id
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshikilibIdToId li = let
208651a016b098f4fa1f6279559f104d70f1632dtakashi path = splitOn '/' $ show li
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshiki toTok s = Token s $ getRange li
208651a016b098f4fa1f6279559f104d70f1632dtakashi in mkId $ map toTok $ intersperse "/" path
208651a016b098f4fa1f6279559f104d70f1632dtakashidata LIB_NAME = Lib_version
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshiki { getLIB_ID :: LIB_ID
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshiki , libVersion :: VERSION_NUMBER }
208651a016b098f4fa1f6279559f104d70f1632dtakashi | Lib_id { getLIB_ID :: LIB_ID }
208651a016b098f4fa1f6279559f104d70f1632dtakashidata LIB_ID = Direct_link URL Range
208651a016b098f4fa1f6279559f104d70f1632dtakashi -- pos: start of URL
208651a016b098f4fa1f6279559f104d70f1632dtakashi | Indirect_link PATH Range FilePath ClockTime
208651a016b098f4fa1f6279559f104d70f1632dtakashi -- pos: start of PATH
208651a016b098f4fa1f6279559f104d70f1632dtakashinoTime :: ClockTime
208651a016b098f4fa1f6279559f104d70f1632dtakashinoTime = TOD 0 0
208651a016b098f4fa1f6279559f104d70f1632dtakashi-- | Returns the LIB_ID of a LIB_NAME
208651a016b098f4fa1f6279559f104d70f1632dtakashigetModTime :: LIB_ID -> ClockTime
208651a016b098f4fa1f6279559f104d70f1632dtakashigetModTime li = case li of
208651a016b098f4fa1f6279559f104d70f1632dtakashi Direct_link _ _ -> noTime
208651a016b098f4fa1f6279559f104d70f1632dtakashi Indirect_link _ _ _ m -> m
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshikiupdFilePathOfLibId :: FilePath -> ClockTime -> LIB_ID -> LIB_ID
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshikiupdFilePathOfLibId fp mt li = case li of
208651a016b098f4fa1f6279559f104d70f1632dtakashi Direct_link _ _ -> li
208651a016b098f4fa1f6279559f104d70f1632dtakashi Indirect_link p r _ _ -> Indirect_link p r fp mt
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshikidata VERSION_NUMBER = Version_number [String] Range deriving (Show, Eq)
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshiki -- pos: "version", start of first string
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshikitype URL = String
208651a016b098f4fa1f6279559f104d70f1632dtakashitype PATH = String
208651a016b098f4fa1f6279559f104d70f1632dtakashiinstance GetRange LIB_ID where
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshiki getRange li = case li of
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshiki Direct_link _ r -> r
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshiki Indirect_link _ r _ _ -> r
208651a016b098f4fa1f6279559f104d70f1632dtakashiinstance Show LIB_ID where
208651a016b098f4fa1f6279559f104d70f1632dtakashi show li = case li of
208651a016b098f4fa1f6279559f104d70f1632dtakashi Direct_link s _ -> s
208651a016b098f4fa1f6279559f104d70f1632dtakashi Indirect_link s1 _ _ _ -> s1
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshikiinstance Show LIB_NAME where
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshiki show ln = case ln of
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshiki Lib_version li (Version_number vs _) ->
208651a016b098f4fa1f6279559f104d70f1632dtakashi shows li $ " version " ++ intercalate "." vs
208651a016b098f4fa1f6279559f104d70f1632dtakashi Lib_id li -> show li
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshikiinstance Eq LIB_ID where
208651a016b098f4fa1f6279559f104d70f1632dtakashi Direct_link s1 _ == Direct_link s2 _ = s1 == s2
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshiki Indirect_link s1 _ _ _ == Indirect_link s2 _ _ _ = s1 == s2
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshiki _ == _ = False
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshikiinstance Ord LIB_ID where
208651a016b098f4fa1f6279559f104d70f1632dtakashi Direct_link s1 _ <= Direct_link s2 _ = s1 <= s2
208651a016b098f4fa1f6279559f104d70f1632dtakashi Indirect_link s1 _ _ _ <= Indirect_link s2 _ _ _ = s1 <= s2
208651a016b098f4fa1f6279559f104d70f1632dtakashi Direct_link _ _ <= _ = True
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshiki Indirect_link _ _ _ _ <= _ = False
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshikiinstance Eq LIB_NAME where
208651a016b098f4fa1f6279559f104d70f1632dtakashi ln1 == ln2 = getLIB_ID ln1 == getLIB_ID ln2
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshikiinstance Ord LIB_NAME where
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshiki ln1 <= ln2 = getLIB_ID ln1 <= getLIB_ID ln2
a4b591abd5d8601b85aeed3ec7e129420a2c91a5kawaiinstance Pretty LIB_NAME where
208651a016b098f4fa1f6279559f104d70f1632dtakashi pretty l = case l of
208651a016b098f4fa1f6279559f104d70f1632dtakashi Lib_version i v ->
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshiki fsep [pretty i, keyword versionS, pretty v]
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshiki Lib_id i -> pretty i
208651a016b098f4fa1f6279559f104d70f1632dtakashiinstance Pretty LIB_ID where
208651a016b098f4fa1f6279559f104d70f1632dtakashi pretty l = structId $ case l of
208651a016b098f4fa1f6279559f104d70f1632dtakashi Direct_link u _ -> u
208651a016b098f4fa1f6279559f104d70f1632dtakashi Indirect_link p _ _ _ -> p
208651a016b098f4fa1f6279559f104d70f1632dtakashiinstance Pretty VERSION_NUMBER where
f6e426d8627afcd70d2cd78c21f0f8afe7964f93yoshiki pretty (Version_number aa _) =
208651a016b098f4fa1f6279559f104d70f1632dtakashi hcat $ punctuate dot $ map codeToken aa