AS.hs revision 52991d9b46a98ad6a9020421a3244950b0f8a522
8a77240a809197c92c0736c431b4b88947a7bac1Christian MaederModule : $Header$
6ea54752d184beb92c92fbae17ae9f7dd065d988Christian MaederCopyright : (c) C. Maeder
e9458b1a7a19a63aa4c179f9ab20f4d50681c168Jens ElknerLicense : GPLv2 or higher, see LICENSE.txt
6ea54752d184beb92c92fbae17ae9f7dd065d988Christian MaederMaintainer : Christian.Maeder@dfki.de
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu ProdescuStability : provisional
2eeec5240b424984e3ee26296da1eeab6c6d739eChristian MaederPortability : portable
306763c67bb99228487345b32ab8c5c6cd41f23cChristian MaederOWL 2 Functional Syntax constructs
44fb55f639914f4f531641f32dd4904f15c510a4Till Mossakowski <http://www.w3.org/TR/2009/REC-owl2-syntax-20091027/#Functional-Style_Syntax>
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski <http://www.w3.org/TR/owl2-manchester-syntax/>
1bc5dccbf0083a620ae1181c717fea75e4af5e5cChristian Maederimport Data.Char (intToDigit)
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maederimport qualified Data.Map as Map
1bc5dccbf0083a620ae1181c717fea75e4af5e5cChristian Maederdata IRIType = Full | Abbreviated | NodeID
1bc5dccbf0083a620ae1181c717fea75e4af5e5cChristian Maeder deriving (Show, Eq, Ord)
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder{- | full or abbreviated IRIs with a possible uri for the prefix
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder or a local part following a hash sign -}
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maederdata QName = QN
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder { namePrefix :: String
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder -- ^ the name prefix part of a qualified name \"namePrefix:localPart\"
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder , localPart :: String
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder -- ^ the local part of a qualified name \"namePrefix:localPart\"
1bc5dccbf0083a620ae1181c717fea75e4af5e5cChristian Maeder , iriType :: IRIType
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski , expandedIRI :: String
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski -- ^ the associated namespace uri (not printed)
922819b1c2d383a0fa5d70e1c4aa76667e2f1ca3Christian Maeder , iriPos :: Range
27166b063721ef1a2efd8f00ab3d9bc820b315fbChristian Maeder } deriving Show
9f87aabedf02d74917d94fe1ac0300e07d3d4bc2Christian Maederinstance Eq QName where
9f87aabedf02d74917d94fe1ac0300e07d3d4bc2Christian Maeder p == q = compare p q == EQ
24a0fbb77b860bc28d25be37ba555fd5746cb6d6Christian Maederinstance Ord QName where
27166b063721ef1a2efd8f00ab3d9bc820b315fbChristian Maeder compare (QN p1 l1 b1 n1 _) (QN p2 l2 b2 n2 _) =
27166b063721ef1a2efd8f00ab3d9bc820b315fbChristian Maeder if null n1 || null n2 then compare (b1, p1, l1) (b2, p2, l2) else
27166b063721ef1a2efd8f00ab3d9bc820b315fbChristian Maeder compare n1 n2 -- compare fully expanded names only
27166b063721ef1a2efd8f00ab3d9bc820b315fbChristian Maederinstance GetRange QName where
63324a97283728a30932828a612c7b0b0f687624Christian Maeder getRange = iriPos
59fa9b1349ae1e001d996da732c4ac805c2938e2Christian MaedershowQN :: QName -> String
e9249d3ecd51a2b6a966a58669953e58d703adc6Till MossakowskishowQN q = (if iriType q /= Abbreviated then showQI else showQU) q
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski-- | show QName as abbreviated iri
e9249d3ecd51a2b6a966a58669953e58d703adc6Till MossakowskishowQU :: QName -> String
53310804002cd9e3c9c5844db3b984abcf001788Christian MaedershowQU (QN pre local _ _ _) =
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski if null pre then local else pre ++ ":" ++ local
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski-- | show QName in ankle brackets as full iris
e9249d3ecd51a2b6a966a58669953e58d703adc6Till MossakowskishowQI :: QName -> String
e9249d3ecd51a2b6a966a58669953e58d703adc6Till MossakowskishowQI = ('<' :) . (++ ">") . showQU
3a87487c048b275c56e502c4a933273788e8d0bbChristian MaedernullQName :: QName
2b565fe5cfb9f99857fd25b52304758d8544e266Mihai CodescunullQName = QN "" "" Abbreviated "" nullRange
2b565fe5cfb9f99857fd25b52304758d8544e266Mihai CodescudummyQName :: QName
b5056cf24da461ee868c4be7b803a76b677fa21dChristian Maeder QN "http" "//www.dfki.de/sks/hets/ontology/unamed" Full "" nullRange
4184cb191a9081cb2a9cf3ef5f060f56f0ca5922Till MossakowskimkQName :: String -> QName
8731f7b93b26083dc34a2c0937cd6493b42f2c2cTill MossakowskimkQName s = nullQName { localPart = s }
24a0fbb77b860bc28d25be37ba555fd5746cb6d6Christian MaedersetQRange :: Range -> QName -> QName
24a0fbb77b860bc28d25be37ba555fd5746cb6d6Christian MaedersetQRange r q = q { iriPos = r }
b5056cf24da461ee868c4be7b803a76b677fa21dChristian MaedersetPrefix :: String -> QName -> QName
b5056cf24da461ee868c4be7b803a76b677fa21dChristian MaedersetPrefix s q = q { namePrefix = s }
d97cb7d1c9beadc4d9102738da0a88c4efcf8fddChristian MaedersetReservedPrefix :: QName -> QName
b5056cf24da461ee868c4be7b803a76b677fa21dChristian MaedersetReservedPrefix iri
b5056cf24da461ee868c4be7b803a76b677fa21dChristian Maeder | isDatatypeKey iri && (null $ namePrefix iri) = setPrefix "xsd" iri
b5056cf24da461ee868c4be7b803a76b677fa21dChristian Maeder | isThing iri && (null $ namePrefix iri) = setPrefix "owl" iri
b5056cf24da461ee868c4be7b803a76b677fa21dChristian Maeder | otherwise = iri
fd496ec12c6be2731410ea84111f1ff88d8b6384Christian MaedersetFull :: QName -> QName
f23641ce10de2d58493d41a4b39c64d904e5b534Christian MaedersetFull q = q {iriType = Full}
f23641ce10de2d58493d41a4b39c64d904e5b534Christian Maedertype IRI = QName
f23641ce10de2d58493d41a4b39c64d904e5b534Christian Maeder-- | checks if an IRI is an anonymous individual
f23641ce10de2d58493d41a4b39c64d904e5b534Christian MaederisAnonymous :: IRI -> Bool
a89e661aad28f1b39f4fc9f9f9a4d46074234123Christian MaederisAnonymous iri = iriType iri == NodeID
a89e661aad28f1b39f4fc9f9f9a4d46074234123Christian MaederowlSomething :: [String]
b5056cf24da461ee868c4be7b803a76b677fa21dChristian MaederowlSomething = ["Thing", "Nothing"]
b5056cf24da461ee868c4be7b803a76b677fa21dChristian MaederisThing :: IRI -> Bool
b60a22e76e983e8129c5dae4d713fe2794ed7054Christian MaederisThing u = elem (localPart u) owlSomething && elem (namePrefix u) ["", "owl"]
83b3260413a3b1b7dee1f9c4d3249dec994a875cMihai Codescu || (showQU u) `elem` map ("http://www.w3.org/2002/07/owl#" ++) owlSomething
a975722baf6fee1ca3e67df170c732c4abd0a945Christian Maeder-- | checks if a string (bound to be localPart of an IRI) contains \":\/\/\"
a975722baf6fee1ca3e67df170c732c4abd0a945Christian MaedercssIRI :: String -> IRIType
a975722baf6fee1ca3e67df170c732c4abd0a945Christian MaedercssIRI iri = if isInfixOf "://" iri then Full else Abbreviated
63324a97283728a30932828a612c7b0b0f687624Christian Maeder-- | prefix -> localname
fd496ec12c6be2731410ea84111f1ff88d8b6384Christian Maedertype PrefixMap = Map.Map String String
b5056cf24da461ee868c4be7b803a76b677fa21dChristian Maedertype LexicalForm = String
b5056cf24da461ee868c4be7b803a76b677fa21dChristian Maedertype LanguageTag = String
b5056cf24da461ee868c4be7b803a76b677fa21dChristian Maedertype ImportIRI = IRI
b5056cf24da461ee868c4be7b803a76b677fa21dChristian Maedertype OntologyIRI = IRI
b5056cf24da461ee868c4be7b803a76b677fa21dChristian Maedertype Class = IRI
f2c050360525df494e6115073b0edc4c443a847cMihai Codescutype Datatype = IRI
b60a22e76e983e8129c5dae4d713fe2794ed7054Christian Maedertype ObjectProperty = IRI
f2c050360525df494e6115073b0edc4c443a847cMihai Codescutype DataProperty = IRI
b60a22e76e983e8129c5dae4d713fe2794ed7054Christian Maedertype AnnotationProperty = IRI
f2c050360525df494e6115073b0edc4c443a847cMihai Codescutype NamedIndividual = IRI
0e51a998b1b213654c7a9eca451562041971f100Till Mossakowskitype Individual = IRI
b60a22e76e983e8129c5dae4d713fe2794ed7054Christian Maederdata EquivOrDisjoint = Equivalent | Disjoint
b60a22e76e983e8129c5dae4d713fe2794ed7054Christian Maeder deriving (Show, Eq, Ord)
5c358300e78157f4bfaf5415c70e1096a9205b61Christian MaedershowEquivOrDisjoint :: EquivOrDisjoint -> String
5c358300e78157f4bfaf5415c70e1096a9205b61Christian MaedershowEquivOrDisjoint ed = case ed of
5c358300e78157f4bfaf5415c70e1096a9205b61Christian Maeder Equivalent -> equivalentToC
5c358300e78157f4bfaf5415c70e1096a9205b61Christian Maeder Disjoint -> disjointWithC
5c358300e78157f4bfaf5415c70e1096a9205b61Christian Maederdata DomainOrRange = ADomain | ARange
27166b063721ef1a2efd8f00ab3d9bc820b315fbChristian Maeder deriving (Show, Eq, Ord)
5c358300e78157f4bfaf5415c70e1096a9205b61Christian MaedershowDomainOrRange :: DomainOrRange -> String
f23641ce10de2d58493d41a4b39c64d904e5b534Christian MaedershowDomainOrRange dr = case dr of
19298cbfd6ee2abd904f3181af7760b965b822c3Christian Maeder ADomain -> domainC
19298cbfd6ee2abd904f3181af7760b965b822c3Christian Maeder ARange -> rangeC
19298cbfd6ee2abd904f3181af7760b965b822c3Christian Maederdata SameOrDifferent = Same | Different
19298cbfd6ee2abd904f3181af7760b965b822c3Christian Maeder deriving (Show, Eq, Ord)
fd496ec12c6be2731410ea84111f1ff88d8b6384Christian MaedershowSameOrDifferent :: SameOrDifferent -> String
19298cbfd6ee2abd904f3181af7760b965b822c3Christian MaedershowSameOrDifferent sd = case sd of
5c358300e78157f4bfaf5415c70e1096a9205b61Christian Maeder Same -> sameAsC
5c358300e78157f4bfaf5415c70e1096a9205b61Christian Maeder Different -> differentFromC
5c358300e78157f4bfaf5415c70e1096a9205b61Christian Maederdata Relation =
5c358300e78157f4bfaf5415c70e1096a9205b61Christian Maeder EDRelation EquivOrDisjoint
5c358300e78157f4bfaf5415c70e1096a9205b61Christian Maeder | SubPropertyOf
5c358300e78157f4bfaf5415c70e1096a9205b61Christian Maeder | DRRelation DomainOrRange
5c358300e78157f4bfaf5415c70e1096a9205b61Christian Maeder | SDRelation SameOrDifferent
5c358300e78157f4bfaf5415c70e1096a9205b61Christian Maeder deriving (Show, Eq, Ord)
5c358300e78157f4bfaf5415c70e1096a9205b61Christian MaedershowRelation :: Relation -> String
5c358300e78157f4bfaf5415c70e1096a9205b61Christian MaedershowRelation r = case r of
5c358300e78157f4bfaf5415c70e1096a9205b61Christian Maeder EDRelation ed -> showEquivOrDisjoint ed
5c358300e78157f4bfaf5415c70e1096a9205b61Christian Maeder SubPropertyOf -> subPropertyOfC
5c358300e78157f4bfaf5415c70e1096a9205b61Christian Maeder InverseOf -> inverseOfC
5c358300e78157f4bfaf5415c70e1096a9205b61Christian Maeder SubClass -> subClassOfC
5c358300e78157f4bfaf5415c70e1096a9205b61Christian Maeder Types -> typesC
5c358300e78157f4bfaf5415c70e1096a9205b61Christian Maeder DRRelation dr -> showDomainOrRange dr
5c358300e78157f4bfaf5415c70e1096a9205b61Christian Maeder SDRelation sd -> showSameOrDifferent sd
5c358300e78157f4bfaf5415c70e1096a9205b61Christian MaedergetED :: Relation -> EquivOrDisjoint
5c358300e78157f4bfaf5415c70e1096a9205b61Christian MaedergetED r = case r of
83b3260413a3b1b7dee1f9c4d3249dec994a875cMihai Codescu EDRelation ed -> ed
83b3260413a3b1b7dee1f9c4d3249dec994a875cMihai Codescu _ -> error "not domain or range"
f23641ce10de2d58493d41a4b39c64d904e5b534Christian MaedergetDR :: Relation -> DomainOrRange
b1f59a4ea7c96f4c03a4d7cfcb9c5e66871cfbbbChristian MaedergetDR r = case r of
6ea54752d184beb92c92fbae17ae9f7dd065d988Christian Maeder DRRelation dr -> dr
6ea54752d184beb92c92fbae17ae9f7dd065d988Christian Maeder _ -> error "not domain or range"
6ea54752d184beb92c92fbae17ae9f7dd065d988Christian MaedergetSD :: Relation -> SameOrDifferent
6ea54752d184beb92c92fbae17ae9f7dd065d988Christian MaedergetSD s = case s of
6ea54752d184beb92c92fbae17ae9f7dd065d988Christian Maeder SDRelation sd -> sd
fd496ec12c6be2731410ea84111f1ff88d8b6384Christian Maeder _ -> error "not same or different"
fd496ec12c6be2731410ea84111f1ff88d8b6384Christian Maederdata Character =
fd496ec12c6be2731410ea84111f1ff88d8b6384Christian Maeder | InverseFunctional
9f87aabedf02d74917d94fe1ac0300e07d3d4bc2Christian Maeder | Irreflexive
9f87aabedf02d74917d94fe1ac0300e07d3d4bc2Christian Maeder | Antisymmetric
24a0fbb77b860bc28d25be37ba555fd5746cb6d6Christian Maeder deriving (Enum, Bounded, Show, Eq, Ord)
fd496ec12c6be2731410ea84111f1ff88d8b6384Christian Maederdata PositiveOrNegative = Positive | Negative
27166b063721ef1a2efd8f00ab3d9bc820b315fbChristian Maeder deriving (Show, Eq, Ord)
6ea54752d184beb92c92fbae17ae9f7dd065d988Christian Maederdata QuantifierType = AllValuesFrom | SomeValuesFrom
4ef5e33657aae95850b7e6941f67ac1fb73cd13fChristian Maeder deriving (Show, Eq, Ord)
4ef5e33657aae95850b7e6941f67ac1fb73cd13fChristian MaedershowQuantifierType :: QuantifierType -> String
6ea54752d184beb92c92fbae17ae9f7dd065d988Christian MaedershowQuantifierType ty = case ty of
27166b063721ef1a2efd8f00ab3d9bc820b315fbChristian Maeder AllValuesFrom -> onlyS
6ea54752d184beb92c92fbae17ae9f7dd065d988Christian Maeder SomeValuesFrom -> someS
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder-- | data type strings (some are not listed in the grammar)
53310804002cd9e3c9c5844db3b984abcf001788Christian MaederdatatypeKeys :: [String]
19298cbfd6ee2abd904f3181af7760b965b822c3Christian MaederdatatypeKeys =
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder , negativeIntegerS
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder , nonNegativeIntegerS
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder , nonPositiveIntegerS
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder , positiveIntegerS
eb0e19a83d8e3eaeb936c197555b20d37129022cKlaus LuettichisDatatypeKey :: IRI -> Bool
eb0e19a83d8e3eaeb936c197555b20d37129022cKlaus LuettichisDatatypeKey u =
6ca6ffc92f5c0058ae4b92d46e4e8cbc7beb11fcMihai Codescu elem (localPart u) datatypeKeys && elem (namePrefix u) ["", "xsd"]
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder || (showQU u) `elem` map ("http://www.w3.org/2001/XMLSchema#" ++) datatypeKeys
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maederdata DatatypeType = OWL2Int | OWL2String | OWL2Bool | Other
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder deriving (Show, Eq, Ord)
eb0e19a83d8e3eaeb936c197555b20d37129022cKlaus LuettichdatatypeType :: IRI -> DatatypeType
eb0e19a83d8e3eaeb936c197555b20d37129022cKlaus LuettichdatatypeType iri =
eb0e19a83d8e3eaeb936c197555b20d37129022cKlaus Luettich let lp = localPart iri
eb0e19a83d8e3eaeb936c197555b20d37129022cKlaus Luettich in case isDatatypeKey iri of
da955132262baab309a50fdffe228c9efe68251dCui Jian | lp == booleanS -> OWL2Bool
eb0e19a83d8e3eaeb936c197555b20d37129022cKlaus Luettich | lp `elem` [integerS, negativeIntegerS, nonNegativeIntegerS,
eb0e19a83d8e3eaeb936c197555b20d37129022cKlaus Luettich nonPositiveIntegerS, positiveIntegerS] -> OWL2Int
da955132262baab309a50fdffe228c9efe68251dCui Jian | lp == stringS -> OWL2String
27166b063721ef1a2efd8f00ab3d9bc820b315fbChristian Maeder | otherwise -> Other
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder False -> Other
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maederdata DatatypeFacet =
3946c010d94321f14139e12061dd4261a3cc7295Christian Maeder | MININCLUSIVE
3946c010d94321f14139e12061dd4261a3cc7295Christian Maeder | MINEXCLUSIVE
3946c010d94321f14139e12061dd4261a3cc7295Christian Maeder | MAXINCLUSIVE
3946c010d94321f14139e12061dd4261a3cc7295Christian Maeder | MAXEXCLUSIVE
3946c010d94321f14139e12061dd4261a3cc7295Christian Maeder | TOTALDIGITS
3946c010d94321f14139e12061dd4261a3cc7295Christian Maeder | FRACTIONDIGITS
27166b063721ef1a2efd8f00ab3d9bc820b315fbChristian Maeder deriving (Show, Eq, Ord)
27166b063721ef1a2efd8f00ab3d9bc820b315fbChristian MaedershowFacet :: DatatypeFacet -> String
e9249d3ecd51a2b6a966a58669953e58d703adc6Till MossakowskishowFacet df = case df of
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski LENGTH -> lengthS
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski MINLENGTH -> minLengthS
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski MAXLENGTH -> maxLengthS
6ca6ffc92f5c0058ae4b92d46e4e8cbc7beb11fcMihai Codescu PATTERN -> patternS
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski MININCLUSIVE -> lessEq
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski MINEXCLUSIVE -> lessS
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski MAXINCLUSIVE -> greaterEq
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski MAXEXCLUSIVE -> greaterS
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski TOTALDIGITS -> digitsS
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder FRACTIONDIGITS -> fractionS
eb0e19a83d8e3eaeb936c197555b20d37129022cKlaus Luettichdata CardinalityType = MinCardinality | MaxCardinality | ExactCardinality
eb0e19a83d8e3eaeb936c197555b20d37129022cKlaus Luettich deriving (Show, Eq, Ord)
3fb8a83c3c06671ee94fd12a1782b14563d09df1Christian MaedershowCardinalityType :: CardinalityType -> String
3fb8a83c3c06671ee94fd12a1782b14563d09df1Christian MaedershowCardinalityType ty = case ty of
3fb8a83c3c06671ee94fd12a1782b14563d09df1Christian Maeder MinCardinality -> minS
eb0e19a83d8e3eaeb936c197555b20d37129022cKlaus Luettich MaxCardinality -> maxS
19298cbfd6ee2abd904f3181af7760b965b822c3Christian Maeder ExactCardinality -> exactlyS
27166b063721ef1a2efd8f00ab3d9bc820b315fbChristian Maederdata Cardinality a b = Cardinality CardinalityType Int a (Maybe b)
83b3260413a3b1b7dee1f9c4d3249dec994a875cMihai Codescu deriving (Show, Eq, Ord)
da955132262baab309a50fdffe228c9efe68251dCui Jiandata JunctionType = UnionOf | IntersectionOf
da955132262baab309a50fdffe228c9efe68251dCui Jian deriving (Show, Eq, Ord)
da955132262baab309a50fdffe228c9efe68251dCui Jiantype ConstrainingFacet = IRI
a98fd29a06e80e447af26d898044c23497adbc73Mihai Codescutype RestrictionValue = Literal
da955132262baab309a50fdffe228c9efe68251dCui Jiandata Entity = Entity EntityType IRI deriving (Show, Eq, Ord)
1a38107941725211e7c3f051f7a8f5e12199f03acmaederinstance GetRange Entity where
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder getRange (Entity _ iri) = iriPos iri
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maederdata EntityType =
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski | ObjectProperty
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski | DataProperty
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski | AnnotationProperty
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski | NamedIndividual
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski deriving (Enum, Bounded, Show, Read, Eq, Ord)
e9249d3ecd51a2b6a966a58669953e58d703adc6Till MossakowskishowEntityType :: EntityType -> String
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian MaedershowEntityType e = case e of
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder Datatype -> datatypeC
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski Class -> classC
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski ObjectProperty -> objectPropertyC
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder DataProperty -> dataPropertyC
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski AnnotationProperty -> annotationPropertyC
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski NamedIndividual -> individualC
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian MaederentityTypes :: [EntityType]
53310804002cd9e3c9c5844db3b984abcf001788Christian MaederentityTypes = [minBound .. maxBound]
53310804002cd9e3c9c5844db3b984abcf001788Christian Maederdata TypedOrUntyped = Typed Datatype | Untyped (Maybe LanguageTag)
8731f7b93b26083dc34a2c0937cd6493b42f2c2cTill Mossakowski deriving (Show, Eq, Ord)
da955132262baab309a50fdffe228c9efe68251dCui Jiandata Literal = Literal LexicalForm TypedOrUntyped | NumberLit FloatLit
27166b063721ef1a2efd8f00ab3d9bc820b315fbChristian Maeder deriving (Show, Eq, Ord)
27166b063721ef1a2efd8f00ab3d9bc820b315fbChristian Maeder-- | non-negative integers given by the sequence of digits
fd496ec12c6be2731410ea84111f1ff88d8b6384Christian Maederdata NNInt = NNInt [Int] deriving (Eq, Ord)
53310804002cd9e3c9c5844db3b984abcf001788Christian Maederinstance Show NNInt where
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder show (NNInt l) = map intToDigit l
53310804002cd9e3c9c5844db3b984abcf001788Christian MaederzeroNNInt :: NNInt
922819b1c2d383a0fa5d70e1c4aa76667e2f1ca3Christian MaederzeroNNInt = NNInt []
e9249d3ecd51a2b6a966a58669953e58d703adc6Till MossakowskiisZeroNNInt :: NNInt -> Bool
27166b063721ef1a2efd8f00ab3d9bc820b315fbChristian MaederisZeroNNInt (NNInt l) = null l
53310804002cd9e3c9c5844db3b984abcf001788Christian Maederdata IntLit = IntLit
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder { absInt :: NNInt
6ea54752d184beb92c92fbae17ae9f7dd065d988Christian Maeder , isNegInt :: Bool }
5bb3727ef464d9f08ab0decb2d4a59c1352a389eChristian Maeder deriving (Eq, Ord)
53310804002cd9e3c9c5844db3b984abcf001788Christian Maederinstance Show IntLit where
922819b1c2d383a0fa5d70e1c4aa76667e2f1ca3Christian Maeder show (IntLit n b) = (if b then ('-' :) else id) $ show n
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian MaederzeroInt :: IntLit
e9249d3ecd51a2b6a966a58669953e58d703adc6Till MossakowskizeroInt = IntLit zeroNNInt False
83b3260413a3b1b7dee1f9c4d3249dec994a875cMihai CodescuisZeroInt :: IntLit -> Bool
83b3260413a3b1b7dee1f9c4d3249dec994a875cMihai CodescuisZeroInt (IntLit n _) = isZeroNNInt n
83b3260413a3b1b7dee1f9c4d3249dec994a875cMihai CodescunegNNInt :: Bool -> NNInt -> IntLit
83b3260413a3b1b7dee1f9c4d3249dec994a875cMihai CodescunegNNInt b n = IntLit n b
83b3260413a3b1b7dee1f9c4d3249dec994a875cMihai CodescunegInt :: IntLit -> IntLit
83b3260413a3b1b7dee1f9c4d3249dec994a875cMihai CodescunegInt (IntLit n b) = IntLit n $ not b
83b3260413a3b1b7dee1f9c4d3249dec994a875cMihai Codescudata DecLit = DecLit
83b3260413a3b1b7dee1f9c4d3249dec994a875cMihai Codescu { truncDec :: IntLit
83b3260413a3b1b7dee1f9c4d3249dec994a875cMihai Codescu , fracDec :: NNInt }
83b3260413a3b1b7dee1f9c4d3249dec994a875cMihai Codescu deriving (Eq, Ord)
83b3260413a3b1b7dee1f9c4d3249dec994a875cMihai Codescuinstance Show DecLit where
63324a97283728a30932828a612c7b0b0f687624Christian Maeder show (DecLit t f) = show t
a975722baf6fee1ca3e67df170c732c4abd0a945Christian Maeder ++ if isZeroNNInt f then "" else
0cd4575fe679a26de63d9a75a4d66d8366f79ab8Christian MaederisDecInt :: DecLit -> Bool
0cd4575fe679a26de63d9a75a4d66d8366f79ab8Christian MaederisDecInt = isZeroNNInt . fracDec
0cd4575fe679a26de63d9a75a4d66d8366f79ab8Christian MaedernegDec :: Bool -> DecLit -> DecLit
0cd4575fe679a26de63d9a75a4d66d8366f79ab8Christian MaedernegDec b (DecLit t f) = DecLit (if b then t else negInt t) f
53f347ab16f992d909f47a50bf2059f57f3c7ad0Christian Maederdata FloatLit = FloatLit
63324a97283728a30932828a612c7b0b0f687624Christian Maeder { floatBase :: DecLit
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder , floatExp :: IntLit }
933baca0720dae81434de384b32a93b47e754d09Christian Maeder deriving (Eq, Ord)
da955132262baab309a50fdffe228c9efe68251dCui Jianinstance Show FloatLit where
a98fd29a06e80e447af26d898044c23497adbc73Mihai Codescu show (FloatLit b e) = show b
a98fd29a06e80e447af26d898044c23497adbc73Mihai Codescu ++ if isZeroInt e then "" else
da955132262baab309a50fdffe228c9efe68251dCui Jian 'E' : show e ++ "F"
f2c050360525df494e6115073b0edc4c443a847cMihai CodescuisFloatDec :: FloatLit -> Bool
da955132262baab309a50fdffe228c9efe68251dCui JianisFloatDec = isZeroInt . floatExp
b60a22e76e983e8129c5dae4d713fe2794ed7054Christian MaederisFloatInt :: FloatLit -> Bool
b60a22e76e983e8129c5dae4d713fe2794ed7054Christian MaederisFloatInt f = isFloatDec f && isDecInt (floatBase f)
556f473448dfcceee22afaa89ed7a364489cdbbbChristian MaederfloatToInt :: FloatLit -> IntLit
556f473448dfcceee22afaa89ed7a364489cdbbbChristian MaederfloatToInt = truncDec . floatBase
556f473448dfcceee22afaa89ed7a364489cdbbbChristian MaederintToDec :: IntLit -> DecLit
556f473448dfcceee22afaa89ed7a364489cdbbbChristian MaederintToDec i = DecLit i zeroNNInt
556f473448dfcceee22afaa89ed7a364489cdbbbChristian MaederdecToFloat :: DecLit -> FloatLit
556f473448dfcceee22afaa89ed7a364489cdbbbChristian MaederdecToFloat d = FloatLit d zeroInt
556f473448dfcceee22afaa89ed7a364489cdbbbChristian MaederintToFloat :: IntLit -> FloatLit
556f473448dfcceee22afaa89ed7a364489cdbbbChristian MaederintToFloat = decToFloat . intToDec
556f473448dfcceee22afaa89ed7a364489cdbbbChristian MaederabInt :: IntLit -> IntLit
556f473448dfcceee22afaa89ed7a364489cdbbbChristian MaederabInt int = int {isNegInt = False}
556f473448dfcceee22afaa89ed7a364489cdbbbChristian MaederabDec :: DecLit -> DecLit
556f473448dfcceee22afaa89ed7a364489cdbbbChristian MaederabDec dec = dec {truncDec = abInt $ truncDec dec}
556f473448dfcceee22afaa89ed7a364489cdbbbChristian MaederabFloat :: FloatLit -> FloatLit
a9183ce3b997bf3539e427b3cd22d70c3565446eChristian MaederabFloat f = f {floatBase = abDec $ floatBase f}
556f473448dfcceee22afaa89ed7a364489cdbbbChristian MaederisNegDec :: DecLit -> Bool
a9183ce3b997bf3539e427b3cd22d70c3565446eChristian MaederisNegDec d = isNegInt $ truncDec d
a9183ce3b997bf3539e427b3cd22d70c3565446eChristian MaedernumberName :: FloatLit -> String
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder | isFloatInt f = integerS
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder | isFloatDec f = decimalS
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder | otherwise = floatS
556f473448dfcceee22afaa89ed7a364489cdbbbChristian MaedercTypeS :: String
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder-- * PROPERTY EXPRESSIONS
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maedertype InverseObjectProperty = ObjectPropertyExpression
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maederdata ObjectPropertyExpression = ObjectProp ObjectProperty
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder | ObjectInverseOf InverseObjectProperty
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder deriving (Show, Eq, Ord)
3946c010d94321f14139e12061dd4261a3cc7295Christian Maedertype DataPropertyExpression = DataProperty
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder-- * DATA RANGES
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maederdata DataRange
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder = DataType Datatype [(ConstrainingFacet, RestrictionValue)]
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder | DataJunction JunctionType [DataRange]
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder | DataComplementOf DataRange
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder | DataOneOf [Literal]
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder deriving (Show, Eq, Ord)
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder-- * CLASS EXPERSSIONS
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maederdata ClassExpression =
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder Expression Class
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder | ObjectJunction JunctionType [ClassExpression]
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder | ObjectComplementOf ClassExpression
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder | ObjectOneOf [Individual]
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder | ObjectValuesFrom QuantifierType ObjectPropertyExpression ClassExpression
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder | ObjectHasValue ObjectPropertyExpression Individual
4ef5e33657aae95850b7e6941f67ac1fb73cd13fChristian Maeder | ObjectHasSelf ObjectPropertyExpression
4ef5e33657aae95850b7e6941f67ac1fb73cd13fChristian Maeder | ObjectCardinality (Cardinality ObjectPropertyExpression ClassExpression)
4ef5e33657aae95850b7e6941f67ac1fb73cd13fChristian Maeder | DataValuesFrom QuantifierType DataPropertyExpression DataRange
4ef5e33657aae95850b7e6941f67ac1fb73cd13fChristian Maeder | DataHasValue DataPropertyExpression Literal
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder | DataCardinality (Cardinality DataPropertyExpression DataRange)
556f473448dfcceee22afaa89ed7a364489cdbbbChristian Maeder deriving (Show, Eq, Ord)
fd496ec12c6be2731410ea84111f1ff88d8b6384Christian Maeder-- * ANNOTATIONS
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroederdata Annotation = Annotation [Annotation] AnnotationProperty AnnotationValue
082693e05d9719faff6a21da3a476dfe8f42a261Jonathan von Schroeder deriving (Show, Eq, Ord)
082693e05d9719faff6a21da3a476dfe8f42a261Jonathan von Schroederdata AnnotationValue
082693e05d9719faff6a21da3a476dfe8f42a261Jonathan von Schroeder | AnnValLit Literal
082693e05d9719faff6a21da3a476dfe8f42a261Jonathan von Schroeder deriving (Show, Eq, Ord)