{- |
Module      :  ./OWL2/ParseMS.hs
Copyright   :  (c) Björn Gehrke
License     :  GPLv2 or higher, see LICENSE.txt
Maintainer  :  bjoern.gehrke@ovgu.de
Stability   :  provisional
Portability :  portable
Manchester Syntax parser
References  :  <https://www.w3.org/TR/owl2-manchester-syntax/>
-}

module OWL2.ParseMS where

import Prelude hiding (lookup)

import OWL2.AS
import OWL2.Keywords hiding (comment)
import OWL2.ColonKeywords

import Common.Keywords
import Common.IRI
import Common.Id (stringToId)
import Common.Lexer
import Common.Parsec
import Common.AnnoParser (newlineOrEof, commentLine)
import Common.Token (criticalKeywords)
import Common.Utils (nubOrd)

import qualified Common.GlobalAnnotations as GA (PrefixMap)

import Text.ParserCombinators.Parsec

import Data.Char
import Data.Maybe (isJust)
import qualified Data.Map as Map (fromList, unions)
import Data.Either (partitionEithers)
import Control.Monad (liftM2, unless)
import qualified Control.Monad.Fail as Fail

type Annotations = [Annotation]
-- | Parses a comment
comment :: CharParser st ()
comment :: CharParser st ()
comment = CharParser st () -> CharParser st ()
forall tok st a. GenParser tok st a -> GenParser tok st a
try (CharParser st () -> CharParser st ())
-> CharParser st () -> CharParser st ()
forall a b. (a -> b) -> a -> b
$ do
    Char -> ParsecT [Char] st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char '#'
    ParsecT [Char] st Identity Char
-> CharParser st () -> ParsecT [Char] st Identity [Char]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
manyTill ParsecT [Char] st Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
anyChar CharParser st ()
forall st. GenParser Char st ()
newlineOrEof
    () -> CharParser st ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

-- | Skips whitespaces and comments
skips :: CharParser st a -> CharParser st a
skips :: CharParser st a -> CharParser st a
skips = (CharParser st a -> ParsecT [Char] st Identity () -> CharParser st a
forall (m :: * -> *) a b. Monad m => m a -> m b -> m a
<< ParsecT [Char] st Identity () -> ParsecT [Char] st Identity ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
skipMany (ParsecT [Char] st Identity Char -> ParsecT [Char] st Identity ()
forall (m :: * -> *) a. Monad m => m a -> m ()
forget ParsecT [Char] st Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
space ParsecT [Char] st Identity ()
-> ParsecT [Char] st Identity () -> ParsecT [Char] st Identity ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT [Char] st Identity ()
forall st. GenParser Char st ()
comment ParsecT [Char] st Identity ()
-> ParsecT [Char] st Identity () -> ParsecT [Char] st Identity ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT [Char] st Identity Annotation
-> ParsecT [Char] st Identity ()
forall (m :: * -> *) a. Monad m => m a -> m ()
forget ParsecT [Char] st Identity Annotation
forall st. GenParser Char st Annotation
commentLine ParsecT [Char] st Identity ()
-> ParsecT [Char] st Identity () -> ParsecT [Char] st Identity ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT [Char] st Identity () -> ParsecT [Char] st Identity ()
forall (m :: * -> *) a. Monad m => m a -> m ()
forget ParsecT [Char] st Identity ()
forall st. GenParser Char st ()
nestCommentOut ParsecT [Char] st Identity ()
-> [Char] -> ParsecT [Char] st Identity ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> [Char] -> ParsecT s u m a
<?> "comment"))


skipChar :: Char -> CharParser st ()
skipChar :: Char -> CharParser st ()
skipChar = ParsecT [Char] st Identity Char -> CharParser st ()
forall (m :: * -> *) a. Monad m => m a -> m ()
forget (ParsecT [Char] st Identity Char -> CharParser st ())
-> (Char -> ParsecT [Char] st Identity Char)
-> Char
-> CharParser st ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParsecT [Char] st Identity Char -> ParsecT [Char] st Identity Char
forall st a. CharParser st a -> CharParser st a
skips (ParsecT [Char] st Identity Char
 -> ParsecT [Char] st Identity Char)
-> (Char -> ParsecT [Char] st Identity Char)
-> Char
-> ParsecT [Char] st Identity Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ParsecT [Char] st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char


characters :: [Character]
characters :: [Character]
characters = [Character
forall a. Bounded a => a
minBound .. Character
forall a. Bounded a => a
maxBound]

-- | OWL and CASL structured keywords including 'andS' and 'notS'
owlKeywords :: [String]
owlKeywords :: [[Char]]
owlKeywords = [Char]
endS [Char] -> [[Char]] -> [[Char]]
forall a. a -> [a] -> [a]
: [Char]
notS [Char] -> [[Char]] -> [[Char]]
forall a. a -> [a] -> [a]
: [Char]
stringS [Char] -> [[Char]] -> [[Char]]
forall a. a -> [a] -> [a]
: (EntityType -> [Char]) -> [EntityType] -> [[Char]]
forall a b. (a -> b) -> [a] -> [b]
map EntityType -> [Char]
forall a. Show a => a -> [Char]
show [EntityType]
entityTypes
  [[Char]] -> [[Char]] -> [[Char]]
forall a. [a] -> [a] -> [a]
++ (Character -> [Char]) -> [Character] -> [[Char]]
forall a b. (a -> b) -> [a] -> [b]
map Character -> [Char]
forall a. Show a => a -> [Char]
show [Character]
characters [[Char]] -> [[Char]] -> [[Char]]
forall a. [a] -> [a] -> [a]
++ [[Char]]
keywords [[Char]] -> [[Char]] -> [[Char]]
forall a. [a] -> [a] -> [a]
++ [[Char]]
criticalKeywords

ncNameStart :: Char -> Bool
ncNameStart :: Char -> Bool
ncNameStart c :: Char
c = Char -> Bool
isAlpha Char
c Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== '_'

-- | rfc3987 plus '+' from scheme (scheme does not allow the dots)
ncNameChar :: Char -> Bool
ncNameChar :: Char -> Bool
ncNameChar c :: Char
c = Char -> Bool
isAlphaNum Char
c Bool -> Bool -> Bool
|| Char -> [Char] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
elem Char
c ".+-_\183"

prefix :: CharParser st String
prefix :: CharParser st [Char]
prefix = (Char -> Bool) -> ParsecT [Char] st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
(Char -> Bool) -> ParsecT s u m Char
satisfy Char -> Bool
ncNameStart ParsecT [Char] st Identity Char
-> CharParser st [Char] -> CharParser st [Char]
forall (m :: * -> *) a. Monad m => m a -> m [a] -> m [a]
<:> ParsecT [Char] st Identity Char -> CharParser st [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ((Char -> Bool) -> ParsecT [Char] st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
(Char -> Bool) -> ParsecT s u m Char
satisfy Char -> Bool
ncNameChar)


-- | parse zero or at most n consecutive arguments
atMost :: Int -> GenParser tok st a -> GenParser tok st [a]
atMost :: Int -> GenParser tok st a -> GenParser tok st [a]
atMost n :: Int
n p :: GenParser tok st a
p = if Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= 0 then [a] -> GenParser tok st [a]
forall (m :: * -> *) a. Monad m => a -> m a
return [] else
     GenParser tok st a
p GenParser tok st a -> GenParser tok st [a] -> GenParser tok st [a]
forall (m :: * -> *) a. Monad m => m a -> m [a] -> m [a]
<:> Int -> GenParser tok st a -> GenParser tok st [a]
forall tok st a. Int -> GenParser tok st a -> GenParser tok st [a]
atMost (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1) GenParser tok st a
p GenParser tok st [a]
-> GenParser tok st [a] -> GenParser tok st [a]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> [a] -> GenParser tok st [a]
forall (m :: * -> *) a. Monad m => a -> m a
return []

-- | parse at least one but at most n conse
atMost1 :: Int -> GenParser tok st a -> GenParser tok st [a]
atMost1 :: Int -> GenParser tok st a -> GenParser tok st [a]
atMost1 n :: Int
n p :: GenParser tok st a
p = GenParser tok st a
p GenParser tok st a -> GenParser tok st [a] -> GenParser tok st [a]
forall (m :: * -> *) a. Monad m => m a -> m [a] -> m [a]
<:> Int -> GenParser tok st a -> GenParser tok st [a]
forall tok st a. Int -> GenParser tok st a -> GenParser tok st [a]
atMost (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1) GenParser tok st a
p




uriQ :: CharParser st IRI
-- uriQ = fullIri <|> abbrIri
uriQ :: CharParser st IRI
uriQ = CharParser st IRI
forall st. IRIParser st IRI
iriCurie

fullIri :: CharParser st IRI
fullIri :: CharParser st IRI
fullIri = CharParser st IRI -> CharParser st IRI
forall st. IRIParser st IRI -> IRIParser st IRI
angles CharParser st IRI
forall st. IRIParser st IRI
iriParser

expUriP :: GA.PrefixMap -> CharParser st IRI
expUriP :: PrefixMap -> CharParser st IRI
expUriP pm :: PrefixMap
pm = CharParser st IRI
forall st. IRIParser st IRI
uriP CharParser st IRI
-> (IRI -> CharParser st IRI) -> CharParser st IRI
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= IRI -> CharParser st IRI
forall (m :: * -> *) a. Monad m => a -> m a
return (IRI -> CharParser st IRI)
-> (IRI -> IRI) -> IRI -> CharParser st IRI
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrefixMap -> IRI -> IRI
expandIRI PrefixMap
pm

uriP :: CharParser st IRI
uriP :: CharParser st IRI
uriP = CharParser st IRI -> CharParser st IRI
forall st a. CharParser st a -> CharParser st a
skips (CharParser st IRI -> CharParser st IRI)
-> CharParser st IRI -> CharParser st IRI
forall a b. (a -> b) -> a -> b
$ CharParser st IRI -> CharParser st IRI
forall tok st a. GenParser tok st a -> GenParser tok st a
try (CharParser st IRI -> CharParser st IRI)
-> CharParser st IRI -> CharParser st IRI
forall a b. (a -> b) -> a -> b
$ do
  Maybe Char
colonM <- ParsecT [Char] st Identity Char
-> ParsecT [Char] st Identity (Maybe Char)
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m (Maybe a)
optionMaybe (ParsecT [Char] st Identity Char
 -> ParsecT [Char] st Identity (Maybe Char))
-> (ParsecT [Char] st Identity Char
    -> ParsecT [Char] st Identity Char)
-> ParsecT [Char] st Identity Char
-> ParsecT [Char] st Identity (Maybe Char)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParsecT [Char] st Identity Char -> ParsecT [Char] st Identity Char
forall tok st a. GenParser tok st a -> GenParser tok st a
try (ParsecT [Char] st Identity Char
 -> ParsecT [Char] st Identity Char)
-> (ParsecT [Char] st Identity Char
    -> ParsecT [Char] st Identity Char)
-> ParsecT [Char] st Identity Char
-> ParsecT [Char] st Identity Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParsecT [Char] st Identity Char -> ParsecT [Char] st Identity Char
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead (ParsecT [Char] st Identity Char
 -> ParsecT [Char] st Identity (Maybe Char))
-> ParsecT [Char] st Identity Char
-> ParsecT [Char] st Identity (Maybe Char)
forall a b. (a -> b) -> a -> b
$ Char -> ParsecT [Char] st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char ':'
  (IRI -> [Char])
-> CharParser st IRI -> (IRI -> Bool) -> CharParser st IRI
forall a tok st.
(a -> [Char])
-> GenParser tok st a -> (a -> Bool) -> GenParser tok st a
checkWithUsing (\i :: IRI
i -> "keyword \"" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ IRI -> [Char]
showIRI IRI
i [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ "\"") CharParser st IRI
forall st. IRIParser st IRI
uriQ ((IRI -> Bool) -> CharParser st IRI)
-> (IRI -> Bool) -> CharParser st IRI
forall a b. (a -> b) -> a -> b
$ \ q :: IRI
q -> let p :: [Char]
p = IRI -> [Char]
prefixName IRI
q in
    if Bool -> Bool
not (IRI -> Bool
isAbbrev IRI
q) Bool -> Bool -> Bool
|| Maybe Char -> Bool
forall a. Maybe a -> Bool
isJust Maybe Char
colonM then Bool
True
    else if [Char] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Char]
p then [Char] -> [[Char]] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
notElem (IRI -> [Char]
iFragment IRI
q) [[Char]]
owlKeywords
    else [Char] -> [[Char]] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
notElem [Char]
p ([[Char]] -> Bool) -> [[Char]] -> Bool
forall a b. (a -> b) -> a -> b
$ ([Char] -> [Char]) -> [[Char]] -> [[Char]]
forall a b. (a -> b) -> [a] -> [b]
map ((Char -> Bool) -> [Char] -> [Char]
forall a. (a -> Bool) -> [a] -> [a]
takeWhile (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
/= ':'))
        ([[Char]] -> [[Char]]) -> [[Char]] -> [[Char]]
forall a b. (a -> b) -> a -> b
$ [[Char]]
colonKeywords
        [[Char]] -> [[Char]] -> [[Char]]
forall a. [a] -> [a] -> [a]
++ [ EquivOrDisjoint -> [Char]
forall a. Show a => a -> [Char]
show EquivOrDisjoint
d [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
e | EquivOrDisjoint
d <- [EquivOrDisjoint]
equivOrDisjointL, [Char]
e <- [[Char]
classesC, [Char]
propertiesC]]


datatypeKey :: GA.PrefixMap -> CharParser st IRI
datatypeKey :: PrefixMap -> CharParser st IRI
datatypeKey pm :: PrefixMap
pm = [Char] -> IRI
mkIRI ([Char] -> IRI)
-> ParsecT [Char] st Identity [Char] -> CharParser st IRI
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ([ParsecT [Char] st Identity [Char]]
-> ParsecT [Char] st Identity [Char]
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice ([ParsecT [Char] st Identity [Char]]
 -> ParsecT [Char] st Identity [Char])
-> [ParsecT [Char] st Identity [Char]]
-> ParsecT [Char] st Identity [Char]
forall a b. (a -> b) -> a -> b
$ ([Char] -> ParsecT [Char] st Identity [Char])
-> [[Char]] -> [ParsecT [Char] st Identity [Char]]
forall a b. (a -> b) -> [a] -> [b]
map (ParsecT [Char] st Identity [Char]
-> ParsecT [Char] st Identity [Char]
forall tok st a. GenParser tok st a -> GenParser tok st a
try (ParsecT [Char] st Identity [Char]
 -> ParsecT [Char] st Identity [Char])
-> ([Char] -> ParsecT [Char] st Identity [Char])
-> [Char]
-> ParsecT [Char] st Identity [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> ParsecT [Char] st Identity [Char]
forall st. [Char] -> CharParser st [Char]
keyword) [[Char]]
datatypeKeys) CharParser st IRI
-> (IRI -> CharParser st IRI) -> CharParser st IRI
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=
    IRI -> CharParser st IRI
forall (m :: * -> *) a. Monad m => a -> m a
return (IRI -> CharParser st IRI)
-> (IRI -> IRI) -> IRI -> CharParser st IRI
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrefixMap -> IRI -> IRI
expandIRI PrefixMap
pm (IRI -> IRI) -> (IRI -> IRI) -> IRI -> IRI
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> IRI -> IRI
setPrefix "xsd"
  
dataPropertyExpr :: GA.PrefixMap -> CharParser st DataPropertyExpression
dataPropertyExpr :: PrefixMap -> CharParser st IRI
dataPropertyExpr = PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
expUriP

datatypeUri :: GA.PrefixMap -> CharParser st IRI
datatypeUri :: PrefixMap -> CharParser st IRI
datatypeUri pm :: PrefixMap
pm = PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
datatypeKey PrefixMap
pm CharParser st IRI -> CharParser st IRI -> CharParser st IRI
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
expUriP PrefixMap
pm

optSign :: CharParser st Bool
optSign :: CharParser st Bool
optSign = Bool -> CharParser st Bool -> CharParser st Bool
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Bool
False (CharParser st Bool -> CharParser st Bool)
-> CharParser st Bool -> CharParser st Bool
forall a b. (a -> b) -> a -> b
$ (Char -> Bool)
-> ParsecT [Char] st Identity Char -> CharParser st Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== '-') ([Char] -> ParsecT [Char] st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m Char
oneOf "+-")

postDecimal :: CharParser st NNInt
postDecimal :: CharParser st NNInt
postDecimal = Char -> ParsecT [Char] st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char '.' ParsecT [Char] st Identity Char
-> CharParser st NNInt -> CharParser st NNInt
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> NNInt -> CharParser st NNInt -> CharParser st NNInt
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option NNInt
zeroNNInt CharParser st NNInt
forall st. CharParser st NNInt
getNNInt

getNNInt :: CharParser st NNInt
getNNInt :: CharParser st NNInt
getNNInt = ([Char] -> NNInt)
-> ParsecT [Char] st Identity [Char] -> CharParser st NNInt
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ([Int] -> NNInt
NNInt ([Int] -> NNInt) -> ([Char] -> [Int]) -> [Char] -> NNInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Int) -> [Char] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map Char -> Int
digitToInt) ParsecT [Char] st Identity [Char]
forall st. CharParser st [Char]
getNumber

intLit :: CharParser st IntLit
intLit :: CharParser st IntLit
intLit = do
  Bool
b <- CharParser st Bool
forall st. CharParser st Bool
optSign
  NNInt
n <- CharParser st NNInt
forall st. CharParser st NNInt
getNNInt
  IntLit -> CharParser st IntLit
forall (m :: * -> *) a. Monad m => a -> m a
return (IntLit -> CharParser st IntLit) -> IntLit -> CharParser st IntLit
forall a b. (a -> b) -> a -> b
$ Bool -> NNInt -> IntLit
negNNInt Bool
b NNInt
n

booleanLit :: GA.PrefixMap -> CharParser st Literal
booleanLit :: PrefixMap -> CharParser st Literal
booleanLit pm :: PrefixMap
pm = do
  [Char]
val <- CharParser st [Char] -> CharParser st [Char]
forall st a. CharParser st a -> CharParser st a
skips (CharParser st [Char] -> CharParser st [Char])
-> CharParser st [Char] -> CharParser st [Char]
forall a b. (a -> b) -> a -> b
$ CharParser st [Char] -> CharParser st [Char]
forall tok st a. GenParser tok st a -> GenParser tok st a
try (CharParser st [Char] -> CharParser st [Char])
-> CharParser st [Char] -> CharParser st [Char]
forall a b. (a -> b) -> a -> b
$ [CharParser st [Char]] -> CharParser st [Char]
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice [[Char] -> CharParser st [Char]
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m [Char]
string [Char]
trueS, [Char] -> CharParser st [Char]
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m [Char]
string [Char]
falseS]
  let typed :: TypedOrUntyped
typed = IRI -> TypedOrUntyped
Typed (PrefixMap -> IRI -> IRI
expandIRI PrefixMap
pm (IRI -> IRI) -> IRI -> IRI
forall a b. (a -> b) -> a -> b
$ IRI
nullIRI { iriPath :: Id
iriPath = [Char] -> Id
stringToId [Char]
booleanS,  iFragment :: [Char]
iFragment = [Char]
booleanS, isAbbrev :: Bool
isAbbrev = Bool
True, prefixName :: [Char]
prefixName = "xsd"})
  Literal -> CharParser st Literal
forall (m :: * -> *) a. Monad m => a -> m a
return (Literal -> CharParser st Literal)
-> Literal -> CharParser st Literal
forall a b. (a -> b) -> a -> b
$ [Char] -> TypedOrUntyped -> Literal
Literal [Char]
val TypedOrUntyped
typed

decimalLit :: CharParser st DecLit
decimalLit :: CharParser st DecLit
decimalLit = (IntLit -> NNInt -> DecLit)
-> ParsecT [Char] st Identity IntLit
-> ParsecT [Char] st Identity NNInt
-> CharParser st DecLit
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 IntLit -> NNInt -> DecLit
DecLit ParsecT [Char] st Identity IntLit
forall st. CharParser st IntLit
intLit (ParsecT [Char] st Identity NNInt -> CharParser st DecLit)
-> ParsecT [Char] st Identity NNInt -> CharParser st DecLit
forall a b. (a -> b) -> a -> b
$ NNInt
-> ParsecT [Char] st Identity NNInt
-> ParsecT [Char] st Identity NNInt
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option NNInt
zeroNNInt ParsecT [Char] st Identity NNInt
forall st. CharParser st NNInt
postDecimal

floatDecimal :: CharParser st DecLit
floatDecimal :: CharParser st DecLit
floatDecimal = do
    NNInt
n <- CharParser st NNInt
forall st. CharParser st NNInt
getNNInt
    NNInt
f <- NNInt -> CharParser st NNInt -> CharParser st NNInt
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option NNInt
zeroNNInt CharParser st NNInt
forall st. CharParser st NNInt
postDecimal
    DecLit -> CharParser st DecLit
forall (m :: * -> *) a. Monad m => a -> m a
return (DecLit -> CharParser st DecLit) -> DecLit -> CharParser st DecLit
forall a b. (a -> b) -> a -> b
$ IntLit -> NNInt -> DecLit
DecLit (Bool -> NNInt -> IntLit
negNNInt Bool
False NNInt
n) NNInt
f
   CharParser st DecLit
-> CharParser st DecLit -> CharParser st DecLit
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    NNInt
n <- CharParser st NNInt
forall st. CharParser st NNInt
postDecimal
    DecLit -> CharParser st DecLit
forall (m :: * -> *) a. Monad m => a -> m a
return (DecLit -> CharParser st DecLit) -> DecLit -> CharParser st DecLit
forall a b. (a -> b) -> a -> b
$ IntLit -> NNInt -> DecLit
DecLit IntLit
zeroInt NNInt
n

floatingPointLit :: CharParser st FloatLit
floatingPointLit :: CharParser st FloatLit
floatingPointLit = do
   Bool
b <- CharParser st Bool
forall st. CharParser st Bool
optSign
   DecLit
d <- CharParser st DecLit
forall st. CharParser st DecLit
floatDecimal
   IntLit
i <- IntLit
-> ParsecT [Char] st Identity IntLit
-> ParsecT [Char] st Identity IntLit
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option IntLit
zeroInt ([Char] -> ParsecT [Char] st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m Char
oneOf "eE" ParsecT [Char] st Identity Char
-> ParsecT [Char] st Identity IntLit
-> ParsecT [Char] st Identity IntLit
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT [Char] st Identity IntLit
forall st. CharParser st IntLit
intLit)
   ParsecT [Char] st Identity Char
-> ParsecT [Char] st Identity (Maybe Char)
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m (Maybe a)
optionMaybe (ParsecT [Char] st Identity Char
 -> ParsecT [Char] st Identity (Maybe Char))
-> ParsecT [Char] st Identity Char
-> ParsecT [Char] st Identity (Maybe Char)
forall a b. (a -> b) -> a -> b
$ [Char] -> ParsecT [Char] st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m Char
oneOf "fF"
   FloatLit -> CharParser st FloatLit
forall (m :: * -> *) a. Monad m => a -> m a
return (FloatLit -> CharParser st FloatLit)
-> FloatLit -> CharParser st FloatLit
forall a b. (a -> b) -> a -> b
$ DecLit -> IntLit -> FloatLit
FloatLit (Bool -> DecLit -> DecLit
negDec Bool
b DecLit
d) IntLit
i

languageTag :: CharParser st String
languageTag :: CharParser st [Char]
languageTag = Int -> GenParser Char st Char -> CharParser st [Char]
forall tok st a. Int -> GenParser tok st a -> GenParser tok st [a]
atMost1 4 GenParser Char st Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
letter
  CharParser st [Char]
-> CharParser st [Char] -> CharParser st [Char]
forall (m :: * -> *) a. Monad m => m [a] -> m [a] -> m [a]
<++> ParsecT [Char] st Identity [[Char]] -> CharParser st [Char]
forall (m :: * -> *) a. Monad m => m [[a]] -> m [a]
flat (CharParser st [Char] -> ParsecT [Char] st Identity [[Char]]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (CharParser st [Char] -> ParsecT [Char] st Identity [[Char]])
-> CharParser st [Char] -> ParsecT [Char] st Identity [[Char]]
forall a b. (a -> b) -> a -> b
$ Char -> GenParser Char st Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char '-' GenParser Char st Char
-> CharParser st [Char] -> CharParser st [Char]
forall (m :: * -> *) a. Monad m => m a -> m [a] -> m [a]
<:> Int -> GenParser Char st Char -> CharParser st [Char]
forall tok st a. Int -> GenParser tok st a -> GenParser tok st [a]
atMost1 8 GenParser Char st Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
alphaNum)

rmQuotes :: String -> String
rmQuotes :: [Char] -> [Char]
rmQuotes s :: [Char]
s = case [Char]
s of
  _ : tl :: [Char]
tl@(_ : _) -> [Char] -> [Char]
forall a. [a] -> [a]
init [Char]
tl
  _ -> [Char] -> [Char]
forall a. HasCallStack => [Char] -> a
error "rmQuotes"

charOrEscaped :: CharParser st Char
charOrEscaped :: CharParser st Char
charOrEscaped = do
    Char
c <- CharParser st Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
anyChar
    if Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== '\\' then Char -> CharParser st Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char '\\' CharParser st Char -> CharParser st Char -> CharParser st Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Char -> CharParser st Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char '"' else Char -> CharParser st Char
forall (m :: * -> *) a. Monad m => a -> m a
return Char
c

stringLiteral :: GA.PrefixMap -> CharParser st Literal
stringLiteral :: PrefixMap -> CharParser st Literal
stringLiteral pm :: PrefixMap
pm = do
  [Char]
s <- Char -> ParsecT [Char] st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char '"' ParsecT [Char] st Identity Char
-> ParsecT [Char] st Identity [Char]
-> ParsecT [Char] st Identity [Char]
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT [Char] st Identity Char
-> ParsecT [Char] st Identity Char
-> ParsecT [Char] st Identity [Char]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
manyTill ParsecT [Char] st Identity Char
forall st. CharParser st Char
charOrEscaped (Char -> ParsecT [Char] st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char '"')
  do
      [Char] -> ParsecT [Char] st Identity [Char]
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m [Char]
string [Char]
cTypeS
      IRI
d <- PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
datatypeUri PrefixMap
pm
      Literal -> CharParser st Literal
forall (m :: * -> *) a. Monad m => a -> m a
return (Literal -> CharParser st Literal)
-> Literal -> CharParser st Literal
forall a b. (a -> b) -> a -> b
$ [Char] -> TypedOrUntyped -> Literal
Literal [Char]
s (TypedOrUntyped -> Literal) -> TypedOrUntyped -> Literal
forall a b. (a -> b) -> a -> b
$ IRI -> TypedOrUntyped
Typed IRI
d
    CharParser st Literal
-> CharParser st Literal -> CharParser st Literal
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
        Maybe [Char]
t <- CharParser st (Maybe [Char]) -> CharParser st (Maybe [Char])
forall st a. CharParser st a -> CharParser st a
skips (CharParser st (Maybe [Char]) -> CharParser st (Maybe [Char]))
-> CharParser st (Maybe [Char]) -> CharParser st (Maybe [Char])
forall a b. (a -> b) -> a -> b
$ ParsecT [Char] st Identity [Char] -> CharParser st (Maybe [Char])
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m (Maybe a)
optionMaybe ([Char] -> ParsecT [Char] st Identity [Char]
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m [Char]
string [Char]
asP ParsecT [Char] st Identity [Char]
-> ParsecT [Char] st Identity [Char]
-> ParsecT [Char] st Identity [Char]
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT [Char] st Identity [Char]
forall st. CharParser st [Char]
languageTag)
        Literal -> CharParser st Literal
forall (m :: * -> *) a. Monad m => a -> m a
return (Literal -> CharParser st Literal)
-> Literal -> CharParser st Literal
forall a b. (a -> b) -> a -> b
$ [Char] -> TypedOrUntyped -> Literal
Literal [Char]
s (TypedOrUntyped -> Literal) -> TypedOrUntyped -> Literal
forall a b. (a -> b) -> a -> b
$ Maybe [Char] -> TypedOrUntyped
Untyped Maybe [Char]
t

literal :: GA.PrefixMap -> CharParser st Literal
literal :: PrefixMap -> CharParser st Literal
literal pm :: PrefixMap
pm = do
    FloatLit
f <- CharParser st FloatLit -> CharParser st FloatLit
forall st a. CharParser st a -> CharParser st a
skips (CharParser st FloatLit -> CharParser st FloatLit)
-> CharParser st FloatLit -> CharParser st FloatLit
forall a b. (a -> b) -> a -> b
$ CharParser st FloatLit -> CharParser st FloatLit
forall tok st a. GenParser tok st a -> GenParser tok st a
try CharParser st FloatLit
forall st. CharParser st FloatLit
floatingPointLit
         CharParser st FloatLit
-> CharParser st FloatLit -> CharParser st FloatLit
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (DecLit -> FloatLit)
-> ParsecT [Char] st Identity DecLit -> CharParser st FloatLit
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap DecLit -> FloatLit
decToFloat ParsecT [Char] st Identity DecLit
forall st. CharParser st DecLit
decimalLit
    Literal -> CharParser st Literal
forall (m :: * -> *) a. Monad m => a -> m a
return (Literal -> CharParser st Literal)
-> Literal -> CharParser st Literal
forall a b. (a -> b) -> a -> b
$ FloatLit -> Literal
NumberLit FloatLit
f
  CharParser st Literal
-> CharParser st Literal -> CharParser st Literal
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> CharParser st Literal -> CharParser st Literal
forall st a. CharParser st a -> CharParser st a
skips (PrefixMap -> CharParser st Literal
forall st. PrefixMap -> CharParser st Literal
stringLiteral PrefixMap
pm)
  CharParser st Literal
-> CharParser st Literal -> CharParser st Literal
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> PrefixMap -> CharParser st Literal
forall st. PrefixMap -> CharParser st Literal
booleanLit PrefixMap
pm
  CharParser st Literal -> [Char] -> CharParser st Literal
forall s u (m :: * -> *) a.
ParsecT s u m a -> [Char] -> ParsecT s u m a
<?> "Literal"
-- * description

owlClassUri :: GA.PrefixMap -> CharParser st IRI
owlClassUri :: PrefixMap -> CharParser st IRI
owlClassUri = PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
expUriP

individualUri :: GA.PrefixMap -> CharParser st IRI
individualUri :: PrefixMap -> CharParser st IRI
individualUri = PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
expUriP

individual :: GA.PrefixMap -> CharParser st Individual
individual :: PrefixMap -> CharParser st IRI
individual pm :: PrefixMap
pm = do
    IRI
i <- PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
individualUri PrefixMap
pm
    IRI -> CharParser st IRI
forall (m :: * -> *) a. Monad m => a -> m a
return (IRI -> CharParser st IRI) -> IRI -> CharParser st IRI
forall a b. (a -> b) -> a -> b
$ if IRI -> [Char]
prefixName IRI
i [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== "_" then IRI
i {isBlankNode :: Bool
isBlankNode = Bool
True}
                                    else IRI
i


parensP :: CharParser st a -> CharParser st a
parensP :: CharParser st a -> CharParser st a
parensP = ParsecT [Char] st Identity ()
-> ParsecT [Char] st Identity ()
-> CharParser st a
-> CharParser st a
forall s (m :: * -> *) t u open close a.
Stream s m t =>
ParsecT s u m open
-> ParsecT s u m close -> ParsecT s u m a -> ParsecT s u m a
between (Char -> ParsecT [Char] st Identity ()
forall st. Char -> CharParser st ()
skipChar '(') (Char -> ParsecT [Char] st Identity ()
forall st. Char -> CharParser st ()
skipChar ')')

optParensP :: CharParser st a -> CharParser st a
optParensP :: CharParser st a -> CharParser st a
optParensP p :: CharParser st a
p = CharParser st a -> CharParser st a
forall st a. CharParser st a -> CharParser st a
parensP CharParser st a
p CharParser st a -> CharParser st a -> CharParser st a
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> CharParser st a
p

bracesP :: CharParser st a -> CharParser st a
bracesP :: CharParser st a -> CharParser st a
bracesP = ParsecT [Char] st Identity ()
-> ParsecT [Char] st Identity ()
-> CharParser st a
-> CharParser st a
forall s (m :: * -> *) t u open close a.
Stream s m t =>
ParsecT s u m open
-> ParsecT s u m close -> ParsecT s u m a -> ParsecT s u m a
between (Char -> ParsecT [Char] st Identity ()
forall st. Char -> CharParser st ()
skipChar '{') (Char -> ParsecT [Char] st Identity ()
forall st. Char -> CharParser st ()
skipChar '}')

bracketsP :: CharParser st a -> CharParser st a
bracketsP :: CharParser st a -> CharParser st a
bracketsP = ParsecT [Char] st Identity ()
-> ParsecT [Char] st Identity ()
-> CharParser st a
-> CharParser st a
forall s (m :: * -> *) t u open close a.
Stream s m t =>
ParsecT s u m open
-> ParsecT s u m close -> ParsecT s u m a -> ParsecT s u m a
between (Char -> ParsecT [Char] st Identity ()
forall st. Char -> CharParser st ()
skipChar '[') (Char -> ParsecT [Char] st Identity ()
forall st. Char -> CharParser st ()
skipChar ']')

commaP :: CharParser st ()
commaP :: CharParser st ()
commaP = Char -> CharParser st ()
forall st. Char -> CharParser st ()
skipChar ','

sepByComma :: CharParser st a -> CharParser st [a]
sepByComma :: CharParser st a -> CharParser st [a]
sepByComma p :: CharParser st a
p = CharParser st a
-> ParsecT [Char] st Identity () -> CharParser st [a]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
sepBy1 CharParser st a
p (ParsecT [Char] st Identity () -> CharParser st [a])
-> ParsecT [Char] st Identity () -> CharParser st [a]
forall a b. (a -> b) -> a -> b
$ ParsecT [Char] st Identity () -> ParsecT [Char] st Identity ()
forall tok st a. GenParser tok st a -> GenParser tok st a
try ParsecT [Char] st Identity ()
forall st. GenParser Char st ()
commaP

-- | plain string parser with skip
pkeyword :: String -> CharParser st ()
pkeyword :: [Char] -> CharParser st ()
pkeyword s :: [Char]
s = ParsecT [Char] st Identity [Char] -> CharParser st ()
forall (m :: * -> *) a. Monad m => m a -> m ()
forget (ParsecT [Char] st Identity [Char] -> CharParser st ())
-> ParsecT [Char] st Identity [Char] -> CharParser st ()
forall a b. (a -> b) -> a -> b
$ [Char] -> CharParser st Char -> ParsecT [Char] st Identity [Char]
forall st. [Char] -> CharParser st Char -> CharParser st [Char]
keywordNotFollowedBy [Char]
s (CharParser st Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
alphaNum CharParser st Char -> CharParser st Char -> CharParser st Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Char -> CharParser st Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char '/')

keywordNotFollowedBy :: String -> CharParser st Char -> CharParser st String
keywordNotFollowedBy :: [Char] -> CharParser st Char -> CharParser st [Char]
keywordNotFollowedBy s :: [Char]
s c :: CharParser st Char
c = CharParser st [Char] -> CharParser st [Char]
forall st a. CharParser st a -> CharParser st a
skips (CharParser st [Char] -> CharParser st [Char])
-> CharParser st [Char] -> CharParser st [Char]
forall a b. (a -> b) -> a -> b
$ CharParser st [Char] -> CharParser st [Char]
forall tok st a. GenParser tok st a -> GenParser tok st a
try (CharParser st [Char] -> CharParser st [Char])
-> CharParser st [Char] -> CharParser st [Char]
forall a b. (a -> b) -> a -> b
$ [Char] -> CharParser st [Char]
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m [Char]
string [Char]
s CharParser st [Char]
-> ParsecT [Char] st Identity () -> CharParser st [Char]
forall (m :: * -> *) a b. Monad m => m a -> m b -> m a
<< CharParser st Char -> ParsecT [Char] st Identity ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy CharParser st Char
c

-- | keyword not followed by any alphanum
keyword :: String -> CharParser st String
keyword :: [Char] -> CharParser st [Char]
keyword s :: [Char]
s = [Char] -> CharParser st Char -> CharParser st [Char]
forall st. [Char] -> CharParser st Char -> CharParser st [Char]
keywordNotFollowedBy [Char]
s (CharParser st Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
alphaNum CharParser st Char -> CharParser st Char -> CharParser st Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Char -> CharParser st Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char '_')

-- base OWLClass excluded
atomic :: GA.PrefixMap -> CharParser st ClassExpression
atomic :: PrefixMap -> CharParser st ClassExpression
atomic pm :: PrefixMap
pm = (CharParser st ClassExpression -> CharParser st ClassExpression
forall st a. CharParser st a -> CharParser st a
parensP (CharParser st ClassExpression -> CharParser st ClassExpression)
-> CharParser st ClassExpression -> CharParser st ClassExpression
forall a b. (a -> b) -> a -> b
$ PrefixMap -> CharParser st ClassExpression
forall st. PrefixMap -> CharParser st ClassExpression
description PrefixMap
pm)
  CharParser st ClassExpression
-> CharParser st ClassExpression -> CharParser st ClassExpression
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> [IRI] -> ClassExpression
ObjectOneOf ([IRI] -> ClassExpression)
-> ParsecT [Char] st Identity [IRI]
-> CharParser st ClassExpression
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ParsecT [Char] st Identity [IRI]
-> ParsecT [Char] st Identity [IRI]
forall st a. CharParser st a -> CharParser st a
bracesP (ParsecT [Char] st Identity [IRI]
 -> ParsecT [Char] st Identity [IRI])
-> ParsecT [Char] st Identity [IRI]
-> ParsecT [Char] st Identity [IRI]
forall a b. (a -> b) -> a -> b
$ CharParser st IRI -> ParsecT [Char] st Identity [IRI]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (CharParser st IRI -> ParsecT [Char] st Identity [IRI])
-> CharParser st IRI -> ParsecT [Char] st Identity [IRI]
forall a b. (a -> b) -> a -> b
$ PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
individual PrefixMap
pm)

objectPropertyExpr :: GA.PrefixMap -> CharParser st ObjectPropertyExpression
objectPropertyExpr :: PrefixMap -> CharParser st ObjectPropertyExpression
objectPropertyExpr pm :: PrefixMap
pm = 
  -- parenthesis around objectPropertyExpressions aren't defined in the standard but used by the Java OWL API
  do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
inverseS
    ObjectPropertyExpression -> ObjectPropertyExpression
ObjectInverseOf (ObjectPropertyExpression -> ObjectPropertyExpression)
-> CharParser st ObjectPropertyExpression
-> CharParser st ObjectPropertyExpression
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CharParser st ObjectPropertyExpression
-> CharParser st ObjectPropertyExpression
forall st a. CharParser st a -> CharParser st a
optParensP (PrefixMap -> CharParser st ObjectPropertyExpression
forall st. PrefixMap -> CharParser st ObjectPropertyExpression
objectPropertyExpr PrefixMap
pm)
  CharParser st ObjectPropertyExpression
-> CharParser st ObjectPropertyExpression
-> CharParser st ObjectPropertyExpression
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> IRI -> ObjectPropertyExpression
ObjectProp (IRI -> ObjectPropertyExpression)
-> ParsecT [Char] st Identity IRI
-> CharParser st ObjectPropertyExpression
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (PrefixMap -> ParsecT [Char] st Identity IRI
forall st. PrefixMap -> CharParser st IRI
expUriP PrefixMap
pm)

parseProperties :: GA.PrefixMap -> CharParser st ([ObjectPropertyExpression], [DataPropertyExpression])
parseProperties :: PrefixMap -> CharParser st ([ObjectPropertyExpression], [IRI])
parseProperties pm :: PrefixMap
pm = do
  [Either ObjectPropertyExpression IRI]
props <- CharParser st (Either ObjectPropertyExpression IRI)
-> CharParser st [Either ObjectPropertyExpression IRI]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (CharParser st (Either ObjectPropertyExpression IRI)
 -> CharParser st [Either ObjectPropertyExpression IRI])
-> CharParser st (Either ObjectPropertyExpression IRI)
-> CharParser st [Either ObjectPropertyExpression IRI]
forall a b. (a -> b) -> a -> b
$ [CharParser st (Either ObjectPropertyExpression IRI)]
-> CharParser st (Either ObjectPropertyExpression IRI)
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice [PrefixMap -> CharParser st ObjectPropertyExpression
forall st. PrefixMap -> CharParser st ObjectPropertyExpression
objectPropertyExpr PrefixMap
pm CharParser st ObjectPropertyExpression
-> (ObjectPropertyExpression
    -> CharParser st (Either ObjectPropertyExpression IRI))
-> CharParser st (Either ObjectPropertyExpression IRI)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Either ObjectPropertyExpression IRI
-> CharParser st (Either ObjectPropertyExpression IRI)
forall (m :: * -> *) a. Monad m => a -> m a
return (Either ObjectPropertyExpression IRI
 -> CharParser st (Either ObjectPropertyExpression IRI))
-> (ObjectPropertyExpression
    -> Either ObjectPropertyExpression IRI)
-> ObjectPropertyExpression
-> CharParser st (Either ObjectPropertyExpression IRI)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ObjectPropertyExpression -> Either ObjectPropertyExpression IRI
forall a b. a -> Either a b
Left, PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
expUriP PrefixMap
pm CharParser st IRI
-> (IRI -> CharParser st (Either ObjectPropertyExpression IRI))
-> CharParser st (Either ObjectPropertyExpression IRI)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Either ObjectPropertyExpression IRI
-> CharParser st (Either ObjectPropertyExpression IRI)
forall (m :: * -> *) a. Monad m => a -> m a
return (Either ObjectPropertyExpression IRI
 -> CharParser st (Either ObjectPropertyExpression IRI))
-> (IRI -> Either ObjectPropertyExpression IRI)
-> IRI
-> CharParser st (Either ObjectPropertyExpression IRI)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IRI -> Either ObjectPropertyExpression IRI
forall a b. b -> Either a b
Right]
  ([ObjectPropertyExpression], [IRI])
-> CharParser st ([ObjectPropertyExpression], [IRI])
forall (m :: * -> *) a. Monad m => a -> m a
return (([ObjectPropertyExpression], [IRI])
 -> CharParser st ([ObjectPropertyExpression], [IRI]))
-> ([ObjectPropertyExpression], [IRI])
-> CharParser st ([ObjectPropertyExpression], [IRI])
forall a b. (a -> b) -> a -> b
$ [Either ObjectPropertyExpression IRI]
-> ([ObjectPropertyExpression], [IRI])
forall a b. [Either a b] -> ([a], [b])
partitionEithers [Either ObjectPropertyExpression IRI]
props


-- creating the facet-value pairs
facetValuePair :: GA.PrefixMap -> CharParser st (ConstrainingFacet, RestrictionValue)
facetValuePair :: PrefixMap -> CharParser st (IRI, Literal)
facetValuePair pm :: PrefixMap
pm = do
  DatatypeFacet
df <- [ParsecT [Char] st Identity DatatypeFacet]
-> ParsecT [Char] st Identity DatatypeFacet
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice ([ParsecT [Char] st Identity DatatypeFacet]
 -> ParsecT [Char] st Identity DatatypeFacet)
-> [ParsecT [Char] st Identity DatatypeFacet]
-> ParsecT [Char] st Identity DatatypeFacet
forall a b. (a -> b) -> a -> b
$ (DatatypeFacet -> ParsecT [Char] st Identity DatatypeFacet)
-> [DatatypeFacet] -> [ParsecT [Char] st Identity DatatypeFacet]
forall a b. (a -> b) -> [a] -> [b]
map (\ f :: DatatypeFacet
f -> [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword (DatatypeFacet -> [Char]
showFacet DatatypeFacet
f) CharParser st ()
-> ParsecT [Char] st Identity DatatypeFacet
-> ParsecT [Char] st Identity DatatypeFacet
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> DatatypeFacet -> ParsecT [Char] st Identity DatatypeFacet
forall (m :: * -> *) a. Monad m => a -> m a
return DatatypeFacet
f)
      [ DatatypeFacet
LENGTH
      , DatatypeFacet
MINLENGTH
      , DatatypeFacet
MAXLENGTH
      , DatatypeFacet
PATTERN
      , DatatypeFacet
TOTALDIGITS
      , DatatypeFacet
FRACTIONDIGITS ] [ParsecT [Char] st Identity DatatypeFacet]
-> [ParsecT [Char] st Identity DatatypeFacet]
-> [ParsecT [Char] st Identity DatatypeFacet]
forall a. [a] -> [a] -> [a]
++ (DatatypeFacet -> ParsecT [Char] st Identity DatatypeFacet)
-> [DatatypeFacet] -> [ParsecT [Char] st Identity DatatypeFacet]
forall a b. (a -> b) -> [a] -> [b]
map
      (\ f :: DatatypeFacet
f -> [Char] -> CharParser st Char -> CharParser st [Char]
forall st. [Char] -> CharParser st Char -> CharParser st [Char]
keywordNotFollowedBy (DatatypeFacet -> [Char]
showFacet DatatypeFacet
f) ([Char] -> CharParser st Char
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m Char
oneOf "<>=")
              CharParser st [Char]
-> ParsecT [Char] st Identity DatatypeFacet
-> ParsecT [Char] st Identity DatatypeFacet
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> DatatypeFacet -> ParsecT [Char] st Identity DatatypeFacet
forall (m :: * -> *) a. Monad m => a -> m a
return DatatypeFacet
f)
      [ DatatypeFacet
MININCLUSIVE
      , DatatypeFacet
MINEXCLUSIVE
      , DatatypeFacet
MAXINCLUSIVE
      , DatatypeFacet
MAXEXCLUSIVE ]
  Literal
rv <- PrefixMap -> CharParser st Literal
forall st. PrefixMap -> CharParser st Literal
literal PrefixMap
pm
  (IRI, Literal) -> CharParser st (IRI, Literal)
forall (m :: * -> *) a. Monad m => a -> m a
return (PrefixMap -> IRI -> IRI
expandIRI PrefixMap
pm (DatatypeFacet -> IRI
facetToIRINoSign DatatypeFacet
df), Literal
rv)

-- it returns DataType Datatype or DatatypeRestriction Datatype [facetValuePair]
dataRangeRestriction :: GA.PrefixMap -> CharParser st DataRange
dataRangeRestriction :: PrefixMap -> CharParser st DataRange
dataRangeRestriction pm :: PrefixMap
pm = do
  IRI
e <- PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
datatypeUri PrefixMap
pm
  DataRange -> CharParser st DataRange -> CharParser st DataRange
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option (IRI -> [(IRI, Literal)] -> DataRange
DataType IRI
e []) (CharParser st DataRange -> CharParser st DataRange)
-> CharParser st DataRange -> CharParser st DataRange
forall a b. (a -> b) -> a -> b
$ ([(IRI, Literal)] -> DataRange)
-> ParsecT [Char] st Identity [(IRI, Literal)]
-> CharParser st DataRange
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (IRI -> [(IRI, Literal)] -> DataRange
DataType IRI
e) (ParsecT [Char] st Identity [(IRI, Literal)]
 -> CharParser st DataRange)
-> ParsecT [Char] st Identity [(IRI, Literal)]
-> CharParser st DataRange
forall a b. (a -> b) -> a -> b
$ ParsecT [Char] st Identity [(IRI, Literal)]
-> ParsecT [Char] st Identity [(IRI, Literal)]
forall tok st a. GenParser tok st a -> GenParser tok st a
try (ParsecT [Char] st Identity [(IRI, Literal)]
 -> ParsecT [Char] st Identity [(IRI, Literal)])
-> ParsecT [Char] st Identity [(IRI, Literal)]
-> ParsecT [Char] st Identity [(IRI, Literal)]
forall a b. (a -> b) -> a -> b
$ PrefixMap -> ParsecT [Char] st Identity [(IRI, Literal)]
forall st. PrefixMap -> CharParser st [(IRI, Literal)]
parseFacetValuePairs PrefixMap
pm
    
parseFacetValuePairs :: GA.PrefixMap -> CharParser st [(ConstrainingFacet, RestrictionValue)]
parseFacetValuePairs :: PrefixMap -> CharParser st [(IRI, Literal)]
parseFacetValuePairs pm :: PrefixMap
pm = CharParser st [(IRI, Literal)] -> CharParser st [(IRI, Literal)]
forall st a. CharParser st a -> CharParser st a
bracketsP (CharParser st [(IRI, Literal)] -> CharParser st [(IRI, Literal)])
-> CharParser st [(IRI, Literal)] -> CharParser st [(IRI, Literal)]
forall a b. (a -> b) -> a -> b
$ CharParser st (IRI, Literal) -> CharParser st [(IRI, Literal)]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (CharParser st (IRI, Literal) -> CharParser st [(IRI, Literal)])
-> CharParser st (IRI, Literal) -> CharParser st [(IRI, Literal)]
forall a b. (a -> b) -> a -> b
$ CharParser st (IRI, Literal) -> CharParser st (IRI, Literal)
forall st a. CharParser st a -> CharParser st a
skips (CharParser st (IRI, Literal) -> CharParser st (IRI, Literal))
-> CharParser st (IRI, Literal) -> CharParser st (IRI, Literal)
forall a b. (a -> b) -> a -> b
$ PrefixMap -> CharParser st (IRI, Literal)
forall st. PrefixMap -> CharParser st (IRI, Literal)
facetValuePair PrefixMap
pm

dataConjunct :: GA.PrefixMap -> CharParser st DataRange
dataConjunct :: PrefixMap -> CharParser st DataRange
dataConjunct pm :: PrefixMap
pm = ([DataRange] -> DataRange)
-> ParsecT [Char] st Identity [DataRange]
-> CharParser st DataRange
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (JunctionType -> [DataRange] -> DataRange
mkDataJunction JunctionType
IntersectionOf)
      (ParsecT [Char] st Identity [DataRange] -> CharParser st DataRange)
-> ParsecT [Char] st Identity [DataRange]
-> CharParser st DataRange
forall a b. (a -> b) -> a -> b
$ CharParser st DataRange
-> ParsecT [Char] st Identity ()
-> ParsecT [Char] st Identity [DataRange]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
sepBy1 (PrefixMap -> CharParser st DataRange
forall st. PrefixMap -> CharParser st DataRange
dataPrimary PrefixMap
pm) (ParsecT [Char] st Identity ()
 -> ParsecT [Char] st Identity [DataRange])
-> ParsecT [Char] st Identity ()
-> ParsecT [Char] st Identity [DataRange]
forall a b. (a -> b) -> a -> b
$ [Char] -> ParsecT [Char] st Identity ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
andS

dataRange :: GA.PrefixMap -> CharParser st DataRange
dataRange :: PrefixMap -> CharParser st DataRange
dataRange pm :: PrefixMap
pm = ([DataRange] -> DataRange)
-> ParsecT [Char] st Identity [DataRange]
-> CharParser st DataRange
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (JunctionType -> [DataRange] -> DataRange
mkDataJunction JunctionType
UnionOf)
      (ParsecT [Char] st Identity [DataRange] -> CharParser st DataRange)
-> ParsecT [Char] st Identity [DataRange]
-> CharParser st DataRange
forall a b. (a -> b) -> a -> b
$ CharParser st DataRange
-> ParsecT [Char] st Identity ()
-> ParsecT [Char] st Identity [DataRange]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
sepBy1 (PrefixMap -> CharParser st DataRange
forall st. PrefixMap -> CharParser st DataRange
dataConjunct PrefixMap
pm) (ParsecT [Char] st Identity ()
 -> ParsecT [Char] st Identity [DataRange])
-> ParsecT [Char] st Identity ()
-> ParsecT [Char] st Identity [DataRange]
forall a b. (a -> b) -> a -> b
$ [Char] -> ParsecT [Char] st Identity ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
orS

dataPrimary :: GA.PrefixMap -> CharParser st DataRange
dataPrimary :: PrefixMap -> CharParser st DataRange
dataPrimary pm :: PrefixMap
pm = do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
notS
    (DataRange -> DataRange)
-> CharParser st DataRange -> CharParser st DataRange
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap DataRange -> DataRange
DataComplementOf (PrefixMap -> CharParser st DataRange
forall st. PrefixMap -> CharParser st DataRange
dataPrimary PrefixMap
pm)
   CharParser st DataRange
-> CharParser st DataRange -> CharParser st DataRange
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> CharParser st DataRange -> CharParser st DataRange
forall st a. CharParser st a -> CharParser st a
parensP (PrefixMap -> CharParser st DataRange
forall st. PrefixMap -> CharParser st DataRange
dataRange PrefixMap
pm)
   CharParser st DataRange
-> CharParser st DataRange -> CharParser st DataRange
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ([Literal] -> DataRange)
-> ParsecT [Char] st Identity [Literal] -> CharParser st DataRange
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Literal] -> DataRange
DataOneOf (ParsecT [Char] st Identity [Literal]
-> ParsecT [Char] st Identity [Literal]
forall st a. CharParser st a -> CharParser st a
bracesP (ParsecT [Char] st Identity [Literal]
 -> ParsecT [Char] st Identity [Literal])
-> ParsecT [Char] st Identity [Literal]
-> ParsecT [Char] st Identity [Literal]
forall a b. (a -> b) -> a -> b
$ CharParser st Literal -> ParsecT [Char] st Identity [Literal]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (CharParser st Literal -> ParsecT [Char] st Identity [Literal])
-> CharParser st Literal -> ParsecT [Char] st Identity [Literal]
forall a b. (a -> b) -> a -> b
$ PrefixMap -> CharParser st Literal
forall st. PrefixMap -> CharParser st Literal
literal PrefixMap
pm)
   CharParser st DataRange
-> CharParser st DataRange -> CharParser st DataRange
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> PrefixMap -> CharParser st DataRange
forall st. PrefixMap -> CharParser st DataRange
dataRangeRestriction PrefixMap
pm

mkDataJunction :: JunctionType -> [DataRange] -> DataRange
mkDataJunction :: JunctionType -> [DataRange] -> DataRange
mkDataJunction ty :: JunctionType
ty ds :: [DataRange]
ds = case [DataRange] -> [DataRange]
forall a. Ord a => [a] -> [a]
nubOrd [DataRange]
ds of
  [] -> [Char] -> DataRange
forall a. HasCallStack => [Char] -> a
error "mkDataJunction"
  [x :: DataRange
x] -> DataRange
x
  ns :: [DataRange]
ns -> JunctionType -> [DataRange] -> DataRange
DataJunction JunctionType
ty [DataRange]
ns

-- parses "some" or "only"
someOrOnly :: CharParser st QuantifierType
someOrOnly :: CharParser st QuantifierType
someOrOnly = [CharParser st QuantifierType] -> CharParser st QuantifierType
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice
  ([CharParser st QuantifierType] -> CharParser st QuantifierType)
-> [CharParser st QuantifierType] -> CharParser st QuantifierType
forall a b. (a -> b) -> a -> b
$ (QuantifierType -> CharParser st QuantifierType)
-> [QuantifierType] -> [CharParser st QuantifierType]
forall a b. (a -> b) -> [a] -> [b]
map (\ f :: QuantifierType
f -> [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword (QuantifierType -> [Char]
showQuantifierType QuantifierType
f) CharParser st ()
-> CharParser st QuantifierType -> CharParser st QuantifierType
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> QuantifierType -> CharParser st QuantifierType
forall (m :: * -> *) a. Monad m => a -> m a
return QuantifierType
f)
    [QuantifierType
AllValuesFrom, QuantifierType
SomeValuesFrom]

-- locates the keywords "min" "max" "exact" and their argument
card :: CharParser st (CardinalityType, Int)
card :: CharParser st (CardinalityType, Int)
card = do
  CardinalityType
c <- [ParsecT [Char] st Identity CardinalityType]
-> ParsecT [Char] st Identity CardinalityType
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice ([ParsecT [Char] st Identity CardinalityType]
 -> ParsecT [Char] st Identity CardinalityType)
-> [ParsecT [Char] st Identity CardinalityType]
-> ParsecT [Char] st Identity CardinalityType
forall a b. (a -> b) -> a -> b
$ (CardinalityType -> ParsecT [Char] st Identity CardinalityType)
-> [CardinalityType]
-> [ParsecT [Char] st Identity CardinalityType]
forall a b. (a -> b) -> [a] -> [b]
map (\ f :: CardinalityType
f -> [Char] -> CharParser st Char -> CharParser st [Char]
forall st. [Char] -> CharParser st Char -> CharParser st [Char]
keywordNotFollowedBy (CardinalityType -> [Char]
showCardinalityType CardinalityType
f) CharParser st Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
letter
                            CharParser st [Char]
-> ParsecT [Char] st Identity CardinalityType
-> ParsecT [Char] st Identity CardinalityType
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> CardinalityType -> ParsecT [Char] st Identity CardinalityType
forall (m :: * -> *) a. Monad m => a -> m a
return CardinalityType
f)
             [CardinalityType
MinCardinality, CardinalityType
MaxCardinality, CardinalityType
ExactCardinality]
  [Char]
n <- CharParser st [Char] -> CharParser st [Char]
forall st a. CharParser st a -> CharParser st a
skips CharParser st [Char]
forall st. CharParser st [Char]
getNumber
  (CardinalityType, Int) -> CharParser st (CardinalityType, Int)
forall (m :: * -> *) a. Monad m => a -> m a
return (CardinalityType
c, Int -> [Char] -> Int
value 10 [Char]
n)

-- tries to parse either a IRI or a literal
individualOrConstant :: GA.PrefixMap -> CharParser st (Either Individual Literal)
individualOrConstant :: PrefixMap -> CharParser st (Either IRI Literal)
individualOrConstant pm :: PrefixMap
pm = (Literal -> Either IRI Literal)
-> ParsecT [Char] st Identity Literal
-> CharParser st (Either IRI Literal)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Literal -> Either IRI Literal
forall a b. b -> Either a b
Right (PrefixMap -> ParsecT [Char] st Identity Literal
forall st. PrefixMap -> CharParser st Literal
literal PrefixMap
pm) CharParser st (Either IRI Literal)
-> CharParser st (Either IRI Literal)
-> CharParser st (Either IRI Literal)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (IRI -> Either IRI Literal)
-> ParsecT [Char] st Identity IRI
-> CharParser st (Either IRI Literal)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap IRI -> Either IRI Literal
forall a b. a -> Either a b
Left (PrefixMap -> ParsecT [Char] st Identity IRI
forall st. PrefixMap -> CharParser st IRI
individual PrefixMap
pm)

{- | applies the previous one to a list separated by commas
    (the list needs to be all of the same type, of course) -}
individualOrConstantList :: GA.PrefixMap -> CharParser st (Either [Individual] [Literal])
individualOrConstantList :: PrefixMap -> CharParser st (Either [IRI] [Literal])
individualOrConstantList pm :: PrefixMap
pm = do
    Either IRI Literal
ioc <- PrefixMap -> CharParser st (Either IRI Literal)
forall st. PrefixMap -> CharParser st (Either IRI Literal)
individualOrConstant PrefixMap
pm
    case Either IRI Literal
ioc of
      Left u :: IRI
u -> ([IRI] -> Either [IRI] [Literal])
-> ParsecT [Char] st Identity [IRI]
-> CharParser st (Either [IRI] [Literal])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ([IRI] -> Either [IRI] [Literal]
forall a b. a -> Either a b
Left ([IRI] -> Either [IRI] [Literal])
-> ([IRI] -> [IRI]) -> [IRI] -> Either [IRI] [Literal]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (IRI
u IRI -> [IRI] -> [IRI]
forall a. a -> [a] -> [a]
:)) (ParsecT [Char] st Identity [IRI]
 -> CharParser st (Either [IRI] [Literal]))
-> ParsecT [Char] st Identity [IRI]
-> CharParser st (Either [IRI] [Literal])
forall a b. (a -> b) -> a -> b
$ ParsecT [Char] st Identity [IRI]
-> ParsecT [Char] st Identity [IRI]
forall tok st a. GenParser tok st [a] -> GenParser tok st [a]
optionL
        (ParsecT [Char] st Identity [IRI]
 -> ParsecT [Char] st Identity [IRI])
-> ParsecT [Char] st Identity [IRI]
-> ParsecT [Char] st Identity [IRI]
forall a b. (a -> b) -> a -> b
$ CharParser st ()
forall st. GenParser Char st ()
commaP CharParser st ()
-> ParsecT [Char] st Identity [IRI]
-> ParsecT [Char] st Identity [IRI]
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> CharParser st IRI -> ParsecT [Char] st Identity [IRI]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
individual PrefixMap
pm)
      Right c :: Literal
c -> ([Literal] -> Either [IRI] [Literal])
-> ParsecT [Char] st Identity [Literal]
-> CharParser st (Either [IRI] [Literal])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ([Literal] -> Either [IRI] [Literal]
forall a b. b -> Either a b
Right ([Literal] -> Either [IRI] [Literal])
-> ([Literal] -> [Literal]) -> [Literal] -> Either [IRI] [Literal]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Literal
c Literal -> [Literal] -> [Literal]
forall a. a -> [a] -> [a]
:)) (ParsecT [Char] st Identity [Literal]
 -> CharParser st (Either [IRI] [Literal]))
-> ParsecT [Char] st Identity [Literal]
-> CharParser st (Either [IRI] [Literal])
forall a b. (a -> b) -> a -> b
$ ParsecT [Char] st Identity [Literal]
-> ParsecT [Char] st Identity [Literal]
forall tok st a. GenParser tok st [a] -> GenParser tok st [a]
optionL
        (ParsecT [Char] st Identity [Literal]
 -> ParsecT [Char] st Identity [Literal])
-> ParsecT [Char] st Identity [Literal]
-> ParsecT [Char] st Identity [Literal]
forall a b. (a -> b) -> a -> b
$ CharParser st ()
forall st. GenParser Char st ()
commaP CharParser st ()
-> ParsecT [Char] st Identity [Literal]
-> ParsecT [Char] st Identity [Literal]
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> CharParser st Literal -> ParsecT [Char] st Identity [Literal]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (PrefixMap -> CharParser st Literal
forall st. PrefixMap -> CharParser st Literal
literal PrefixMap
pm)

primaryOrDataRange :: GA.PrefixMap -> CharParser st (Either ClassExpression DataRange)
primaryOrDataRange :: PrefixMap -> CharParser st (Either ClassExpression DataRange)
primaryOrDataRange pm :: PrefixMap
pm = do
  [()]
ns <- ParsecT [Char] st Identity () -> ParsecT [Char] st Identity [()]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (ParsecT [Char] st Identity () -> ParsecT [Char] st Identity [()])
-> ParsecT [Char] st Identity () -> ParsecT [Char] st Identity [()]
forall a b. (a -> b) -> a -> b
$ [Char] -> ParsecT [Char] st Identity ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
notS  -- allows multiple not before primary
  Either ClassExpression DataRange
ed <- do
      IRI
u <- PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
datatypeUri PrefixMap
pm
      (ClassExpression -> Either ClassExpression DataRange)
-> ParsecT [Char] st Identity ClassExpression
-> CharParser st (Either ClassExpression DataRange)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ClassExpression -> Either ClassExpression DataRange
forall a b. a -> Either a b
Left (PrefixMap
-> ObjectPropertyExpression
-> ParsecT [Char] st Identity ClassExpression
forall st.
PrefixMap
-> ObjectPropertyExpression -> CharParser st ClassExpression
restrictionAny PrefixMap
pm (ObjectPropertyExpression
 -> ParsecT [Char] st Identity ClassExpression)
-> ObjectPropertyExpression
-> ParsecT [Char] st Identity ClassExpression
forall a b. (a -> b) -> a -> b
$ IRI -> ObjectPropertyExpression
ObjectProp IRI
u)
        CharParser st (Either ClassExpression DataRange)
-> CharParser st (Either ClassExpression DataRange)
-> CharParser st (Either ClassExpression DataRange)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ([(IRI, Literal)] -> Either ClassExpression DataRange)
-> ParsecT [Char] st Identity [(IRI, Literal)]
-> CharParser st (Either ClassExpression DataRange)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (DataRange -> Either ClassExpression DataRange
forall a b. b -> Either a b
Right (DataRange -> Either ClassExpression DataRange)
-> ([(IRI, Literal)] -> DataRange)
-> [(IRI, Literal)]
-> Either ClassExpression DataRange
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IRI -> [(IRI, Literal)] -> DataRange
DataType IRI
u)
            (ParsecT [Char] st Identity [(IRI, Literal)]
-> ParsecT [Char] st Identity [(IRI, Literal)]
forall st a. CharParser st a -> CharParser st a
bracketsP (ParsecT [Char] st Identity [(IRI, Literal)]
 -> ParsecT [Char] st Identity [(IRI, Literal)])
-> ParsecT [Char] st Identity [(IRI, Literal)]
-> ParsecT [Char] st Identity [(IRI, Literal)]
forall a b. (a -> b) -> a -> b
$ CharParser st (IRI, Literal)
-> ParsecT [Char] st Identity [(IRI, Literal)]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (CharParser st (IRI, Literal)
 -> ParsecT [Char] st Identity [(IRI, Literal)])
-> CharParser st (IRI, Literal)
-> ParsecT [Char] st Identity [(IRI, Literal)]
forall a b. (a -> b) -> a -> b
$ PrefixMap -> CharParser st (IRI, Literal)
forall st. PrefixMap -> CharParser st (IRI, Literal)
facetValuePair PrefixMap
pm)
        CharParser st (Either ClassExpression DataRange)
-> CharParser st (Either ClassExpression DataRange)
-> CharParser st (Either ClassExpression DataRange)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Either ClassExpression DataRange
-> CharParser st (Either ClassExpression DataRange)
forall (m :: * -> *) a. Monad m => a -> m a
return (if IRI -> Bool
isDatatypeKey IRI
u
              then DataRange -> Either ClassExpression DataRange
forall a b. b -> Either a b
Right (DataRange -> Either ClassExpression DataRange)
-> DataRange -> Either ClassExpression DataRange
forall a b. (a -> b) -> a -> b
$ IRI -> [(IRI, Literal)] -> DataRange
DataType IRI
u []
              else ClassExpression -> Either ClassExpression DataRange
forall a b. a -> Either a b
Left (ClassExpression -> Either ClassExpression DataRange)
-> ClassExpression -> Either ClassExpression DataRange
forall a b. (a -> b) -> a -> b
$ IRI -> ClassExpression
Expression IRI
u) -- could still be a datatypeUri
    CharParser st (Either ClassExpression DataRange)
-> CharParser st (Either ClassExpression DataRange)
-> CharParser st (Either ClassExpression DataRange)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
      Either [IRI] [Literal]
e <- CharParser st (Either [IRI] [Literal])
-> CharParser st (Either [IRI] [Literal])
forall st a. CharParser st a -> CharParser st a
bracesP (CharParser st (Either [IRI] [Literal])
 -> CharParser st (Either [IRI] [Literal]))
-> CharParser st (Either [IRI] [Literal])
-> CharParser st (Either [IRI] [Literal])
forall a b. (a -> b) -> a -> b
$ PrefixMap -> CharParser st (Either [IRI] [Literal])
forall st. PrefixMap -> CharParser st (Either [IRI] [Literal])
individualOrConstantList PrefixMap
pm
      Either ClassExpression DataRange
-> CharParser st (Either ClassExpression DataRange)
forall (m :: * -> *) a. Monad m => a -> m a
return (Either ClassExpression DataRange
 -> CharParser st (Either ClassExpression DataRange))
-> Either ClassExpression DataRange
-> CharParser st (Either ClassExpression DataRange)
forall a b. (a -> b) -> a -> b
$ case Either [IRI] [Literal]
e of
        Left us :: [IRI]
us -> ClassExpression -> Either ClassExpression DataRange
forall a b. a -> Either a b
Left (ClassExpression -> Either ClassExpression DataRange)
-> ClassExpression -> Either ClassExpression DataRange
forall a b. (a -> b) -> a -> b
$ [IRI] -> ClassExpression
ObjectOneOf [IRI]
us
        Right cs :: [Literal]
cs -> DataRange -> Either ClassExpression DataRange
forall a b. b -> Either a b
Right (DataRange -> Either ClassExpression DataRange)
-> DataRange -> Either ClassExpression DataRange
forall a b. (a -> b) -> a -> b
$ [Literal] -> DataRange
DataOneOf [Literal]
cs
    CharParser st (Either ClassExpression DataRange)
-> CharParser st (Either ClassExpression DataRange)
-> CharParser st (Either ClassExpression DataRange)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (ClassExpression -> Either ClassExpression DataRange)
-> ParsecT [Char] st Identity ClassExpression
-> CharParser st (Either ClassExpression DataRange)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ClassExpression -> Either ClassExpression DataRange
forall a b. a -> Either a b
Left (PrefixMap -> ParsecT [Char] st Identity ClassExpression
forall st. PrefixMap -> CharParser st ClassExpression
restrictionOrAtomic PrefixMap
pm)
  Either ClassExpression DataRange
-> CharParser st (Either ClassExpression DataRange)
forall (m :: * -> *) a. Monad m => a -> m a
return (Either ClassExpression DataRange
 -> CharParser st (Either ClassExpression DataRange))
-> Either ClassExpression DataRange
-> CharParser st (Either ClassExpression DataRange)
forall a b. (a -> b) -> a -> b
$ if Int -> Bool
forall a. Integral a => a -> Bool
even ([()] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [()]
ns) then Either ClassExpression DataRange
ed else
    case Either ClassExpression DataRange
ed of
      Left d :: ClassExpression
d -> ClassExpression -> Either ClassExpression DataRange
forall a b. a -> Either a b
Left (ClassExpression -> Either ClassExpression DataRange)
-> ClassExpression -> Either ClassExpression DataRange
forall a b. (a -> b) -> a -> b
$ ClassExpression -> ClassExpression
ObjectComplementOf ClassExpression
d
      Right d :: DataRange
d -> DataRange -> Either ClassExpression DataRange
forall a b. b -> Either a b
Right (DataRange -> Either ClassExpression DataRange)
-> DataRange -> Either ClassExpression DataRange
forall a b. (a -> b) -> a -> b
$ DataRange -> DataRange
DataComplementOf DataRange
d

mkObjectJunction :: JunctionType -> [ClassExpression] -> ClassExpression
mkObjectJunction :: JunctionType -> [ClassExpression] -> ClassExpression
mkObjectJunction ty :: JunctionType
ty ds :: [ClassExpression]
ds = case [ClassExpression] -> [ClassExpression]
forall a. Ord a => [a] -> [a]
nubOrd [ClassExpression]
ds of
  [] -> [Char] -> ClassExpression
forall a. HasCallStack => [Char] -> a
error "mkObjectJunction"
  [x :: ClassExpression
x] -> ClassExpression
x
  ns :: [ClassExpression]
ns -> JunctionType -> [ClassExpression] -> ClassExpression
ObjectJunction JunctionType
ty [ClassExpression]
ns

dataValuesFrom :: GA.PrefixMap -> CharParser st ClassExpression
dataValuesFrom :: PrefixMap -> CharParser st ClassExpression
dataValuesFrom pm :: PrefixMap
pm = CharParser st ClassExpression -> CharParser st ClassExpression
forall tok st a. GenParser tok st a -> GenParser tok st a
try (CharParser st ClassExpression -> CharParser st ClassExpression)
-> CharParser st ClassExpression -> CharParser st ClassExpression
forall a b. (a -> b) -> a -> b
$ do
    [IRI]
dpExprs <- CharParser st [IRI] -> CharParser st [IRI]
forall st a. CharParser st a -> CharParser st a
parensP (CharParser st [IRI] -> CharParser st [IRI])
-> CharParser st [IRI] -> CharParser st [IRI]
forall a b. (a -> b) -> a -> b
$ do
      IRI
dpExpr <- PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
dataPropertyExpr PrefixMap
pm
      CharParser st ()
forall st. GenParser Char st ()
commaP
      [IRI]
dpExprs <- CharParser st IRI -> CharParser st [IRI]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
dataPropertyExpr PrefixMap
pm)
      [IRI] -> CharParser st [IRI]
forall (m :: * -> *) a. Monad m => a -> m a
return (IRI
dpExpr IRI -> [IRI] -> [IRI]
forall a. a -> [a] -> [a]
: [IRI]
dpExprs)
    QuantifierType
s <- CharParser st QuantifierType
forall st. CharParser st QuantifierType
someOrOnly
    DataRange
dp <- PrefixMap -> CharParser st DataRange
forall st. PrefixMap -> CharParser st DataRange
dataPrimary PrefixMap
pm
    ClassExpression -> CharParser st ClassExpression
forall (m :: * -> *) a. Monad m => a -> m a
return (ClassExpression -> CharParser st ClassExpression)
-> ClassExpression -> CharParser st ClassExpression
forall a b. (a -> b) -> a -> b
$ QuantifierType -> [IRI] -> DataRange -> ClassExpression
DataValuesFrom QuantifierType
s [IRI]
dpExprs DataRange
dp

restrictionAny :: GA.PrefixMap -> ObjectPropertyExpression -> CharParser st ClassExpression
restrictionAny :: PrefixMap
-> ObjectPropertyExpression -> CharParser st ClassExpression
restrictionAny pm :: PrefixMap
pm opExpr :: ObjectPropertyExpression
opExpr = do
      [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
valueS
      Either IRI Literal
e <- PrefixMap -> CharParser st (Either IRI Literal)
forall st. PrefixMap -> CharParser st (Either IRI Literal)
individualOrConstant PrefixMap
pm
      case Either IRI Literal
e of
        Left u :: IRI
u -> ClassExpression -> CharParser st ClassExpression
forall (m :: * -> *) a. Monad m => a -> m a
return (ClassExpression -> CharParser st ClassExpression)
-> ClassExpression -> CharParser st ClassExpression
forall a b. (a -> b) -> a -> b
$ ObjectPropertyExpression -> IRI -> ClassExpression
ObjectHasValue ObjectPropertyExpression
opExpr IRI
u
        Right c :: Literal
c -> case ObjectPropertyExpression
opExpr of
          ObjectProp dpExpr :: IRI
dpExpr -> ClassExpression -> CharParser st ClassExpression
forall (m :: * -> *) a. Monad m => a -> m a
return (ClassExpression -> CharParser st ClassExpression)
-> ClassExpression -> CharParser st ClassExpression
forall a b. (a -> b) -> a -> b
$ IRI -> Literal -> ClassExpression
DataHasValue IRI
dpExpr Literal
c
          _ -> [Char] -> CharParser st ClassExpression
forall s (m :: * -> *) t u a.
Stream s m t =>
[Char] -> ParsecT s u m a
unexpected "literal"
    CharParser st ClassExpression
-> CharParser st ClassExpression -> CharParser st ClassExpression
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
      [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
selfS
      ClassExpression -> CharParser st ClassExpression
forall (m :: * -> *) a. Monad m => a -> m a
return (ClassExpression -> CharParser st ClassExpression)
-> ClassExpression -> CharParser st ClassExpression
forall a b. (a -> b) -> a -> b
$ ObjectPropertyExpression -> ClassExpression
ObjectHasSelf ObjectPropertyExpression
opExpr
    CharParser st ClassExpression
-> CharParser st ClassExpression -> CharParser st ClassExpression
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do -- sugar
      [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
onlysomeS
      [ClassExpression]
ds <- CharParser st [ClassExpression] -> CharParser st [ClassExpression]
forall st a. CharParser st a -> CharParser st a
bracketsP (CharParser st [ClassExpression]
 -> CharParser st [ClassExpression])
-> CharParser st [ClassExpression]
-> CharParser st [ClassExpression]
forall a b. (a -> b) -> a -> b
$ CharParser st ClassExpression -> CharParser st [ClassExpression]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (CharParser st ClassExpression -> CharParser st [ClassExpression])
-> CharParser st ClassExpression -> CharParser st [ClassExpression]
forall a b. (a -> b) -> a -> b
$ PrefixMap -> CharParser st ClassExpression
forall st. PrefixMap -> CharParser st ClassExpression
description PrefixMap
pm
      let as :: [ClassExpression]
as = (ClassExpression -> ClassExpression)
-> [ClassExpression] -> [ClassExpression]
forall a b. (a -> b) -> [a] -> [b]
map (QuantifierType
-> ObjectPropertyExpression -> ClassExpression -> ClassExpression
ObjectValuesFrom QuantifierType
SomeValuesFrom ObjectPropertyExpression
opExpr) [ClassExpression]
ds
          o :: ClassExpression
o = QuantifierType
-> ObjectPropertyExpression -> ClassExpression -> ClassExpression
ObjectValuesFrom QuantifierType
AllValuesFrom ObjectPropertyExpression
opExpr
              (ClassExpression -> ClassExpression)
-> ClassExpression -> ClassExpression
forall a b. (a -> b) -> a -> b
$ JunctionType -> [ClassExpression] -> ClassExpression
mkObjectJunction JunctionType
UnionOf [ClassExpression]
ds
      ClassExpression -> CharParser st ClassExpression
forall (m :: * -> *) a. Monad m => a -> m a
return (ClassExpression -> CharParser st ClassExpression)
-> ClassExpression -> CharParser st ClassExpression
forall a b. (a -> b) -> a -> b
$ JunctionType -> [ClassExpression] -> ClassExpression
mkObjectJunction JunctionType
IntersectionOf ([ClassExpression] -> ClassExpression)
-> [ClassExpression] -> ClassExpression
forall a b. (a -> b) -> a -> b
$ ClassExpression
o ClassExpression -> [ClassExpression] -> [ClassExpression]
forall a. a -> [a] -> [a]
: [ClassExpression]
as
    CharParser st ClassExpression
-> CharParser st ClassExpression -> CharParser st ClassExpression
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do -- sugar
      [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
hasS
      IRI
iu <- PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
individual PrefixMap
pm
      ClassExpression -> CharParser st ClassExpression
forall (m :: * -> *) a. Monad m => a -> m a
return (ClassExpression -> CharParser st ClassExpression)
-> ClassExpression -> CharParser st ClassExpression
forall a b. (a -> b) -> a -> b
$ QuantifierType
-> ObjectPropertyExpression -> ClassExpression -> ClassExpression
ObjectValuesFrom QuantifierType
SomeValuesFrom ObjectPropertyExpression
opExpr (ClassExpression -> ClassExpression)
-> ClassExpression -> ClassExpression
forall a b. (a -> b) -> a -> b
$ [IRI] -> ClassExpression
ObjectOneOf [IRI
iu]
    CharParser st ClassExpression
-> CharParser st ClassExpression -> CharParser st ClassExpression
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
      QuantifierType
v <- CharParser st QuantifierType
forall st. CharParser st QuantifierType
someOrOnly
      Either ClassExpression DataRange
pr <- PrefixMap -> CharParser st (Either ClassExpression DataRange)
forall st.
PrefixMap -> CharParser st (Either ClassExpression DataRange)
primaryOrDataRange PrefixMap
pm
      case Either ClassExpression DataRange
pr of
        Left p :: ClassExpression
p -> ClassExpression -> CharParser st ClassExpression
forall (m :: * -> *) a. Monad m => a -> m a
return (ClassExpression -> CharParser st ClassExpression)
-> ClassExpression -> CharParser st ClassExpression
forall a b. (a -> b) -> a -> b
$ QuantifierType
-> ObjectPropertyExpression -> ClassExpression -> ClassExpression
ObjectValuesFrom QuantifierType
v ObjectPropertyExpression
opExpr ClassExpression
p
        Right r :: DataRange
r -> case ObjectPropertyExpression
opExpr of
          ObjectProp dpExpr :: IRI
dpExpr -> ClassExpression -> CharParser st ClassExpression
forall (m :: * -> *) a. Monad m => a -> m a
return (ClassExpression -> CharParser st ClassExpression)
-> ClassExpression -> CharParser st ClassExpression
forall a b. (a -> b) -> a -> b
$ QuantifierType -> [IRI] -> DataRange -> ClassExpression
DataValuesFrom QuantifierType
v [IRI
dpExpr] DataRange
r
          _ -> [Char] -> CharParser st ClassExpression
forall s (m :: * -> *) t u a.
Stream s m t =>
[Char] -> ParsecT s u m a
unexpected ([Char] -> CharParser st ClassExpression)
-> [Char] -> CharParser st ClassExpression
forall a b. (a -> b) -> a -> b
$ "dataRange after " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ QuantifierType -> [Char]
showQuantifierType QuantifierType
v
    CharParser st ClassExpression
-> CharParser st ClassExpression -> CharParser st ClassExpression
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
      (c :: CardinalityType
c, n :: Int
n) <- CharParser st (CardinalityType, Int)
forall st. CharParser st (CardinalityType, Int)
card
      Maybe (Either ClassExpression DataRange)
mp <- CharParser st (Either ClassExpression DataRange)
-> ParsecT
     [Char] st Identity (Maybe (Either ClassExpression DataRange))
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m (Maybe a)
optionMaybe (CharParser st (Either ClassExpression DataRange)
 -> ParsecT
      [Char] st Identity (Maybe (Either ClassExpression DataRange)))
-> CharParser st (Either ClassExpression DataRange)
-> ParsecT
     [Char] st Identity (Maybe (Either ClassExpression DataRange))
forall a b. (a -> b) -> a -> b
$ PrefixMap -> CharParser st (Either ClassExpression DataRange)
forall st.
PrefixMap -> CharParser st (Either ClassExpression DataRange)
primaryOrDataRange PrefixMap
pm
      case Maybe (Either ClassExpression DataRange)
mp of
         Nothing -> ClassExpression -> CharParser st ClassExpression
forall (m :: * -> *) a. Monad m => a -> m a
return (ClassExpression -> CharParser st ClassExpression)
-> ClassExpression -> CharParser st ClassExpression
forall a b. (a -> b) -> a -> b
$ Cardinality ObjectPropertyExpression ClassExpression
-> ClassExpression
ObjectCardinality (Cardinality ObjectPropertyExpression ClassExpression
 -> ClassExpression)
-> Cardinality ObjectPropertyExpression ClassExpression
-> ClassExpression
forall a b. (a -> b) -> a -> b
$ CardinalityType
-> Int
-> ObjectPropertyExpression
-> Maybe ClassExpression
-> Cardinality ObjectPropertyExpression ClassExpression
forall a b.
CardinalityType -> Int -> a -> Maybe b -> Cardinality a b
Cardinality CardinalityType
c Int
n ObjectPropertyExpression
opExpr Maybe ClassExpression
forall a. Maybe a
Nothing
         Just pr :: Either ClassExpression DataRange
pr -> case Either ClassExpression DataRange
pr of
           Left p :: ClassExpression
p ->
             ClassExpression -> CharParser st ClassExpression
forall (m :: * -> *) a. Monad m => a -> m a
return (ClassExpression -> CharParser st ClassExpression)
-> ClassExpression -> CharParser st ClassExpression
forall a b. (a -> b) -> a -> b
$ Cardinality ObjectPropertyExpression ClassExpression
-> ClassExpression
ObjectCardinality (Cardinality ObjectPropertyExpression ClassExpression
 -> ClassExpression)
-> Cardinality ObjectPropertyExpression ClassExpression
-> ClassExpression
forall a b. (a -> b) -> a -> b
$ CardinalityType
-> Int
-> ObjectPropertyExpression
-> Maybe ClassExpression
-> Cardinality ObjectPropertyExpression ClassExpression
forall a b.
CardinalityType -> Int -> a -> Maybe b -> Cardinality a b
Cardinality CardinalityType
c Int
n ObjectPropertyExpression
opExpr (Maybe ClassExpression
 -> Cardinality ObjectPropertyExpression ClassExpression)
-> Maybe ClassExpression
-> Cardinality ObjectPropertyExpression ClassExpression
forall a b. (a -> b) -> a -> b
$ ClassExpression -> Maybe ClassExpression
forall a. a -> Maybe a
Just ClassExpression
p
           Right r :: DataRange
r -> case ObjectPropertyExpression
opExpr of
             ObjectProp dpExpr :: IRI
dpExpr ->
               ClassExpression -> CharParser st ClassExpression
forall (m :: * -> *) a. Monad m => a -> m a
return (ClassExpression -> CharParser st ClassExpression)
-> ClassExpression -> CharParser st ClassExpression
forall a b. (a -> b) -> a -> b
$ Cardinality IRI DataRange -> ClassExpression
DataCardinality (Cardinality IRI DataRange -> ClassExpression)
-> Cardinality IRI DataRange -> ClassExpression
forall a b. (a -> b) -> a -> b
$ CardinalityType
-> Int -> IRI -> Maybe DataRange -> Cardinality IRI DataRange
forall a b.
CardinalityType -> Int -> a -> Maybe b -> Cardinality a b
Cardinality CardinalityType
c Int
n IRI
dpExpr (Maybe DataRange -> Cardinality IRI DataRange)
-> Maybe DataRange -> Cardinality IRI DataRange
forall a b. (a -> b) -> a -> b
$ DataRange -> Maybe DataRange
forall a. a -> Maybe a
Just DataRange
r
             _ -> [Char] -> CharParser st ClassExpression
forall s (m :: * -> *) t u a.
Stream s m t =>
[Char] -> ParsecT s u m a
unexpected ([Char] -> CharParser st ClassExpression)
-> [Char] -> CharParser st ClassExpression
forall a b. (a -> b) -> a -> b
$ "dataRange after " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ CardinalityType -> [Char]
showCardinalityType CardinalityType
c

restriction :: GA.PrefixMap -> CharParser st ClassExpression
restriction :: PrefixMap -> CharParser st ClassExpression
restriction pm :: PrefixMap
pm = PrefixMap -> CharParser st ClassExpression
forall st. PrefixMap -> CharParser st ClassExpression
dataValuesFrom PrefixMap
pm CharParser st ClassExpression
-> CharParser st ClassExpression -> CharParser st ClassExpression
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (PrefixMap -> CharParser st ObjectPropertyExpression
forall st. PrefixMap -> CharParser st ObjectPropertyExpression
objectPropertyExpr PrefixMap
pm CharParser st ObjectPropertyExpression
-> (ObjectPropertyExpression -> CharParser st ClassExpression)
-> CharParser st ClassExpression
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= PrefixMap
-> ObjectPropertyExpression -> CharParser st ClassExpression
forall st.
PrefixMap
-> ObjectPropertyExpression -> CharParser st ClassExpression
restrictionAny PrefixMap
pm)

restrictionOrAtomic :: GA.PrefixMap -> CharParser st ClassExpression
restrictionOrAtomic :: PrefixMap -> CharParser st ClassExpression
restrictionOrAtomic pm :: PrefixMap
pm = PrefixMap -> CharParser st ClassExpression
forall st. PrefixMap -> CharParser st ClassExpression
dataValuesFrom PrefixMap
pm CharParser st ClassExpression
-> CharParser st ClassExpression -> CharParser st ClassExpression
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    ObjectPropertyExpression
opExpr <- PrefixMap -> CharParser st ObjectPropertyExpression
forall st. PrefixMap -> CharParser st ObjectPropertyExpression
objectPropertyExpr PrefixMap
pm
    PrefixMap
-> ObjectPropertyExpression -> CharParser st ClassExpression
forall st.
PrefixMap
-> ObjectPropertyExpression -> CharParser st ClassExpression
restrictionAny PrefixMap
pm ObjectPropertyExpression
opExpr CharParser st ClassExpression
-> CharParser st ClassExpression -> CharParser st ClassExpression
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> case ObjectPropertyExpression
opExpr of
       ObjectProp euri :: IRI
euri -> ClassExpression -> CharParser st ClassExpression
forall (m :: * -> *) a. Monad m => a -> m a
return (ClassExpression -> CharParser st ClassExpression)
-> ClassExpression -> CharParser st ClassExpression
forall a b. (a -> b) -> a -> b
$ IRI -> ClassExpression
Expression IRI
euri
       _ -> [Char] -> CharParser st ClassExpression
forall s (m :: * -> *) t u a.
Stream s m t =>
[Char] -> ParsecT s u m a
unexpected "inverse object property"
  CharParser st ClassExpression
-> CharParser st ClassExpression -> CharParser st ClassExpression
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> PrefixMap -> CharParser st ClassExpression
forall st. PrefixMap -> CharParser st ClassExpression
atomic PrefixMap
pm

optNot :: (a -> a) -> CharParser st a -> CharParser st a
optNot :: (a -> a) -> CharParser st a -> CharParser st a
optNot f :: a -> a
f p :: CharParser st a
p = ([Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
notS CharParser st () -> CharParser st a -> CharParser st a
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (a -> a) -> CharParser st a -> CharParser st a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
f CharParser st a
p) CharParser st a -> CharParser st a -> CharParser st a
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> CharParser st a
p

primary :: GA.PrefixMap -> CharParser st ClassExpression
primary :: PrefixMap -> CharParser st ClassExpression
primary pm :: PrefixMap
pm = (ClassExpression -> ClassExpression)
-> CharParser st ClassExpression -> CharParser st ClassExpression
forall a st. (a -> a) -> CharParser st a -> CharParser st a
optNot ClassExpression -> ClassExpression
ObjectComplementOf (PrefixMap -> CharParser st ClassExpression
forall st. PrefixMap -> CharParser st ClassExpression
restrictionOrAtomic PrefixMap
pm)

conjunction :: GA.PrefixMap -> CharParser st ClassExpression
conjunction :: PrefixMap -> CharParser st ClassExpression
conjunction pm :: PrefixMap
pm = do
    ClassExpression
curi <- IRI -> ClassExpression
Expression (IRI -> ClassExpression)
-> ParsecT [Char] st Identity IRI -> CharParser st ClassExpression
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT [Char] st Identity IRI -> ParsecT [Char] st Identity IRI
forall tok st a. GenParser tok st a -> GenParser tok st a
try (PrefixMap -> ParsecT [Char] st Identity IRI
forall st. PrefixMap -> CharParser st IRI
owlClassUri PrefixMap
pm ParsecT [Char] st Identity IRI
-> ParsecT [Char] st Identity () -> ParsecT [Char] st Identity IRI
forall (m :: * -> *) a b. Monad m => m a -> m b -> m a
<< [Char] -> ParsecT [Char] st Identity ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
thatS)
    [ClassExpression]
rs <- CharParser st ClassExpression
-> ParsecT [Char] st Identity ()
-> ParsecT [Char] st Identity [ClassExpression]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
sepBy1 ((ClassExpression -> ClassExpression)
-> CharParser st ClassExpression -> CharParser st ClassExpression
forall a st. (a -> a) -> CharParser st a -> CharParser st a
optNot ClassExpression -> ClassExpression
ObjectComplementOf (CharParser st ClassExpression -> CharParser st ClassExpression)
-> CharParser st ClassExpression -> CharParser st ClassExpression
forall a b. (a -> b) -> a -> b
$ PrefixMap -> CharParser st ClassExpression
forall st. PrefixMap -> CharParser st ClassExpression
restriction PrefixMap
pm) (ParsecT [Char] st Identity ()
 -> ParsecT [Char] st Identity [ClassExpression])
-> ParsecT [Char] st Identity ()
-> ParsecT [Char] st Identity [ClassExpression]
forall a b. (a -> b) -> a -> b
$ [Char] -> ParsecT [Char] st Identity ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
andS
    ClassExpression -> CharParser st ClassExpression
forall (m :: * -> *) a. Monad m => a -> m a
return (ClassExpression -> CharParser st ClassExpression)
-> ClassExpression -> CharParser st ClassExpression
forall a b. (a -> b) -> a -> b
$ JunctionType -> [ClassExpression] -> ClassExpression
mkObjectJunction JunctionType
IntersectionOf ([ClassExpression] -> ClassExpression)
-> [ClassExpression] -> ClassExpression
forall a b. (a -> b) -> a -> b
$ ClassExpression
curi ClassExpression -> [ClassExpression] -> [ClassExpression]
forall a. a -> [a] -> [a]
: [ClassExpression]
rs
  CharParser st ClassExpression
-> CharParser st ClassExpression -> CharParser st ClassExpression
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (JunctionType -> [ClassExpression] -> ClassExpression
mkObjectJunction JunctionType
IntersectionOf) ([ClassExpression] -> ClassExpression)
-> ParsecT [Char] st Identity [ClassExpression]
-> CharParser st ClassExpression
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
      (CharParser st ClassExpression
-> ParsecT [Char] st Identity ()
-> ParsecT [Char] st Identity [ClassExpression]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
sepBy1 (CharParser st ClassExpression -> CharParser st ClassExpression
forall st a. CharParser st a -> CharParser st a
skips (CharParser st ClassExpression -> CharParser st ClassExpression)
-> CharParser st ClassExpression -> CharParser st ClassExpression
forall a b. (a -> b) -> a -> b
$ PrefixMap -> CharParser st ClassExpression
forall st. PrefixMap -> CharParser st ClassExpression
primary PrefixMap
pm) ([Char] -> ParsecT [Char] st Identity ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
andS))

description :: GA.PrefixMap -> CharParser st ClassExpression
description :: PrefixMap -> CharParser st ClassExpression
description pm :: PrefixMap
pm =
  (JunctionType -> [ClassExpression] -> ClassExpression
mkObjectJunction JunctionType
UnionOf ([ClassExpression] -> ClassExpression)
-> ParsecT [Char] st Identity [ClassExpression]
-> CharParser st ClassExpression
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CharParser st ClassExpression
-> ParsecT [Char] st Identity ()
-> ParsecT [Char] st Identity [ClassExpression]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
sepBy1 (PrefixMap -> CharParser st ClassExpression
forall st. PrefixMap -> CharParser st ClassExpression
conjunction PrefixMap
pm) ([Char] -> ParsecT [Char] st Identity ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
orS))

{- | same as annotation Target in Manchester Syntax,
      named annotation Value in Abstract Syntax -}
annotationValue :: GA.PrefixMap -> CharParser st AnnotationValue
annotationValue :: PrefixMap -> CharParser st AnnotationValue
annotationValue pm :: PrefixMap
pm = do
    Literal
l <- PrefixMap -> CharParser st Literal
forall st. PrefixMap -> CharParser st Literal
literal PrefixMap
pm
    AnnotationValue -> CharParser st AnnotationValue
forall (m :: * -> *) a. Monad m => a -> m a
return (AnnotationValue -> CharParser st AnnotationValue)
-> AnnotationValue -> CharParser st AnnotationValue
forall a b. (a -> b) -> a -> b
$ Literal -> AnnotationValue
AnnValLit Literal
l
  CharParser st AnnotationValue
-> CharParser st AnnotationValue -> CharParser st AnnotationValue
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    IRI
i <- PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
individual PrefixMap
pm
    AnnotationValue -> CharParser st AnnotationValue
forall (m :: * -> *) a. Monad m => a -> m a
return (AnnotationValue -> CharParser st AnnotationValue)
-> AnnotationValue -> CharParser st AnnotationValue
forall a b. (a -> b) -> a -> b
$ IRI -> AnnotationValue
AnnValue IRI
i

equivOrDisjointL :: [EquivOrDisjoint]
equivOrDisjointL :: [EquivOrDisjoint]
equivOrDisjointL = [EquivOrDisjoint
Equivalent, EquivOrDisjoint
Disjoint]
objectPropertyCharacter :: 
  GA.PrefixMap ->
  ObjectPropertyExpression ->
  CharParser st ObjectPropertyAxiom
objectPropertyCharacter :: PrefixMap
-> ObjectPropertyExpression -> CharParser st ObjectPropertyAxiom
objectPropertyCharacter pm :: PrefixMap
pm oe :: ObjectPropertyExpression
oe = do
  Annotations
ans <- (PrefixMap -> CharParser st Annotations
forall st. PrefixMap -> CharParser st Annotations
optionalAnnos PrefixMap
pm)
  Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom
ctor <- (([Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
functionalS CharParser st ()
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
forall (m :: * -> *) a. Monad m => a -> m a
return Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom
FunctionalObjectProperty) ParsecT
  [Char]
  st
  Identity
  (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
    ([Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
inverseFunctionalS CharParser st ()
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
forall (m :: * -> *) a. Monad m => a -> m a
return Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom
InverseFunctionalObjectProperty) ParsecT
  [Char]
  st
  Identity
  (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
    ([Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
reflexiveS CharParser st ()
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
forall (m :: * -> *) a. Monad m => a -> m a
return Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom
ReflexiveObjectProperty) ParsecT
  [Char]
  st
  Identity
  (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
    ([Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
irreflexiveS CharParser st ()
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
forall (m :: * -> *) a. Monad m => a -> m a
return Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom
IrreflexiveObjectProperty) ParsecT
  [Char]
  st
  Identity
  (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
    ([Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
symmetricS CharParser st ()
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
forall (m :: * -> *) a. Monad m => a -> m a
return Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom
SymmetricObjectProperty) ParsecT
  [Char]
  st
  Identity
  (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
    ([Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
asymmetricS CharParser st ()
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
forall (m :: * -> *) a. Monad m => a -> m a
return Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom
AsymmetricObjectProperty) ParsecT
  [Char]
  st
  Identity
  (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
    ([Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
transitiveS CharParser st ()
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
-> ParsecT
     [Char]
     st
     Identity
     (Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom)
forall (m :: * -> *) a. Monad m => a -> m a
return Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom
TransitiveObjectProperty))
  ObjectPropertyAxiom -> CharParser st ObjectPropertyAxiom
forall (m :: * -> *) a. Monad m => a -> m a
return (ObjectPropertyAxiom -> CharParser st ObjectPropertyAxiom)
-> ObjectPropertyAxiom -> CharParser st ObjectPropertyAxiom
forall a b. (a -> b) -> a -> b
$ Annotations -> ObjectPropertyExpression -> ObjectPropertyAxiom
ctor Annotations
ans ObjectPropertyExpression
oe


optAnnos :: GA.PrefixMap -> CharParser st a -> CharParser st (Annotations, a)
optAnnos :: PrefixMap -> CharParser st a -> CharParser st (Annotations, a)
optAnnos pm :: PrefixMap
pm p :: CharParser st a
p = do
    Annotations
as <- PrefixMap -> CharParser st Annotations
forall st. PrefixMap -> CharParser st Annotations
optionalAnnos PrefixMap
pm
    a
a <- CharParser st a
p
    (Annotations, a) -> CharParser st (Annotations, a)
forall (m :: * -> *) a. Monad m => a -> m a
return (Annotations
as, a
a)

optionalAnnos :: GA.PrefixMap -> CharParser st Annotations
optionalAnnos :: PrefixMap -> CharParser st Annotations
optionalAnnos pm :: PrefixMap
pm = Annotations
-> CharParser st Annotations -> CharParser st Annotations
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option [] (CharParser st Annotations -> CharParser st Annotations)
-> CharParser st Annotations -> CharParser st Annotations
forall a b. (a -> b) -> a -> b
$ CharParser st Annotations -> CharParser st Annotations
forall tok st a. GenParser tok st a -> GenParser tok st a
try (CharParser st Annotations -> CharParser st Annotations)
-> CharParser st Annotations -> CharParser st Annotations
forall a b. (a -> b) -> a -> b
$ PrefixMap -> CharParser st Annotations
forall st. PrefixMap -> CharParser st Annotations
annotations PrefixMap
pm

annotations :: GA.PrefixMap -> CharParser st Annotations
annotations :: PrefixMap -> CharParser st Annotations
annotations pm :: PrefixMap
pm = do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
annotationsC
    [(Annotations, (IRI, AnnotationValue))]
as <- CharParser st (Annotations, (IRI, AnnotationValue))
-> CharParser st [(Annotations, (IRI, AnnotationValue))]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (CharParser st (Annotations, (IRI, AnnotationValue))
 -> CharParser st [(Annotations, (IRI, AnnotationValue))])
-> CharParser st (Annotations, (IRI, AnnotationValue))
-> CharParser st [(Annotations, (IRI, AnnotationValue))]
forall a b. (a -> b) -> a -> b
$ PrefixMap
-> CharParser st (IRI, AnnotationValue)
-> CharParser st (Annotations, (IRI, AnnotationValue))
forall st a.
PrefixMap -> CharParser st a -> CharParser st (Annotations, a)
optAnnos PrefixMap
pm (CharParser st (IRI, AnnotationValue)
 -> CharParser st (Annotations, (IRI, AnnotationValue)))
-> CharParser st (IRI, AnnotationValue)
-> CharParser st (Annotations, (IRI, AnnotationValue))
forall a b. (a -> b) -> a -> b
$ CharParser st (IRI, AnnotationValue)
-> CharParser st (IRI, AnnotationValue)
forall tok st a. GenParser tok st a -> GenParser tok st a
try (CharParser st (IRI, AnnotationValue)
 -> CharParser st (IRI, AnnotationValue))
-> CharParser st (IRI, AnnotationValue)
-> CharParser st (IRI, AnnotationValue)
forall a b. (a -> b) -> a -> b
$ ParsecT [Char] st Identity IRI
-> ParsecT [Char] st Identity AnnotationValue
-> CharParser st (IRI, AnnotationValue)
forall (m :: * -> *) a b. Monad m => m a -> m b -> m (a, b)
pair (PrefixMap -> ParsecT [Char] st Identity IRI
forall st. PrefixMap -> CharParser st IRI
expUriP PrefixMap
pm) (ParsecT [Char] st Identity AnnotationValue
-> ParsecT [Char] st Identity AnnotationValue
forall st a. CharParser st a -> CharParser st a
skips (ParsecT [Char] st Identity AnnotationValue
 -> ParsecT [Char] st Identity AnnotationValue)
-> ParsecT [Char] st Identity AnnotationValue
-> ParsecT [Char] st Identity AnnotationValue
forall a b. (a -> b) -> a -> b
$ PrefixMap -> ParsecT [Char] st Identity AnnotationValue
forall st. PrefixMap -> CharParser st AnnotationValue
annotationValue PrefixMap
pm)
    Annotations -> CharParser st Annotations
forall (m :: * -> *) a. Monad m => a -> m a
return (Annotations -> CharParser st Annotations)
-> Annotations -> CharParser st Annotations
forall a b. (a -> b) -> a -> b
$ ((Annotations, (IRI, AnnotationValue)) -> Annotation)
-> [(Annotations, (IRI, AnnotationValue))] -> Annotations
forall a b. (a -> b) -> [a] -> [b]
map (\(anns :: Annotations
anns, (source :: IRI
source, target :: AnnotationValue
target)) -> Annotations -> IRI -> AnnotationValue -> Annotation
Annotation Annotations
anns IRI
source AnnotationValue
target) [(Annotations, (IRI, AnnotationValue))]
as

descriptionAnnotatedList :: GA.PrefixMap -> CharParser st [(Annotations, ClassExpression)]
descriptionAnnotatedList :: PrefixMap -> CharParser st [(Annotations, ClassExpression)]
descriptionAnnotatedList pm :: PrefixMap
pm = CharParser st (Annotations, ClassExpression)
-> CharParser st [(Annotations, ClassExpression)]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (CharParser st (Annotations, ClassExpression)
 -> CharParser st [(Annotations, ClassExpression)])
-> CharParser st (Annotations, ClassExpression)
-> CharParser st [(Annotations, ClassExpression)]
forall a b. (a -> b) -> a -> b
$ PrefixMap
-> CharParser st ClassExpression
-> CharParser st (Annotations, ClassExpression)
forall st a.
PrefixMap -> CharParser st a -> CharParser st (Annotations, a)
optAnnos PrefixMap
pm (PrefixMap -> CharParser st ClassExpression
forall st. PrefixMap -> CharParser st ClassExpression
description PrefixMap
pm)

annotationPropertyFrame :: GA.PrefixMap -> CharParser st [Axiom]
annotationPropertyFrame :: PrefixMap -> CharParser st [Axiom]
annotationPropertyFrame pm :: PrefixMap
pm = do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
annotationPropertyC
    Annotations
annos <- PrefixMap -> CharParser st Annotations
forall st. PrefixMap -> CharParser st Annotations
optionalAnnos PrefixMap
pm
    IRI
ap <- (PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
expUriP PrefixMap
pm)
    [[Axiom]]
x <- CharParser st [Axiom] -> ParsecT [Char] st Identity [[Axiom]]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (CharParser st [Axiom] -> ParsecT [Char] st Identity [[Axiom]])
-> CharParser st [Axiom] -> ParsecT [Char] st Identity [[Axiom]]
forall a b. (a -> b) -> a -> b
$ CharParser st [Axiom] -> CharParser st [Axiom]
forall tok st a. GenParser tok st a -> GenParser tok st a
try (CharParser st [Axiom] -> CharParser st [Axiom])
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ PrefixMap -> IRI -> CharParser st [Axiom]
forall st. PrefixMap -> IRI -> CharParser st [Axiom]
apSection PrefixMap
pm IRI
ap
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ Annotations -> Entity -> Axiom
Declaration Annotations
annos (EntityType -> IRI -> Entity
mkEntity EntityType
AnnotationProperty IRI
ap) Axiom -> [Axiom] -> [Axiom]
forall a. a -> [a] -> [a]
: [[Axiom]] -> [Axiom]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[Axiom]]
x

apSection :: GA.PrefixMap -> AnnotationProperty -> CharParser st [Axiom]
apSection :: PrefixMap -> IRI -> CharParser st [Axiom]
apSection pm :: PrefixMap
pm p :: IRI
p = do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
subPropertyOfC
    [(Annotations, IRI)]
as <- CharParser st (Annotations, IRI)
-> CharParser st [(Annotations, IRI)]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (CharParser st (Annotations, IRI)
 -> CharParser st [(Annotations, IRI)])
-> CharParser st (Annotations, IRI)
-> CharParser st [(Annotations, IRI)]
forall a b. (a -> b) -> a -> b
$ PrefixMap -> CharParser st IRI -> CharParser st (Annotations, IRI)
forall st a.
PrefixMap -> CharParser st a -> CharParser st (Annotations, a)
optAnnos PrefixMap
pm (PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
expUriP PrefixMap
pm)
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ ((Annotations, IRI) -> Axiom) -> [(Annotations, IRI)] -> [Axiom]
forall a b. (a -> b) -> [a] -> [b]
map (\(ans :: Annotations
ans, i :: IRI
i) -> AnnotationAxiom -> Axiom
AnnotationAxiom (AnnotationAxiom -> Axiom) -> AnnotationAxiom -> Axiom
forall a b. (a -> b) -> a -> b
$ Annotations -> IRI -> IRI -> AnnotationAxiom
SubAnnotationPropertyOf Annotations
ans IRI
p IRI
i) [(Annotations, IRI)]
as
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
domainC
    [(Annotations, IRI)]
as <- CharParser st (Annotations, IRI)
-> CharParser st [(Annotations, IRI)]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (CharParser st (Annotations, IRI)
 -> CharParser st [(Annotations, IRI)])
-> CharParser st (Annotations, IRI)
-> CharParser st [(Annotations, IRI)]
forall a b. (a -> b) -> a -> b
$ (PrefixMap -> CharParser st IRI -> CharParser st (Annotations, IRI)
forall st a.
PrefixMap -> CharParser st a -> CharParser st (Annotations, a)
optAnnos PrefixMap
pm) (PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
expUriP PrefixMap
pm)
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ ((Annotations, IRI) -> Axiom) -> [(Annotations, IRI)] -> [Axiom]
forall a b. (a -> b) -> [a] -> [b]
map (\(ans :: Annotations
ans, i :: IRI
i) -> AnnotationAxiom -> Axiom
AnnotationAxiom (AnnotationAxiom -> Axiom) -> AnnotationAxiom -> Axiom
forall a b. (a -> b) -> a -> b
$ Annotations -> IRI -> IRI -> AnnotationAxiom
AnnotationPropertyDomain Annotations
ans IRI
p IRI
i) [(Annotations, IRI)]
as
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
rangeC
    [(Annotations, IRI)]
as <- CharParser st (Annotations, IRI)
-> CharParser st [(Annotations, IRI)]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (CharParser st (Annotations, IRI)
 -> CharParser st [(Annotations, IRI)])
-> CharParser st (Annotations, IRI)
-> CharParser st [(Annotations, IRI)]
forall a b. (a -> b) -> a -> b
$ (PrefixMap -> CharParser st IRI -> CharParser st (Annotations, IRI)
forall st a.
PrefixMap -> CharParser st a -> CharParser st (Annotations, a)
optAnnos PrefixMap
pm) (PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
expUriP PrefixMap
pm)
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ ((Annotations, IRI) -> Axiom) -> [(Annotations, IRI)] -> [Axiom]
forall a b. (a -> b) -> [a] -> [b]
map (\(ans :: Annotations
ans, i :: IRI
i) -> AnnotationAxiom -> Axiom
AnnotationAxiom (AnnotationAxiom -> Axiom) -> AnnotationAxiom -> Axiom
forall a b. (a -> b) -> a -> b
$ Annotations -> IRI -> IRI -> AnnotationAxiom
AnnotationPropertyRange Annotations
ans IRI
p IRI
i) [(Annotations, IRI)]
as
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> PrefixMap -> AnnotationSubject -> CharParser st [Axiom]
forall st. PrefixMap -> AnnotationSubject -> CharParser st [Axiom]
parseAnnotationAssertions PrefixMap
pm (IRI -> AnnotationSubject
AnnSubIri IRI
p)


parseDatatypeFrame :: GA.PrefixMap -> CharParser st [Axiom]
parseDatatypeFrame :: PrefixMap -> CharParser st [Axiom]
parseDatatypeFrame pm :: PrefixMap
pm = do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
datatypeC
    Annotations
annos <- PrefixMap -> CharParser st Annotations
forall st. PrefixMap -> CharParser st Annotations
optionalAnnos PrefixMap
pm
    IRI
iri <- PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
datatypeUri PrefixMap
pm
    [Axiom]
axs <- [Axiom] -> CharParser st [Axiom] -> CharParser st [Axiom]
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option [] (CharParser st [Axiom] -> CharParser st [Axiom]
forall tok st a. GenParser tok st a -> GenParser tok st a
try (CharParser st [Axiom] -> CharParser st [Axiom])
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ (do
        [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
equivalentToC
        [Annotations]
ans <- CharParser st Annotations
-> ParsecT [Char] st Identity [Annotations]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (CharParser st Annotations
 -> ParsecT [Char] st Identity [Annotations])
-> CharParser st Annotations
-> ParsecT [Char] st Identity [Annotations]
forall a b. (a -> b) -> a -> b
$ PrefixMap -> CharParser st Annotations
forall st. PrefixMap -> CharParser st Annotations
annotations PrefixMap
pm
        DataRange
range <- PrefixMap -> CharParser st DataRange
forall st. PrefixMap -> CharParser st DataRange
dataRange PrefixMap
pm
        [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return [Annotations -> IRI -> DataRange -> Axiom
DatatypeDefinition ([Annotations] -> Annotations
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [Annotations]
ans) IRI
iri DataRange
range]
      ) CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> PrefixMap -> AnnotationSubject -> CharParser st [Axiom]
forall st. PrefixMap -> AnnotationSubject -> CharParser st [Axiom]
parseAnnotationAssertions PrefixMap
pm (IRI -> AnnotationSubject
AnnSubIri IRI
iri))
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ Annotations -> Entity -> Axiom
Declaration Annotations
annos (EntityType -> IRI -> Entity
mkEntity EntityType
Datatype IRI
iri) Axiom -> [Axiom] -> [Axiom]
forall a. a -> [a] -> [a]
: [Axiom]
axs

classFrame :: GA.PrefixMap -> CharParser st [Axiom]
classFrame :: PrefixMap -> CharParser st [Axiom]
classFrame pm :: PrefixMap
pm = do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
classC
    Annotations
annos <- PrefixMap -> CharParser st Annotations
forall st. PrefixMap -> CharParser st Annotations
optionalAnnos PrefixMap
pm
    ClassExpression
desc <- PrefixMap -> CharParser st ClassExpression
forall st. PrefixMap -> CharParser st ClassExpression
description PrefixMap
pm
    [[Axiom]]
axs <- CharParser st [Axiom] -> ParsecT [Char] st Identity [[Axiom]]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (CharParser st [Axiom] -> ParsecT [Char] st Identity [[Axiom]])
-> CharParser st [Axiom] -> ParsecT [Char] st Identity [[Axiom]]
forall a b. (a -> b) -> a -> b
$ PrefixMap -> ClassExpression -> CharParser st [Axiom]
forall st. PrefixMap -> ClassExpression -> CharParser st [Axiom]
classFrameSection PrefixMap
pm ClassExpression
desc
    -- ignore Individuals: ... !
    -- optional $ pkeyword individualsC >> sepByComma (individual pm)
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ case ClassExpression
desc of
      Expression i :: IRI
i -> Annotations -> Entity -> Axiom
Declaration Annotations
annos (EntityType -> IRI -> Entity
mkEntity EntityType
Class IRI
i) Axiom -> [Axiom] -> [Axiom]
forall a. a -> [a] -> [a]
: [[Axiom]] -> [Axiom]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[Axiom]]
axs
      _ -> [[Axiom]] -> [Axiom]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[Axiom]]
axs

classFrameSection :: GA.PrefixMap -> ClassExpression -> CharParser st [Axiom]
classFrameSection :: PrefixMap -> ClassExpression -> CharParser st [Axiom]
classFrameSection pm :: PrefixMap
pm e :: ClassExpression
e =
  do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
subClassOfC
    [(Annotations, ClassExpression)]
ds <- PrefixMap -> CharParser st [(Annotations, ClassExpression)]
forall st.
PrefixMap -> CharParser st [(Annotations, ClassExpression)]
descriptionAnnotatedList PrefixMap
pm
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ ((Annotations, ClassExpression) -> Axiom)
-> [(Annotations, ClassExpression)] -> [Axiom]
forall a b. (a -> b) -> [a] -> [b]
map (\(anns :: Annotations
anns, desc :: ClassExpression
desc) -> ClassAxiom -> Axiom
ClassAxiom (ClassAxiom -> Axiom) -> ClassAxiom -> Axiom
forall a b. (a -> b) -> a -> b
$ Annotations -> ClassExpression -> ClassExpression -> ClassAxiom
SubClassOf Annotations
anns ClassExpression
e ClassExpression
desc) [(Annotations, ClassExpression)]
ds
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
equivalentToC
    [(Annotations, ClassExpression)]
ds <- PrefixMap -> CharParser st [(Annotations, ClassExpression)]
forall st.
PrefixMap -> CharParser st [(Annotations, ClassExpression)]
descriptionAnnotatedList PrefixMap
pm
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ ((Annotations, ClassExpression) -> Axiom)
-> [(Annotations, ClassExpression)] -> [Axiom]
forall a b. (a -> b) -> [a] -> [b]
map (\(anns :: Annotations
anns, desc :: ClassExpression
desc) -> ClassAxiom -> Axiom
ClassAxiom (ClassAxiom -> Axiom) -> ClassAxiom -> Axiom
forall a b. (a -> b) -> a -> b
$ Annotations -> [ClassExpression] -> ClassAxiom
EquivalentClasses Annotations
anns [ClassExpression
e, ClassExpression
desc]) [(Annotations, ClassExpression)]
ds
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
disjointWithC
    [(Annotations, ClassExpression)]
ds <- PrefixMap -> CharParser st [(Annotations, ClassExpression)]
forall st.
PrefixMap -> CharParser st [(Annotations, ClassExpression)]
descriptionAnnotatedList PrefixMap
pm
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ ((Annotations, ClassExpression) -> Axiom)
-> [(Annotations, ClassExpression)] -> [Axiom]
forall a b. (a -> b) -> [a] -> [b]
map (\(anns :: Annotations
anns, desc :: ClassExpression
desc) -> ClassAxiom -> Axiom
ClassAxiom (ClassAxiom -> Axiom) -> ClassAxiom -> Axiom
forall a b. (a -> b) -> a -> b
$ Annotations -> [ClassExpression] -> ClassAxiom
DisjointClasses Annotations
anns [ClassExpression
e, ClassExpression
desc]) [(Annotations, ClassExpression)]
ds
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
disjointUnionOfC
    Annotations
as <- PrefixMap -> CharParser st Annotations
forall st. PrefixMap -> CharParser st Annotations
optionalAnnos PrefixMap
pm
    [ClassExpression]
ds <- CharParser st ClassExpression -> CharParser st [ClassExpression]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (CharParser st ClassExpression -> CharParser st [ClassExpression])
-> CharParser st ClassExpression -> CharParser st [ClassExpression]
forall a b. (a -> b) -> a -> b
$ PrefixMap -> CharParser st ClassExpression
forall st. PrefixMap -> CharParser st ClassExpression
description PrefixMap
pm
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return [ClassAxiom -> Axiom
ClassAxiom (ClassAxiom -> Axiom) -> ClassAxiom -> Axiom
forall a b. (a -> b) -> a -> b
$ Annotations -> [ClassExpression] -> ClassAxiom
DisjointClasses Annotations
as (ClassExpression
e ClassExpression -> [ClassExpression] -> [ClassExpression]
forall a. a -> [a] -> [a]
: [ClassExpression]
ds)]
      
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
hasKeyC
    Annotations
as <- PrefixMap -> CharParser st Annotations
forall st. PrefixMap -> CharParser st Annotations
optionalAnnos PrefixMap
pm
    ([ObjectPropertyExpression], [IRI])
props <- PrefixMap -> CharParser st ([ObjectPropertyExpression], [IRI])
forall st.
PrefixMap -> CharParser st ([ObjectPropertyExpression], [IRI])
parseProperties PrefixMap
pm
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return [Annotations
-> ClassExpression -> [ObjectPropertyExpression] -> [IRI] -> Axiom
HasKey Annotations
as ClassExpression
e (([ObjectPropertyExpression], [IRI]) -> [ObjectPropertyExpression]
forall a b. (a, b) -> a
fst ([ObjectPropertyExpression], [IRI])
props) (([ObjectPropertyExpression], [IRI]) -> [IRI]
forall a b. (a, b) -> b
snd ([ObjectPropertyExpression], [IRI])
props)]
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    -- This section is only created by the OWL API and is not defined in the standard.
    -- It only duplicates information see https://github.com/owlcs/owlapi/issues/1006
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword "Individuals:"
    CharParser st IRI -> CharParser st [IRI]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (CharParser st IRI -> CharParser st [IRI])
-> CharParser st IRI -> CharParser st [IRI]
forall a b. (a -> b) -> a -> b
$ PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
individual PrefixMap
pm
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return []
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> case ClassExpression
e of
    Expression i :: IRI
i -> PrefixMap -> AnnotationSubject -> CharParser st [Axiom]
forall st. PrefixMap -> AnnotationSubject -> CharParser st [Axiom]
parseAnnotationAssertions PrefixMap
pm (IRI -> AnnotationSubject
AnnSubIri IRI
i)
    _ -> [Char] -> CharParser st [Axiom]
forall s (m :: * -> *) t u a.
Stream s m t =>
[Char] -> ParsecT s u m a
unexpected "Annotation for class expression"

parseAnnotationAssertions :: GA.PrefixMap -> AnnotationSubject -> CharParser st [Axiom]
parseAnnotationAssertions :: PrefixMap -> AnnotationSubject -> CharParser st [Axiom]
parseAnnotationAssertions pm :: PrefixMap
pm s :: AnnotationSubject
s = do
    Annotations
a <- PrefixMap -> CharParser st Annotations
forall st. PrefixMap -> CharParser st Annotations
annotations PrefixMap
pm
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ ((Annotation -> Axiom) -> Annotations -> [Axiom]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\an :: Annotation
an -> AnnotationAxiom -> Axiom
AnnotationAxiom (AnnotationAxiom -> Axiom) -> AnnotationAxiom -> Axiom
forall a b. (a -> b) -> a -> b
$ Annotations
-> IRI -> AnnotationSubject -> AnnotationValue -> AnnotationAxiom
AnnotationAssertion [] (Annotation -> IRI
annProperty Annotation
an) AnnotationSubject
s (Annotation -> AnnotationValue
annValue Annotation
an)) Annotations
a)

objPropExprAList :: GA.PrefixMap -> CharParser st [(Annotations, ObjectPropertyExpression)]
objPropExprAList :: PrefixMap
-> CharParser st [(Annotations, ObjectPropertyExpression)]
objPropExprAList pm :: PrefixMap
pm = CharParser st (Annotations, ObjectPropertyExpression)
-> CharParser st [(Annotations, ObjectPropertyExpression)]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (CharParser st (Annotations, ObjectPropertyExpression)
 -> CharParser st [(Annotations, ObjectPropertyExpression)])
-> CharParser st (Annotations, ObjectPropertyExpression)
-> CharParser st [(Annotations, ObjectPropertyExpression)]
forall a b. (a -> b) -> a -> b
$ PrefixMap
-> CharParser st ObjectPropertyExpression
-> CharParser st (Annotations, ObjectPropertyExpression)
forall st a.
PrefixMap -> CharParser st a -> CharParser st (Annotations, a)
optAnnos PrefixMap
pm (CharParser st ObjectPropertyExpression
 -> CharParser st (Annotations, ObjectPropertyExpression))
-> CharParser st ObjectPropertyExpression
-> CharParser st (Annotations, ObjectPropertyExpression)
forall a b. (a -> b) -> a -> b
$ PrefixMap -> CharParser st ObjectPropertyExpression
forall st. PrefixMap -> CharParser st ObjectPropertyExpression
objectPropertyExpr PrefixMap
pm

objectPropertyFrameSection :: GA.PrefixMap -> ObjectPropertyExpression -> CharParser st [Axiom]
objectPropertyFrameSection :: PrefixMap -> ObjectPropertyExpression -> CharParser st [Axiom]
objectPropertyFrameSection pm :: PrefixMap
pm oe :: ObjectPropertyExpression
oe =
  do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
domainC
    [(Annotations, ClassExpression)]
ds <- PrefixMap -> CharParser st [(Annotations, ClassExpression)]
forall st.
PrefixMap -> CharParser st [(Annotations, ClassExpression)]
descriptionAnnotatedList PrefixMap
pm
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ ((Annotations, ClassExpression) -> Axiom)
-> [(Annotations, ClassExpression)] -> [Axiom]
forall a b. (a -> b) -> [a] -> [b]
map (\(anns :: Annotations
anns, desc :: ClassExpression
desc) -> ObjectPropertyAxiom -> Axiom
ObjectPropertyAxiom (ObjectPropertyAxiom -> Axiom) -> ObjectPropertyAxiom -> Axiom
forall a b. (a -> b) -> a -> b
$ Annotations
-> ObjectPropertyExpression
-> ClassExpression
-> ObjectPropertyAxiom
ObjectPropertyDomain Annotations
anns ObjectPropertyExpression
oe ClassExpression
desc) [(Annotations, ClassExpression)]
ds
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
rangeC
    [(Annotations, ClassExpression)]
ds <- PrefixMap -> CharParser st [(Annotations, ClassExpression)]
forall st.
PrefixMap -> CharParser st [(Annotations, ClassExpression)]
descriptionAnnotatedList PrefixMap
pm
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ ((Annotations, ClassExpression) -> Axiom)
-> [(Annotations, ClassExpression)] -> [Axiom]
forall a b. (a -> b) -> [a] -> [b]
map (\(anns :: Annotations
anns, desc :: ClassExpression
desc) -> ObjectPropertyAxiom -> Axiom
ObjectPropertyAxiom (ObjectPropertyAxiom -> Axiom) -> ObjectPropertyAxiom -> Axiom
forall a b. (a -> b) -> a -> b
$ Annotations
-> ObjectPropertyExpression
-> ClassExpression
-> ObjectPropertyAxiom
ObjectPropertyRange Annotations
anns ObjectPropertyExpression
oe ClassExpression
desc) [(Annotations, ClassExpression)]
ds
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
characteristicsC
    [ObjectPropertyAxiom]
ax <- CharParser st ObjectPropertyAxiom
-> CharParser st [ObjectPropertyAxiom]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (CharParser st ObjectPropertyAxiom
 -> CharParser st [ObjectPropertyAxiom])
-> CharParser st ObjectPropertyAxiom
-> CharParser st [ObjectPropertyAxiom]
forall a b. (a -> b) -> a -> b
$ PrefixMap
-> ObjectPropertyExpression -> CharParser st ObjectPropertyAxiom
forall st.
PrefixMap
-> ObjectPropertyExpression -> CharParser st ObjectPropertyAxiom
objectPropertyCharacter PrefixMap
pm ObjectPropertyExpression
oe
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ ObjectPropertyAxiom -> Axiom
ObjectPropertyAxiom (ObjectPropertyAxiom -> Axiom) -> [ObjectPropertyAxiom] -> [Axiom]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [ObjectPropertyAxiom]
ax
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
subPropertyOfC
    [(Annotations, ObjectPropertyExpression)]
ds <- PrefixMap
-> CharParser st [(Annotations, ObjectPropertyExpression)]
forall st.
PrefixMap
-> CharParser st [(Annotations, ObjectPropertyExpression)]
objPropExprAList PrefixMap
pm
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ ((Annotations, ObjectPropertyExpression) -> Axiom)
-> [(Annotations, ObjectPropertyExpression)] -> [Axiom]
forall a b. (a -> b) -> [a] -> [b]
map (\(anns :: Annotations
anns, desc :: ObjectPropertyExpression
desc) -> ObjectPropertyAxiom -> Axiom
ObjectPropertyAxiom (ObjectPropertyAxiom -> Axiom) -> ObjectPropertyAxiom -> Axiom
forall a b. (a -> b) -> a -> b
$ Annotations
-> SubObjectPropertyExpression
-> ObjectPropertyExpression
-> ObjectPropertyAxiom
SubObjectPropertyOf Annotations
anns (ObjectPropertyExpression -> SubObjectPropertyExpression
SubObjPropExpr_obj ObjectPropertyExpression
oe) ObjectPropertyExpression
desc) [(Annotations, ObjectPropertyExpression)]
ds
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
equivalentToC
    [(Annotations, ObjectPropertyExpression)]
ds <- PrefixMap
-> CharParser st [(Annotations, ObjectPropertyExpression)]
forall st.
PrefixMap
-> CharParser st [(Annotations, ObjectPropertyExpression)]
objPropExprAList PrefixMap
pm
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ ((Annotations, ObjectPropertyExpression) -> Axiom)
-> [(Annotations, ObjectPropertyExpression)] -> [Axiom]
forall a b. (a -> b) -> [a] -> [b]
map (\(anns :: Annotations
anns, desc :: ObjectPropertyExpression
desc) -> ObjectPropertyAxiom -> Axiom
ObjectPropertyAxiom (ObjectPropertyAxiom -> Axiom) -> ObjectPropertyAxiom -> Axiom
forall a b. (a -> b) -> a -> b
$ Annotations -> [ObjectPropertyExpression] -> ObjectPropertyAxiom
EquivalentObjectProperties Annotations
anns [ObjectPropertyExpression
oe, ObjectPropertyExpression
desc]) [(Annotations, ObjectPropertyExpression)]
ds
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
disjointWithC
    [(Annotations, ObjectPropertyExpression)]
ds <- PrefixMap
-> CharParser st [(Annotations, ObjectPropertyExpression)]
forall st.
PrefixMap
-> CharParser st [(Annotations, ObjectPropertyExpression)]
objPropExprAList PrefixMap
pm
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ ((Annotations, ObjectPropertyExpression) -> Axiom)
-> [(Annotations, ObjectPropertyExpression)] -> [Axiom]
forall a b. (a -> b) -> [a] -> [b]
map (\(anns :: Annotations
anns, desc :: ObjectPropertyExpression
desc) -> ObjectPropertyAxiom -> Axiom
ObjectPropertyAxiom (ObjectPropertyAxiom -> Axiom) -> ObjectPropertyAxiom -> Axiom
forall a b. (a -> b) -> a -> b
$ Annotations -> [ObjectPropertyExpression] -> ObjectPropertyAxiom
DisjointObjectProperties Annotations
anns [ObjectPropertyExpression
oe, ObjectPropertyExpression
desc]) [(Annotations, ObjectPropertyExpression)]
ds
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
inverseOfC
    [(Annotations, ObjectPropertyExpression)]
ds <- PrefixMap
-> CharParser st [(Annotations, ObjectPropertyExpression)]
forall st.
PrefixMap
-> CharParser st [(Annotations, ObjectPropertyExpression)]
objPropExprAList PrefixMap
pm
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ ((Annotations, ObjectPropertyExpression) -> Axiom)
-> [(Annotations, ObjectPropertyExpression)] -> [Axiom]
forall a b. (a -> b) -> [a] -> [b]
map (\(anns :: Annotations
anns, desc :: ObjectPropertyExpression
desc) -> ObjectPropertyAxiom -> Axiom
ObjectPropertyAxiom (ObjectPropertyAxiom -> Axiom) -> ObjectPropertyAxiom -> Axiom
forall a b. (a -> b) -> a -> b
$ Annotations
-> ObjectPropertyExpression
-> ObjectPropertyExpression
-> ObjectPropertyAxiom
InverseObjectProperties Annotations
anns ObjectPropertyExpression
oe ObjectPropertyExpression
desc) [(Annotations, ObjectPropertyExpression)]
ds
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
subPropertyChainC
    Annotations
as <- PrefixMap -> CharParser st Annotations
forall st. PrefixMap -> CharParser st Annotations
optionalAnnos PrefixMap
pm
    [ObjectPropertyExpression]
os <- ParsecT [Char] st Identity ObjectPropertyExpression
-> CharParser st ()
-> ParsecT [Char] st Identity [ObjectPropertyExpression]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
sepBy1 (PrefixMap -> ParsecT [Char] st Identity ObjectPropertyExpression
forall st. PrefixMap -> CharParser st ObjectPropertyExpression
objectPropertyExpr PrefixMap
pm) ([Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
oS)
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return [ObjectPropertyAxiom -> Axiom
ObjectPropertyAxiom (ObjectPropertyAxiom -> Axiom) -> ObjectPropertyAxiom -> Axiom
forall a b. (a -> b) -> a -> b
$ Annotations
-> SubObjectPropertyExpression
-> ObjectPropertyExpression
-> ObjectPropertyAxiom
SubObjectPropertyOf Annotations
as ([ObjectPropertyExpression] -> SubObjectPropertyExpression
SubObjPropExpr_exprchain [ObjectPropertyExpression]
os) ObjectPropertyExpression
oe]
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> case ObjectPropertyExpression
oe of
    ObjectProp i :: IRI
i -> PrefixMap -> AnnotationSubject -> CharParser st [Axiom]
forall st. PrefixMap -> AnnotationSubject -> CharParser st [Axiom]
parseAnnotationAssertions PrefixMap
pm (IRI -> AnnotationSubject
AnnSubIri IRI
i)
    _ -> [Char] -> CharParser st [Axiom]
forall s (m :: * -> *) t u a.
Stream s m t =>
[Char] -> ParsecT s u m a
unexpected "Annotation for object property expression"

objectPropertyFrame :: GA.PrefixMap -> CharParser st [Axiom]
objectPropertyFrame :: PrefixMap -> CharParser st [Axiom]
objectPropertyFrame pm :: PrefixMap
pm = do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
objectPropertyC
    Annotations
annos <- PrefixMap -> CharParser st Annotations
forall st. PrefixMap -> CharParser st Annotations
optionalAnnos PrefixMap
pm
    ObjectPropertyExpression
oe <- PrefixMap -> CharParser st ObjectPropertyExpression
forall st. PrefixMap -> CharParser st ObjectPropertyExpression
objectPropertyExpr PrefixMap
pm
    [[Axiom]]
sections <- CharParser st [Axiom] -> ParsecT [Char] st Identity [[Axiom]]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (CharParser st [Axiom] -> ParsecT [Char] st Identity [[Axiom]])
-> CharParser st [Axiom] -> ParsecT [Char] st Identity [[Axiom]]
forall a b. (a -> b) -> a -> b
$ PrefixMap -> ObjectPropertyExpression -> CharParser st [Axiom]
forall st.
PrefixMap -> ObjectPropertyExpression -> CharParser st [Axiom]
objectPropertyFrameSection PrefixMap
pm ObjectPropertyExpression
oe
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ case ObjectPropertyExpression
oe of
      ObjectProp i :: IRI
i -> Annotations -> Entity -> Axiom
Declaration Annotations
annos (EntityType -> IRI -> Entity
mkEntity EntityType
ObjectProperty IRI
i) Axiom -> [Axiom] -> [Axiom]
forall a. a -> [a] -> [a]
: [[Axiom]] -> [Axiom]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[Axiom]]
sections
      _ -> [[Axiom]] -> [Axiom]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[Axiom]]
sections

dataPropExprAList :: GA.PrefixMap -> CharParser st [(Annotations, DataPropertyExpression)]
dataPropExprAList :: PrefixMap -> CharParser st [(Annotations, IRI)]
dataPropExprAList pm :: PrefixMap
pm = CharParser st (Annotations, IRI)
-> CharParser st [(Annotations, IRI)]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (CharParser st (Annotations, IRI)
 -> CharParser st [(Annotations, IRI)])
-> CharParser st (Annotations, IRI)
-> CharParser st [(Annotations, IRI)]
forall a b. (a -> b) -> a -> b
$ (PrefixMap -> CharParser st IRI -> CharParser st (Annotations, IRI)
forall st a.
PrefixMap -> CharParser st a -> CharParser st (Annotations, a)
optAnnos PrefixMap
pm) (PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
expUriP PrefixMap
pm)


dataFrameSection :: GA.PrefixMap -> DataPropertyExpression -> CharParser st [Axiom]
dataFrameSection :: PrefixMap -> IRI -> CharParser st [Axiom]
dataFrameSection pm :: PrefixMap
pm de :: IRI
de = do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
domainC
    [(Annotations, ClassExpression)]
ds <- PrefixMap -> CharParser st [(Annotations, ClassExpression)]
forall st.
PrefixMap -> CharParser st [(Annotations, ClassExpression)]
descriptionAnnotatedList PrefixMap
pm
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ ((Annotations, ClassExpression) -> Axiom)
-> [(Annotations, ClassExpression)] -> [Axiom]
forall a b. (a -> b) -> [a] -> [b]
map (\(anns :: Annotations
anns, desc :: ClassExpression
desc) -> DataPropertyAxiom -> Axiom
DataPropertyAxiom (DataPropertyAxiom -> Axiom) -> DataPropertyAxiom -> Axiom
forall a b. (a -> b) -> a -> b
$ Annotations -> IRI -> ClassExpression -> DataPropertyAxiom
DataPropertyDomain Annotations
anns IRI
de ClassExpression
desc) [(Annotations, ClassExpression)]
ds
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
rangeC
    [(Annotations, DataRange)]
ds <- CharParser st (Annotations, DataRange)
-> CharParser st [(Annotations, DataRange)]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (CharParser st (Annotations, DataRange)
 -> CharParser st [(Annotations, DataRange)])
-> CharParser st (Annotations, DataRange)
-> CharParser st [(Annotations, DataRange)]
forall a b. (a -> b) -> a -> b
$ (PrefixMap
-> CharParser st DataRange
-> CharParser st (Annotations, DataRange)
forall st a.
PrefixMap -> CharParser st a -> CharParser st (Annotations, a)
optAnnos PrefixMap
pm) (PrefixMap -> CharParser st DataRange
forall st. PrefixMap -> CharParser st DataRange
dataRange PrefixMap
pm)
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ ((Annotations, DataRange) -> Axiom)
-> [(Annotations, DataRange)] -> [Axiom]
forall a b. (a -> b) -> [a] -> [b]
map (\(anns :: Annotations
anns, r :: DataRange
r) -> DataPropertyAxiom -> Axiom
DataPropertyAxiom (DataPropertyAxiom -> Axiom) -> DataPropertyAxiom -> Axiom
forall a b. (a -> b) -> a -> b
$ Annotations -> IRI -> DataRange -> DataPropertyAxiom
DataPropertyRange Annotations
anns IRI
de DataRange
r) [(Annotations, DataRange)]
ds
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
characteristicsC
    Annotations
as <- PrefixMap -> CharParser st Annotations
forall st. PrefixMap -> CharParser st Annotations
optionalAnnos PrefixMap
pm
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
functionalS
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return [DataPropertyAxiom -> Axiom
DataPropertyAxiom (DataPropertyAxiom -> Axiom) -> DataPropertyAxiom -> Axiom
forall a b. (a -> b) -> a -> b
$ Annotations -> IRI -> DataPropertyAxiom
FunctionalDataProperty Annotations
as IRI
de]
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
subPropertyOfC
    [(Annotations, IRI)]
ds <- PrefixMap -> CharParser st [(Annotations, IRI)]
forall st. PrefixMap -> CharParser st [(Annotations, IRI)]
dataPropExprAList PrefixMap
pm
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ ((Annotations, IRI) -> Axiom) -> [(Annotations, IRI)] -> [Axiom]
forall a b. (a -> b) -> [a] -> [b]
map (\(anns :: Annotations
anns, sup :: IRI
sup) -> DataPropertyAxiom -> Axiom
DataPropertyAxiom (DataPropertyAxiom -> Axiom) -> DataPropertyAxiom -> Axiom
forall a b. (a -> b) -> a -> b
$ Annotations -> IRI -> IRI -> DataPropertyAxiom
SubDataPropertyOf Annotations
anns IRI
de IRI
sup) [(Annotations, IRI)]
ds
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
equivalentToC
    [(Annotations, IRI)]
ds <- PrefixMap -> CharParser st [(Annotations, IRI)]
forall st. PrefixMap -> CharParser st [(Annotations, IRI)]
dataPropExprAList PrefixMap
pm
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ ((Annotations, IRI) -> Axiom) -> [(Annotations, IRI)] -> [Axiom]
forall a b. (a -> b) -> [a] -> [b]
map (\(anns :: Annotations
anns, d :: IRI
d) -> DataPropertyAxiom -> Axiom
DataPropertyAxiom (DataPropertyAxiom -> Axiom) -> DataPropertyAxiom -> Axiom
forall a b. (a -> b) -> a -> b
$ Annotations -> [IRI] -> DataPropertyAxiom
EquivalentDataProperties Annotations
anns [IRI
de, IRI
d]) [(Annotations, IRI)]
ds
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
disjointWithC
    [(Annotations, IRI)]
ds <- PrefixMap -> CharParser st [(Annotations, IRI)]
forall st. PrefixMap -> CharParser st [(Annotations, IRI)]
dataPropExprAList PrefixMap
pm
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ ((Annotations, IRI) -> Axiom) -> [(Annotations, IRI)] -> [Axiom]
forall a b. (a -> b) -> [a] -> [b]
map (\(anns :: Annotations
anns, d :: IRI
d) -> DataPropertyAxiom -> Axiom
DataPropertyAxiom (DataPropertyAxiom -> Axiom) -> DataPropertyAxiom -> Axiom
forall a b. (a -> b) -> a -> b
$ Annotations -> [IRI] -> DataPropertyAxiom
DisjointDataProperties Annotations
anns [IRI
de, IRI
d]) [(Annotations, IRI)]
ds
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> PrefixMap -> AnnotationSubject -> CharParser st [Axiom]
forall st. PrefixMap -> AnnotationSubject -> CharParser st [Axiom]
parseAnnotationAssertions PrefixMap
pm (IRI -> AnnotationSubject
AnnSubIri IRI
de)

dataPropertyFrame :: GA.PrefixMap -> CharParser st [Axiom]
dataPropertyFrame :: PrefixMap -> CharParser st [Axiom]
dataPropertyFrame pm :: PrefixMap
pm = do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
dataPropertyC
    Annotations
annos <- PrefixMap -> CharParser st Annotations
forall st. PrefixMap -> CharParser st Annotations
optionalAnnos PrefixMap
pm
    IRI
duri <- PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
expUriP PrefixMap
pm
    [[Axiom]]
sections <- CharParser st [Axiom] -> ParsecT [Char] st Identity [[Axiom]]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (CharParser st [Axiom] -> ParsecT [Char] st Identity [[Axiom]])
-> CharParser st [Axiom] -> ParsecT [Char] st Identity [[Axiom]]
forall a b. (a -> b) -> a -> b
$ PrefixMap -> IRI -> CharParser st [Axiom]
forall st. PrefixMap -> IRI -> CharParser st [Axiom]
dataFrameSection PrefixMap
pm IRI
duri 
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ Annotations -> Entity -> Axiom
Declaration Annotations
annos (EntityType -> IRI -> Entity
mkEntity EntityType
DataProperty IRI
duri) Axiom -> [Axiom] -> [Axiom]
forall a. a -> [a] -> [a]
: [[Axiom]] -> [Axiom]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[Axiom]]
sections

fact :: GA.PrefixMap -> Individual -> CharParser st Assertion
fact :: PrefixMap -> IRI -> CharParser st Assertion
fact pm :: PrefixMap
pm i :: IRI
i = do
    Annotations
anns <- PrefixMap -> CharParser st Annotations
forall st. PrefixMap -> CharParser st Annotations
optionalAnnos PrefixMap
pm
    Bool
negative <- Bool
-> ParsecT [Char] st Identity Bool
-> ParsecT [Char] st Identity Bool
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Bool
False (ParsecT [Char] st Identity Bool
 -> ParsecT [Char] st Identity Bool)
-> ParsecT [Char] st Identity Bool
-> ParsecT [Char] st Identity Bool
forall a b. (a -> b) -> a -> b
$ [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
notS CharParser st ()
-> ParsecT [Char] st Identity Bool
-> ParsecT [Char] st Identity Bool
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Bool -> ParsecT [Char] st Identity Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
True
    CharParser st Assertion -> CharParser st Assertion
forall tok st a. GenParser tok st a -> GenParser tok st a
try (do
        IRI
u <- PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
expUriP PrefixMap
pm
        Literal
c <- PrefixMap -> CharParser st Literal
forall st. PrefixMap -> CharParser st Literal
literal PrefixMap
pm
        let assertion :: Annotations -> IRI -> IRI -> Literal -> Assertion
assertion = if Bool
negative
            then Annotations -> IRI -> IRI -> Literal -> Assertion
NegativeDataPropertyAssertion
            else Annotations -> IRI -> IRI -> Literal -> Assertion
DataPropertyAssertion
        Assertion -> CharParser st Assertion
forall (m :: * -> *) a. Monad m => a -> m a
return (Assertion -> CharParser st Assertion)
-> Assertion -> CharParser st Assertion
forall a b. (a -> b) -> a -> b
$ Annotations -> IRI -> IRI -> Literal -> Assertion
assertion Annotations
anns IRI
u IRI
i Literal
c)
      CharParser st Assertion
-> CharParser st Assertion -> CharParser st Assertion
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
        ObjectPropertyExpression
o <- PrefixMap -> CharParser st ObjectPropertyExpression
forall st. PrefixMap -> CharParser st ObjectPropertyExpression
objectPropertyExpr PrefixMap
pm
        IRI
t <- PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
individual PrefixMap
pm
        let assertion :: Annotations -> ObjectPropertyExpression -> IRI -> IRI -> Assertion
assertion = if Bool
negative
            then Annotations -> ObjectPropertyExpression -> IRI -> IRI -> Assertion
NegativeObjectPropertyAssertion
            else Annotations -> ObjectPropertyExpression -> IRI -> IRI -> Assertion
ObjectPropertyAssertion
        Assertion -> CharParser st Assertion
forall (m :: * -> *) a. Monad m => a -> m a
return (Assertion -> CharParser st Assertion)
-> Assertion -> CharParser st Assertion
forall a b. (a -> b) -> a -> b
$ Annotations -> ObjectPropertyExpression -> IRI -> IRI -> Assertion
assertion Annotations
anns ObjectPropertyExpression
o IRI
i IRI
t

iFrameSection :: GA.PrefixMap -> Individual -> CharParser st [Axiom]
iFrameSection :: PrefixMap -> IRI -> CharParser st [Axiom]
iFrameSection pm :: PrefixMap
pm i :: IRI
i = do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
typesC
    [(Annotations, ClassExpression)]
ds <- PrefixMap -> CharParser st [(Annotations, ClassExpression)]
forall st.
PrefixMap -> CharParser st [(Annotations, ClassExpression)]
descriptionAnnotatedList PrefixMap
pm
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ ((Annotations, ClassExpression) -> Axiom)
-> [(Annotations, ClassExpression)] -> [Axiom]
forall a b. (a -> b) -> [a] -> [b]
map (\(ans :: Annotations
ans, d :: ClassExpression
d) -> Assertion -> Axiom
Assertion (Assertion -> Axiom) -> Assertion -> Axiom
forall a b. (a -> b) -> a -> b
$ Annotations -> ClassExpression -> IRI -> Assertion
ClassAssertion Annotations
ans ClassExpression
d IRI
i) [(Annotations, ClassExpression)]
ds
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
sameAsC
    [(Annotations, IRI)]
is <- CharParser st (Annotations, IRI)
-> CharParser st [(Annotations, IRI)]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (CharParser st (Annotations, IRI)
 -> CharParser st [(Annotations, IRI)])
-> CharParser st (Annotations, IRI)
-> CharParser st [(Annotations, IRI)]
forall a b. (a -> b) -> a -> b
$ (PrefixMap -> CharParser st IRI -> CharParser st (Annotations, IRI)
forall st a.
PrefixMap -> CharParser st a -> CharParser st (Annotations, a)
optAnnos PrefixMap
pm) (CharParser st IRI -> CharParser st (Annotations, IRI))
-> CharParser st IRI -> CharParser st (Annotations, IRI)
forall a b. (a -> b) -> a -> b
$ PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
individual PrefixMap
pm
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ ((Annotations, IRI) -> Axiom) -> [(Annotations, IRI)] -> [Axiom]
forall a b. (a -> b) -> [a] -> [b]
map (\(ans :: Annotations
ans, d :: IRI
d) -> Assertion -> Axiom
Assertion (Assertion -> Axiom) -> Assertion -> Axiom
forall a b. (a -> b) -> a -> b
$ Annotations -> [IRI] -> Assertion
SameIndividual Annotations
ans [IRI
d, IRI
i]) [(Annotations, IRI)]
is
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
differentFromC
    [(Annotations, IRI)]
is <- CharParser st (Annotations, IRI)
-> CharParser st [(Annotations, IRI)]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (CharParser st (Annotations, IRI)
 -> CharParser st [(Annotations, IRI)])
-> CharParser st (Annotations, IRI)
-> CharParser st [(Annotations, IRI)]
forall a b. (a -> b) -> a -> b
$ (PrefixMap -> CharParser st IRI -> CharParser st (Annotations, IRI)
forall st a.
PrefixMap -> CharParser st a -> CharParser st (Annotations, a)
optAnnos PrefixMap
pm) (CharParser st IRI -> CharParser st (Annotations, IRI))
-> CharParser st IRI -> CharParser st (Annotations, IRI)
forall a b. (a -> b) -> a -> b
$ PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
individual PrefixMap
pm
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ ((Annotations, IRI) -> Axiom) -> [(Annotations, IRI)] -> [Axiom]
forall a b. (a -> b) -> [a] -> [b]
map (\(ans :: Annotations
ans, d :: IRI
d) -> Assertion -> Axiom
Assertion (Assertion -> Axiom) -> Assertion -> Axiom
forall a b. (a -> b) -> a -> b
$ Annotations -> [IRI] -> Assertion
DifferentIndividuals Annotations
ans [IRI
d, IRI
i]) [(Annotations, IRI)]
is
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
factsC
    [Assertion]
facts <- CharParser st Assertion -> CharParser st [Assertion]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (CharParser st Assertion -> CharParser st [Assertion])
-> CharParser st Assertion -> CharParser st [Assertion]
forall a b. (a -> b) -> a -> b
$ PrefixMap -> IRI -> CharParser st Assertion
forall st. PrefixMap -> IRI -> CharParser st Assertion
fact PrefixMap
pm IRI
i
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ Assertion -> Axiom
Assertion (Assertion -> Axiom) -> [Assertion] -> [Axiom]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Assertion]
facts
  CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> PrefixMap -> AnnotationSubject -> CharParser st [Axiom]
forall st. PrefixMap -> AnnotationSubject -> CharParser st [Axiom]
parseAnnotationAssertions PrefixMap
pm (IRI -> AnnotationSubject
AnnSubAnInd IRI
i)

individualFrame ::GA.PrefixMap -> CharParser st [Axiom]
individualFrame :: PrefixMap -> CharParser st [Axiom]
individualFrame pm :: PrefixMap
pm = do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
individualC
    Annotations
annos <- PrefixMap -> CharParser st Annotations
forall st. PrefixMap -> CharParser st Annotations
optionalAnnos PrefixMap
pm
    IRI
iuri <- PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
individual PrefixMap
pm
    [[Axiom]]
axs <- CharParser st [Axiom] -> ParsecT [Char] st Identity [[Axiom]]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (CharParser st [Axiom] -> ParsecT [Char] st Identity [[Axiom]])
-> CharParser st [Axiom] -> ParsecT [Char] st Identity [[Axiom]]
forall a b. (a -> b) -> a -> b
$ PrefixMap -> IRI -> CharParser st [Axiom]
forall st. PrefixMap -> IRI -> CharParser st [Axiom]
iFrameSection PrefixMap
pm IRI
iuri
    [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ Annotations -> Entity -> Axiom
Declaration Annotations
annos (EntityType -> IRI -> Entity
mkEntity EntityType
NamedIndividual IRI
iuri) Axiom -> [Axiom] -> [Axiom]
forall a. a -> [a] -> [a]
:[[Axiom]] -> [Axiom]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[Axiom]]
axs

parseEquivalentClasses :: GA.PrefixMap -> CharParser st ClassAxiom
parseEquivalentClasses :: PrefixMap -> CharParser st ClassAxiom
parseEquivalentClasses pm :: PrefixMap
pm = do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
equivalentClassesC
    Annotations
anns <- PrefixMap -> CharParser st Annotations
forall st. PrefixMap -> CharParser st Annotations
optionalAnnos PrefixMap
pm
    [ClassExpression]
classExprs <- CharParser st ClassExpression -> CharParser st [ClassExpression]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (CharParser st ClassExpression -> CharParser st [ClassExpression])
-> CharParser st ClassExpression -> CharParser st [ClassExpression]
forall a b. (a -> b) -> a -> b
$ PrefixMap -> CharParser st ClassExpression
forall st. PrefixMap -> CharParser st ClassExpression
description PrefixMap
pm
    ClassAxiom -> CharParser st ClassAxiom
forall (m :: * -> *) a. Monad m => a -> m a
return (ClassAxiom -> CharParser st ClassAxiom)
-> ClassAxiom -> CharParser st ClassAxiom
forall a b. (a -> b) -> a -> b
$ Annotations -> [ClassExpression] -> ClassAxiom
EquivalentClasses Annotations
anns [ClassExpression]
classExprs

parseDisjointClasses :: GA.PrefixMap -> CharParser st ClassAxiom
parseDisjointClasses :: PrefixMap -> CharParser st ClassAxiom
parseDisjointClasses pm :: PrefixMap
pm = do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
disjointClassesC
    Annotations
anns <- PrefixMap -> CharParser st Annotations
forall st. PrefixMap -> CharParser st Annotations
optionalAnnos PrefixMap
pm
    [ClassExpression]
classExprs <- CharParser st ClassExpression -> CharParser st [ClassExpression]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (CharParser st ClassExpression -> CharParser st [ClassExpression])
-> CharParser st ClassExpression -> CharParser st [ClassExpression]
forall a b. (a -> b) -> a -> b
$ PrefixMap -> CharParser st ClassExpression
forall st. PrefixMap -> CharParser st ClassExpression
description PrefixMap
pm
    ClassAxiom -> CharParser st ClassAxiom
forall (m :: * -> *) a. Monad m => a -> m a
return (ClassAxiom -> CharParser st ClassAxiom)
-> ClassAxiom -> CharParser st ClassAxiom
forall a b. (a -> b) -> a -> b
$ Annotations -> [ClassExpression] -> ClassAxiom
DisjointClasses Annotations
anns [ClassExpression]
classExprs

parseEquivalentObjectProperties :: GA.PrefixMap -> CharParser st ObjectPropertyAxiom
parseEquivalentObjectProperties :: PrefixMap -> CharParser st ObjectPropertyAxiom
parseEquivalentObjectProperties pm :: PrefixMap
pm = do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
equivalentPropertiesC
    Annotations
anns <- PrefixMap -> CharParser st Annotations
forall st. PrefixMap -> CharParser st Annotations
optionalAnnos PrefixMap
pm
    [ObjectPropertyExpression]
objectExprs <- CharParser st ObjectPropertyExpression
-> CharParser st [ObjectPropertyExpression]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (CharParser st ObjectPropertyExpression
 -> CharParser st [ObjectPropertyExpression])
-> CharParser st ObjectPropertyExpression
-> CharParser st [ObjectPropertyExpression]
forall a b. (a -> b) -> a -> b
$ PrefixMap -> CharParser st ObjectPropertyExpression
forall st. PrefixMap -> CharParser st ObjectPropertyExpression
objectPropertyExpr PrefixMap
pm
    ObjectPropertyAxiom -> CharParser st ObjectPropertyAxiom
forall (m :: * -> *) a. Monad m => a -> m a
return (ObjectPropertyAxiom -> CharParser st ObjectPropertyAxiom)
-> ObjectPropertyAxiom -> CharParser st ObjectPropertyAxiom
forall a b. (a -> b) -> a -> b
$ Annotations -> [ObjectPropertyExpression] -> ObjectPropertyAxiom
EquivalentObjectProperties Annotations
anns [ObjectPropertyExpression]
objectExprs

parseDisjointObjectProperties :: GA.PrefixMap -> CharParser st ObjectPropertyAxiom
parseDisjointObjectProperties :: PrefixMap -> CharParser st ObjectPropertyAxiom
parseDisjointObjectProperties pm :: PrefixMap
pm = do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
disjointPropertiesC
    Annotations
anns <- PrefixMap -> CharParser st Annotations
forall st. PrefixMap -> CharParser st Annotations
optionalAnnos PrefixMap
pm
    [ObjectPropertyExpression]
objectExprs <- CharParser st ObjectPropertyExpression
-> CharParser st [ObjectPropertyExpression]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (CharParser st ObjectPropertyExpression
 -> CharParser st [ObjectPropertyExpression])
-> CharParser st ObjectPropertyExpression
-> CharParser st [ObjectPropertyExpression]
forall a b. (a -> b) -> a -> b
$ PrefixMap -> CharParser st ObjectPropertyExpression
forall st. PrefixMap -> CharParser st ObjectPropertyExpression
objectPropertyExpr PrefixMap
pm
    ObjectPropertyAxiom -> CharParser st ObjectPropertyAxiom
forall (m :: * -> *) a. Monad m => a -> m a
return (ObjectPropertyAxiom -> CharParser st ObjectPropertyAxiom)
-> ObjectPropertyAxiom -> CharParser st ObjectPropertyAxiom
forall a b. (a -> b) -> a -> b
$ Annotations -> [ObjectPropertyExpression] -> ObjectPropertyAxiom
DisjointObjectProperties Annotations
anns [ObjectPropertyExpression]
objectExprs

parseSameIndividuals :: GA.PrefixMap -> CharParser st Assertion
parseSameIndividuals :: PrefixMap -> CharParser st Assertion
parseSameIndividuals pm :: PrefixMap
pm = do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
sameIndividualC
    Annotations
anns <- PrefixMap -> CharParser st Annotations
forall st. PrefixMap -> CharParser st Annotations
optionalAnnos PrefixMap
pm
    [IRI]
indivs <- CharParser st IRI -> CharParser st [IRI]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (CharParser st IRI -> CharParser st [IRI])
-> CharParser st IRI -> CharParser st [IRI]
forall a b. (a -> b) -> a -> b
$ PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
individualUri PrefixMap
pm
    Assertion -> CharParser st Assertion
forall (m :: * -> *) a. Monad m => a -> m a
return (Assertion -> CharParser st Assertion)
-> Assertion -> CharParser st Assertion
forall a b. (a -> b) -> a -> b
$ Annotations -> [IRI] -> Assertion
SameIndividual Annotations
anns [IRI]
indivs


parseDifferentIndividuals :: GA.PrefixMap -> CharParser st Assertion
parseDifferentIndividuals :: PrefixMap -> CharParser st Assertion
parseDifferentIndividuals pm :: PrefixMap
pm = do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
differentIndividualsC
    Annotations
anns <- PrefixMap -> CharParser st Annotations
forall st. PrefixMap -> CharParser st Annotations
optionalAnnos PrefixMap
pm
    [IRI]
indivs <- CharParser st IRI -> CharParser st [IRI]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (CharParser st IRI -> CharParser st [IRI])
-> CharParser st IRI -> CharParser st [IRI]
forall a b. (a -> b) -> a -> b
$ PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
individualUri PrefixMap
pm
    Assertion -> CharParser st Assertion
forall (m :: * -> *) a. Monad m => a -> m a
return (Assertion -> CharParser st Assertion)
-> Assertion -> CharParser st Assertion
forall a b. (a -> b) -> a -> b
$ Annotations -> [IRI] -> Assertion
SameIndividual Annotations
anns [IRI]
indivs


misc :: GA.PrefixMap -> CharParser st Axiom
misc :: PrefixMap -> CharParser st Axiom
misc pm :: PrefixMap
pm =
    ClassAxiom -> Axiom
ClassAxiom (ClassAxiom -> Axiom)
-> ParsecT [Char] st Identity ClassAxiom -> CharParser st Axiom
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrefixMap -> ParsecT [Char] st Identity ClassAxiom
forall st. PrefixMap -> CharParser st ClassAxiom
parseEquivalentClasses PrefixMap
pm CharParser st Axiom -> CharParser st Axiom -> CharParser st Axiom
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
    ClassAxiom -> Axiom
ClassAxiom (ClassAxiom -> Axiom)
-> ParsecT [Char] st Identity ClassAxiom -> CharParser st Axiom
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrefixMap -> ParsecT [Char] st Identity ClassAxiom
forall st. PrefixMap -> CharParser st ClassAxiom
parseDisjointClasses PrefixMap
pm CharParser st Axiom -> CharParser st Axiom -> CharParser st Axiom
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
    ObjectPropertyAxiom -> Axiom
ObjectPropertyAxiom (ObjectPropertyAxiom -> Axiom)
-> ParsecT [Char] st Identity ObjectPropertyAxiom
-> CharParser st Axiom
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrefixMap -> ParsecT [Char] st Identity ObjectPropertyAxiom
forall st. PrefixMap -> CharParser st ObjectPropertyAxiom
parseEquivalentObjectProperties PrefixMap
pm CharParser st Axiom -> CharParser st Axiom -> CharParser st Axiom
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
    ObjectPropertyAxiom -> Axiom
ObjectPropertyAxiom (ObjectPropertyAxiom -> Axiom)
-> ParsecT [Char] st Identity ObjectPropertyAxiom
-> CharParser st Axiom
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrefixMap -> ParsecT [Char] st Identity ObjectPropertyAxiom
forall st. PrefixMap -> CharParser st ObjectPropertyAxiom
parseDisjointObjectProperties PrefixMap
pm CharParser st Axiom -> CharParser st Axiom -> CharParser st Axiom
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
    Assertion -> Axiom
Assertion (Assertion -> Axiom)
-> ParsecT [Char] st Identity Assertion -> CharParser st Axiom
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrefixMap -> ParsecT [Char] st Identity Assertion
forall st. PrefixMap -> CharParser st Assertion
parseSameIndividuals PrefixMap
pm CharParser st Axiom -> CharParser st Axiom -> CharParser st Axiom
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
    Assertion -> Axiom
Assertion (Assertion -> Axiom)
-> ParsecT [Char] st Identity Assertion -> CharParser st Axiom
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrefixMap -> ParsecT [Char] st Identity Assertion
forall st. PrefixMap -> CharParser st Assertion
parseDifferentIndividuals PrefixMap
pm

-- # Rules
-- There are ambiguities listed in the following table
{-

<predicate>(<iri>)                 | ClassAtom
<predicate>(<literal>)             | DataRangeAtom, BuiltInAtom
<predicate>(?<var>)                | ClassAtom, DataRangeAtom, BuiltInAtom

<predicate>(<iri>, <iri>)          | ObjectPropertyAtom
<predicate>(<literal>, <iri>)      | -invalid-
<predicate>(?<var>, <iri>)         | ObjectPropertyAtom
<predicate>(<iri>, <literal>)      | DataPropertyAtom
<predicate>(<literal>, <literal>)  | BuiltInAtom
<predicate>(?<var>, <literal>)     | ObjectPropertyAtom, DataPropertyAtom
<predicate>(<iri>, ?<var>)         | ObjectPropertyAtom, DataPropertyAtom
<predicate>(<literal>, ?<var>)     | BuiltInAtom
<predicate>(?<var>, ?<var>)        | ObjectPropertyAtom, DataPropertyAtom, BuiltInAtom

<predicate>(<any>, <any>, <any>, ...) | BuiltInAtom

-}

parseVariable :: GA.PrefixMap -> CharParser st Variable
parseVariable :: PrefixMap -> CharParser st IRI
parseVariable pm :: PrefixMap
pm = CharParser st IRI -> CharParser st IRI
forall st a. CharParser st a -> CharParser st a
optParensP (CharParser st IRI -> CharParser st IRI)
-> CharParser st IRI -> CharParser st IRI
forall a b. (a -> b) -> a -> b
$ do 
  Char -> ParsecT [Char] st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char '?'
  PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
expUriP PrefixMap
pm

parseNoVariable :: CharParser st a -> CharParser st a
parseNoVariable :: CharParser st a -> CharParser st a
parseNoVariable p :: CharParser st a
p = do
  Char
nextChar <- ParsecT [Char] st Identity Char -> ParsecT [Char] st Identity Char
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead ParsecT [Char] st Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
anyChar
  if Char
nextChar Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== '?' then [Char] -> CharParser st a
forall (m :: * -> *) a. MonadFail m => [Char] -> m a
Fail.fail "Variable" else CharParser st a
p

parseClassExprAtom :: GA.PrefixMap -> CharParser st Atom
parseClassExprAtom :: PrefixMap -> CharParser st Atom
parseClassExprAtom pm :: PrefixMap
pm = do
  ClassExpression
classExpr <- CharParser st ClassExpression -> CharParser st ClassExpression
forall st a. CharParser st a -> CharParser st a
parensP (CharParser st ClassExpression -> CharParser st ClassExpression)
-> CharParser st ClassExpression -> CharParser st ClassExpression
forall a b. (a -> b) -> a -> b
$ PrefixMap -> CharParser st ClassExpression
forall st. PrefixMap -> CharParser st ClassExpression
description PrefixMap
pm
  IndividualArg
arg <- (IRI -> IndividualArg
IVar (IRI -> IndividualArg)
-> ParsecT [Char] st Identity IRI
-> ParsecT [Char] st Identity IndividualArg
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrefixMap -> ParsecT [Char] st Identity IRI
forall st. PrefixMap -> CharParser st IRI
parseVariable PrefixMap
pm) ParsecT [Char] st Identity IndividualArg
-> ParsecT [Char] st Identity IndividualArg
-> ParsecT [Char] st Identity IndividualArg
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (IRI -> IndividualArg
IArg (IRI -> IndividualArg)
-> ParsecT [Char] st Identity IRI
-> ParsecT [Char] st Identity IndividualArg
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrefixMap -> ParsecT [Char] st Identity IRI
forall st. PrefixMap -> CharParser st IRI
expUriP PrefixMap
pm)
  Atom -> CharParser st Atom
forall (m :: * -> *) a. Monad m => a -> m a
return (Atom -> CharParser st Atom) -> Atom -> CharParser st Atom
forall a b. (a -> b) -> a -> b
$ ClassExpression -> IndividualArg -> Atom
ClassAtom ClassExpression
classExpr IndividualArg
arg

-- parses uniquely identified class atoms. The only way a class atom can be
-- identified as such during parsing is if iArg is an individual. If it is a Variable
-- it could also be a DataRangeAtom.
parseClassAtom :: GA.PrefixMap -> IRI -> CharParser st Atom
parseClassAtom :: PrefixMap -> IRI -> CharParser st Atom
parseClassAtom pm :: PrefixMap
pm pre :: IRI
pre = ClassExpression -> IndividualArg -> Atom
ClassAtom (IRI -> ClassExpression
Expression IRI
pre) (IndividualArg -> Atom)
-> ParsecT [Char] st Identity IndividualArg -> CharParser st Atom
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
  (IRI -> IndividualArg
IArg (IRI -> IndividualArg)
-> ParsecT [Char] st Identity IRI
-> ParsecT [Char] st Identity IndividualArg
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT [Char] st Identity IRI -> ParsecT [Char] st Identity IRI
forall st a. CharParser st a -> CharParser st a
parseNoVariable (PrefixMap -> ParsecT [Char] st Identity IRI
forall st. PrefixMap -> CharParser st IRI
expUriP PrefixMap
pm))

parseIArg :: GA.PrefixMap -> CharParser st IndividualArg
parseIArg :: PrefixMap -> CharParser st IndividualArg
parseIArg pm :: PrefixMap
pm = (IRI -> IndividualArg
IVar (IRI -> IndividualArg)
-> ParsecT [Char] st Identity IRI -> CharParser st IndividualArg
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrefixMap -> ParsecT [Char] st Identity IRI
forall st. PrefixMap -> CharParser st IRI
parseVariable PrefixMap
pm) CharParser st IndividualArg
-> CharParser st IndividualArg -> CharParser st IndividualArg
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (IRI -> IndividualArg
IArg (IRI -> IndividualArg)
-> ParsecT [Char] st Identity IRI -> CharParser st IndividualArg
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrefixMap -> ParsecT [Char] st Identity IRI
forall st. PrefixMap -> CharParser st IRI
individual PrefixMap
pm)

parseObjectPropertyAtom :: GA.PrefixMap -> IRI -> CharParser st Atom
parseObjectPropertyAtom :: PrefixMap -> IRI -> CharParser st Atom
parseObjectPropertyAtom pm :: PrefixMap
pm pre :: IRI
pre = do
  IndividualArg
iarg <- PrefixMap -> CharParser st IndividualArg
forall st. PrefixMap -> CharParser st IndividualArg
parseIArg PrefixMap
pm
  CharParser st ()
forall st. GenParser Char st ()
commaP
  IndividualArg
i <- IRI -> IndividualArg
IArg (IRI -> IndividualArg)
-> ParsecT [Char] st Identity IRI -> CharParser st IndividualArg
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT [Char] st Identity IRI -> ParsecT [Char] st Identity IRI
forall st a. CharParser st a -> CharParser st a
parseNoVariable (PrefixMap -> ParsecT [Char] st Identity IRI
forall st. PrefixMap -> CharParser st IRI
individual PrefixMap
pm)
  Atom -> CharParser st Atom
forall (m :: * -> *) a. Monad m => a -> m a
return (Atom -> CharParser st Atom) -> Atom -> CharParser st Atom
forall a b. (a -> b) -> a -> b
$ ObjectPropertyExpression -> IndividualArg -> IndividualArg -> Atom
ObjectPropertyAtom (IRI -> ObjectPropertyExpression
ObjectProp IRI
pre) IndividualArg
iarg IndividualArg
i

parseDataPropertyAtom :: GA.PrefixMap -> IRI -> CharParser st Atom
parseDataPropertyAtom :: PrefixMap -> IRI -> CharParser st Atom
parseDataPropertyAtom pm :: PrefixMap
pm pre :: IRI
pre = do
  IndividualArg
iarg <- IRI -> IndividualArg
IArg (IRI -> IndividualArg)
-> ParsecT [Char] st Identity IRI
-> ParsecT [Char] st Identity IndividualArg
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT [Char] st Identity IRI -> ParsecT [Char] st Identity IRI
forall st a. CharParser st a -> CharParser st a
parseNoVariable (PrefixMap -> ParsecT [Char] st Identity IRI
forall st. PrefixMap -> CharParser st IRI
individual PrefixMap
pm)
  CharParser st ()
forall st. GenParser Char st ()
commaP
  DataArg
dataProp <- Literal -> DataArg
DArg (Literal -> DataArg)
-> ParsecT [Char] st Identity Literal
-> ParsecT [Char] st Identity DataArg
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrefixMap -> ParsecT [Char] st Identity Literal
forall st. PrefixMap -> CharParser st Literal
literal PrefixMap
pm
  Atom -> CharParser st Atom
forall (m :: * -> *) a. Monad m => a -> m a
return (Atom -> CharParser st Atom) -> Atom -> CharParser st Atom
forall a b. (a -> b) -> a -> b
$ IRI -> IndividualArg -> DataArg -> Atom
DataPropertyAtom IRI
pre IndividualArg
iarg DataArg
dataProp

parseSameIndividualsAtom :: GA.PrefixMap -> CharParser st Atom
parseSameIndividualsAtom :: PrefixMap -> CharParser st Atom
parseSameIndividualsAtom pm :: PrefixMap
pm = do
  [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
sameAsS
  CharParser st Atom -> CharParser st Atom
forall st a. CharParser st a -> CharParser st a
parensP (CharParser st Atom -> CharParser st Atom)
-> CharParser st Atom -> CharParser st Atom
forall a b. (a -> b) -> a -> b
$ do 
    IndividualArg
iarg1 <- PrefixMap -> CharParser st IndividualArg
forall st. PrefixMap -> CharParser st IndividualArg
parseIArg PrefixMap
pm
    CharParser st ()
forall st. GenParser Char st ()
commaP
    IndividualArg
iarg2 <- PrefixMap -> CharParser st IndividualArg
forall st. PrefixMap -> CharParser st IndividualArg
parseIArg PrefixMap
pm
    Atom -> CharParser st Atom
forall (m :: * -> *) a. Monad m => a -> m a
return (Atom -> CharParser st Atom) -> Atom -> CharParser st Atom
forall a b. (a -> b) -> a -> b
$ IndividualArg -> IndividualArg -> Atom
SameIndividualAtom IndividualArg
iarg1 IndividualArg
iarg2
  
parseDifferentIndividualsAtom :: GA.PrefixMap -> CharParser st Atom
parseDifferentIndividualsAtom :: PrefixMap -> CharParser st Atom
parseDifferentIndividualsAtom pm :: PrefixMap
pm = do
  [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
differentFromS
  CharParser st Atom -> CharParser st Atom
forall st a. CharParser st a -> CharParser st a
parensP (CharParser st Atom -> CharParser st Atom)
-> CharParser st Atom -> CharParser st Atom
forall a b. (a -> b) -> a -> b
$ do
    IndividualArg
iarg1 <- PrefixMap -> CharParser st IndividualArg
forall st. PrefixMap -> CharParser st IndividualArg
parseIArg PrefixMap
pm
    CharParser st ()
forall st. GenParser Char st ()
commaP
    IndividualArg
iarg2 <- PrefixMap -> CharParser st IndividualArg
forall st. PrefixMap -> CharParser st IndividualArg
parseIArg PrefixMap
pm
    Atom -> CharParser st Atom
forall (m :: * -> *) a. Monad m => a -> m a
return (Atom -> CharParser st Atom) -> Atom -> CharParser st Atom
forall a b. (a -> b) -> a -> b
$ IndividualArg -> IndividualArg -> Atom
DifferentIndividualsAtom IndividualArg
iarg1 IndividualArg
iarg2

parseDArg :: GA.PrefixMap -> CharParser st DataArg
parseDArg :: PrefixMap -> CharParser st DataArg
parseDArg pm :: PrefixMap
pm = (Literal -> DataArg
DArg (Literal -> DataArg)
-> ParsecT [Char] st Identity Literal -> CharParser st DataArg
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrefixMap -> ParsecT [Char] st Identity Literal
forall st. PrefixMap -> CharParser st Literal
literal PrefixMap
pm) CharParser st DataArg
-> CharParser st DataArg -> CharParser st DataArg
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (IRI -> DataArg
DVar (IRI -> DataArg)
-> ParsecT [Char] st Identity IRI -> CharParser st DataArg
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrefixMap -> ParsecT [Char] st Identity IRI
forall st. PrefixMap -> CharParser st IRI
parseVariable PrefixMap
pm)



parseBuiltInAtom :: GA.PrefixMap -> IRI -> CharParser st Atom
parseBuiltInAtom :: PrefixMap -> IRI -> CharParser st Atom
parseBuiltInAtom pm :: PrefixMap
pm pre :: IRI
pre = do
  Bool
-> ParsecT [Char] st Identity () -> ParsecT [Char] st Identity ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (IRI -> Bool
isSWRLBuiltIn IRI
pre) (ParsecT [Char] st Identity () -> ParsecT [Char] st Identity ())
-> ParsecT [Char] st Identity () -> ParsecT [Char] st Identity ()
forall a b. (a -> b) -> a -> b
$ [Char] -> ParsecT [Char] st Identity ()
forall (m :: * -> *) a. MonadFail m => [Char] -> m a
Fail.fail ("\"" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ IRI -> [Char]
forall a. Show a => a -> [Char]
show IRI
pre [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ "\" is not a built in predicate.")
  IRI -> [DataArg] -> Atom
BuiltInAtom IRI
pre ([DataArg] -> Atom)
-> ParsecT [Char] st Identity [DataArg] -> CharParser st Atom
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CharParser st DataArg -> ParsecT [Char] st Identity [DataArg]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (PrefixMap -> CharParser st DataArg
forall st. PrefixMap -> CharParser st DataArg
parseDArg PrefixMap
pm)


parseUnknownArg :: GA.PrefixMap -> CharParser st UnknownArg
parseUnknownArg :: PrefixMap -> CharParser st UnknownArg
parseUnknownArg pm :: PrefixMap
pm = (IRI -> UnknownArg
Variable (IRI -> UnknownArg)
-> ParsecT [Char] st Identity IRI -> CharParser st UnknownArg
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrefixMap -> ParsecT [Char] st Identity IRI
forall st. PrefixMap -> CharParser st IRI
parseVariable PrefixMap
pm) CharParser st UnknownArg
-> CharParser st UnknownArg -> CharParser st UnknownArg
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
  CharParser st UnknownArg -> CharParser st UnknownArg
forall tok st a. GenParser tok st a -> GenParser tok st a
try (IndividualArg -> UnknownArg
IndividualArg (IndividualArg -> UnknownArg)
-> ParsecT [Char] st Identity IndividualArg
-> CharParser st UnknownArg
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrefixMap -> ParsecT [Char] st Identity IndividualArg
forall st. PrefixMap -> CharParser st IndividualArg
parseIArg PrefixMap
pm) CharParser st UnknownArg
-> CharParser st UnknownArg -> CharParser st UnknownArg
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
  (DataArg -> UnknownArg
DataArg (DataArg -> UnknownArg)
-> ParsecT [Char] st Identity DataArg -> CharParser st UnknownArg
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrefixMap -> ParsecT [Char] st Identity DataArg
forall st. PrefixMap -> CharParser st DataArg
parseDArg PrefixMap
pm)

parseUnknownAtom :: GA.PrefixMap -> IRI -> CharParser st Atom
parseUnknownAtom :: PrefixMap -> IRI -> CharParser st Atom
parseUnknownAtom pm :: PrefixMap
pm pre :: IRI
pre =
  CharParser st Atom -> CharParser st Atom
forall tok st a. GenParser tok st a -> GenParser tok st a
try (IRI -> UnknownArg -> UnknownArg -> Atom
UnknownBinaryAtom IRI
pre (UnknownArg -> UnknownArg -> Atom)
-> ParsecT [Char] st Identity UnknownArg
-> ParsecT [Char] st Identity (UnknownArg -> Atom)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrefixMap -> ParsecT [Char] st Identity UnknownArg
forall st. PrefixMap -> CharParser st UnknownArg
parseUnknownArg PrefixMap
pm ParsecT [Char] st Identity (UnknownArg -> Atom)
-> ParsecT [Char] st Identity UnknownArg -> CharParser st Atom
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (CharParser st ()
forall st. GenParser Char st ()
commaP CharParser st ()
-> ParsecT [Char] st Identity UnknownArg
-> ParsecT [Char] st Identity UnknownArg
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> PrefixMap -> ParsecT [Char] st Identity UnknownArg
forall st. PrefixMap -> CharParser st UnknownArg
parseUnknownArg PrefixMap
pm)) CharParser st Atom -> CharParser st Atom -> CharParser st Atom
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
  (IRI -> UnknownArg -> Atom
UnknownUnaryAtom IRI
pre (UnknownArg -> Atom)
-> ParsecT [Char] st Identity UnknownArg -> CharParser st Atom
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrefixMap -> ParsecT [Char] st Identity UnknownArg
forall st. PrefixMap -> CharParser st UnknownArg
parseUnknownArg PrefixMap
pm)

parseDataRangeAtom :: GA.PrefixMap -> IRI -> CharParser st Atom
parseDataRangeAtom :: PrefixMap -> IRI -> CharParser st Atom
parseDataRangeAtom pm :: PrefixMap
pm pre :: IRI
pre = do
  [(IRI, Literal)]
facets <- PrefixMap -> CharParser st [(IRI, Literal)]
forall st. PrefixMap -> CharParser st [(IRI, Literal)]
parseFacetValuePairs PrefixMap
pm
  DataArg
darg <- PrefixMap -> CharParser st DataArg
forall st. PrefixMap -> CharParser st DataArg
parseDArg PrefixMap
pm
  Atom -> CharParser st Atom
forall (m :: * -> *) a. Monad m => a -> m a
return (Atom -> CharParser st Atom) -> Atom -> CharParser st Atom
forall a b. (a -> b) -> a -> b
$ DataRange -> DataArg -> Atom
DataRangeAtom (IRI -> [(IRI, Literal)] -> DataRange
DataType IRI
pre [(IRI, Literal)]
facets) DataArg
darg


parseAtom :: GA.PrefixMap -> CharParser st Atom
parseAtom :: PrefixMap -> CharParser st Atom
parseAtom pm :: PrefixMap
pm =  PrefixMap -> CharParser st Atom
forall st. PrefixMap -> CharParser st Atom
parseClassExprAtom PrefixMap
pm CharParser st Atom -> CharParser st Atom -> CharParser st Atom
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> 
  PrefixMap -> CharParser st Atom
forall st. PrefixMap -> CharParser st Atom
parseSameIndividualsAtom PrefixMap
pm CharParser st Atom -> CharParser st Atom -> CharParser st Atom
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
  PrefixMap -> CharParser st Atom
forall st. PrefixMap -> CharParser st Atom
parseDifferentIndividualsAtom PrefixMap
pm CharParser st Atom -> CharParser st Atom -> CharParser st Atom
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    IRI
pre <- PrefixMap -> CharParser st IRI
forall st. PrefixMap -> CharParser st IRI
expUriP PrefixMap
pm
    [CharParser st Atom] -> CharParser st Atom
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice ([CharParser st Atom] -> CharParser st Atom)
-> [CharParser st Atom] -> CharParser st Atom
forall a b. (a -> b) -> a -> b
$ (CharParser st Atom -> CharParser st Atom)
-> [CharParser st Atom] -> [CharParser st Atom]
forall a b. (a -> b) -> [a] -> [b]
map CharParser st Atom -> CharParser st Atom
forall tok st a. GenParser tok st a -> GenParser tok st a
try [
      CharParser st Atom -> CharParser st Atom
forall st a. CharParser st a -> CharParser st a
parensP (CharParser st Atom -> CharParser st Atom)
-> CharParser st Atom -> CharParser st Atom
forall a b. (a -> b) -> a -> b
$ PrefixMap -> IRI -> CharParser st Atom
forall st. PrefixMap -> IRI -> CharParser st Atom
parseBuiltInAtom PrefixMap
pm IRI
pre,
      CharParser st Atom -> CharParser st Atom
forall st a. CharParser st a -> CharParser st a
parensP (CharParser st Atom -> CharParser st Atom)
-> CharParser st Atom -> CharParser st Atom
forall a b. (a -> b) -> a -> b
$ PrefixMap -> IRI -> CharParser st Atom
forall st. PrefixMap -> IRI -> CharParser st Atom
parseClassAtom PrefixMap
pm IRI
pre,
      CharParser st Atom -> CharParser st Atom
forall st a. CharParser st a -> CharParser st a
parensP (CharParser st Atom -> CharParser st Atom)
-> CharParser st Atom -> CharParser st Atom
forall a b. (a -> b) -> a -> b
$ PrefixMap -> IRI -> CharParser st Atom
forall st. PrefixMap -> IRI -> CharParser st Atom
parseDataPropertyAtom PrefixMap
pm IRI
pre,
      CharParser st Atom -> CharParser st Atom
forall st a. CharParser st a -> CharParser st a
parensP (CharParser st Atom -> CharParser st Atom)
-> CharParser st Atom -> CharParser st Atom
forall a b. (a -> b) -> a -> b
$ PrefixMap -> IRI -> CharParser st Atom
forall st. PrefixMap -> IRI -> CharParser st Atom
parseObjectPropertyAtom PrefixMap
pm IRI
pre,
      PrefixMap -> IRI -> CharParser st Atom
forall st. PrefixMap -> IRI -> CharParser st Atom
parseDataRangeAtom PrefixMap
pm IRI
pre,
      CharParser st Atom -> CharParser st Atom
forall st a. CharParser st a -> CharParser st a
parensP (CharParser st Atom -> CharParser st Atom)
-> CharParser st Atom -> CharParser st Atom
forall a b. (a -> b) -> a -> b
$ PrefixMap -> IRI -> CharParser st Atom
forall st. PrefixMap -> IRI -> CharParser st Atom
parseUnknownAtom PrefixMap
pm IRI
pre]

parseRule :: GA.PrefixMap -> CharParser st Axiom
parseRule :: PrefixMap -> CharParser st Axiom
parseRule pm :: PrefixMap
pm = do
  [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
ruleC
  Annotations
anns <- PrefixMap -> CharParser st Annotations
forall st. PrefixMap -> CharParser st Annotations
optionalAnnos PrefixMap
pm
  [Atom]
body <- CharParser st Atom -> CharParser st [Atom]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (PrefixMap -> CharParser st Atom
forall st. PrefixMap -> CharParser st Atom
parseAtom PrefixMap
pm) 
  [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword "->"
  [Atom]
rHead <- CharParser st Atom -> CharParser st [Atom]
forall st a. CharParser st a -> CharParser st [a]
sepByComma (PrefixMap -> CharParser st Atom
forall st. PrefixMap -> CharParser st Atom
parseAtom PrefixMap
pm)
  Axiom -> CharParser st Axiom
forall (m :: * -> *) a. Monad m => a -> m a
return (Axiom -> CharParser st Axiom) -> Axiom -> CharParser st Axiom
forall a b. (a -> b) -> a -> b
$ Rule -> Axiom
Rule (Rule -> Axiom) -> Rule -> Axiom
forall a b. (a -> b) -> a -> b
$ Annotations -> [Atom] -> [Atom] -> Rule
DLSafeRule Annotations
anns [Atom]
body [Atom]
rHead


parseFrame :: GA.PrefixMap -> CharParser st [Axiom]
parseFrame :: PrefixMap -> CharParser st [Axiom]
parseFrame pm :: PrefixMap
pm = do 
  [Axiom]
frames <- PrefixMap -> CharParser st [Axiom]
forall st. PrefixMap -> CharParser st [Axiom]
classFrame PrefixMap
pm CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> PrefixMap -> CharParser st [Axiom]
forall st. PrefixMap -> CharParser st [Axiom]
parseDatatypeFrame PrefixMap
pm
    CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> PrefixMap -> CharParser st [Axiom]
forall st. PrefixMap -> CharParser st [Axiom]
objectPropertyFrame PrefixMap
pm CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> PrefixMap -> CharParser st [Axiom]
forall st. PrefixMap -> CharParser st [Axiom]
dataPropertyFrame PrefixMap
pm CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> PrefixMap -> CharParser st [Axiom]
forall st. PrefixMap -> CharParser st [Axiom]
individualFrame PrefixMap
pm
    CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> PrefixMap -> CharParser st [Axiom]
forall st. PrefixMap -> CharParser st [Axiom]
annotationPropertyFrame PrefixMap
pm CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (PrefixMap -> CharParser st Axiom
forall st. PrefixMap -> CharParser st Axiom
misc PrefixMap
pm CharParser st Axiom
-> (Axiom -> CharParser st [Axiom]) -> CharParser st [Axiom]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return([Axiom] -> CharParser st [Axiom])
-> (Axiom -> [Axiom]) -> Axiom -> CharParser st [Axiom]
forall b c a. (b -> c) -> (a -> b) -> a -> c
.Axiom -> [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return)
    CharParser st [Axiom]
-> CharParser st [Axiom] -> CharParser st [Axiom]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (PrefixMap -> CharParser st Axiom
forall st. PrefixMap -> CharParser st Axiom
parseRule PrefixMap
pm CharParser st Axiom
-> (Axiom -> CharParser st [Axiom]) -> CharParser st [Axiom]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return([Axiom] -> CharParser st [Axiom])
-> (Axiom -> [Axiom]) -> Axiom -> CharParser st [Axiom]
forall b c a. (b -> c) -> (a -> b) -> a -> c
.Axiom -> [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return)
  [Axiom] -> CharParser st [Axiom]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Axiom] -> CharParser st [Axiom])
-> [Axiom] -> CharParser st [Axiom]
forall a b. (a -> b) -> a -> b
$ [Axiom]
frames


importEntry :: GA.PrefixMap -> CharParser st DirectlyImportsDocuments
importEntry :: PrefixMap -> CharParser st [IRI]
importEntry pm :: PrefixMap
pm = ParsecT [Char] st Identity IRI -> CharParser st [IRI]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (ParsecT [Char] st Identity IRI -> CharParser st [IRI])
-> ParsecT [Char] st Identity IRI -> CharParser st [IRI]
forall a b. (a -> b) -> a -> b
$ [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
importC CharParser st ()
-> ParsecT [Char] st Identity IRI -> ParsecT [Char] st Identity IRI
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> PrefixMap -> ParsecT [Char] st Identity IRI
forall st. PrefixMap -> CharParser st IRI
expUriP PrefixMap
pm

parseOntology :: GA.PrefixMap -> CharParser st Ontology
parseOntology :: PrefixMap -> CharParser st Ontology
parseOntology pm :: PrefixMap
pm = do
    (ontologyIRI :: Maybe IRI
ontologyIRI, versionIRI :: Maybe IRI
versionIRI) <- (Maybe IRI, Maybe IRI)
-> ParsecT [Char] st Identity (Maybe IRI, Maybe IRI)
-> ParsecT [Char] st Identity (Maybe IRI, Maybe IRI)
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option (Maybe IRI
forall a. Maybe a
Nothing, Maybe IRI
forall a. Maybe a
Nothing) (do 
        [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
ontologyC
        Maybe IRI
o <- ParsecT [Char] st Identity IRI
-> ParsecT [Char] st Identity (Maybe IRI)
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m (Maybe a)
optionMaybe (PrefixMap -> ParsecT [Char] st Identity IRI
forall st. PrefixMap -> CharParser st IRI
expUriP PrefixMap
pm)
        Maybe IRI
v <- ParsecT [Char] st Identity IRI
-> ParsecT [Char] st Identity (Maybe IRI)
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m (Maybe a)
optionMaybe (PrefixMap -> ParsecT [Char] st Identity IRI
forall st. PrefixMap -> CharParser st IRI
expUriP PrefixMap
pm)
        (Maybe IRI, Maybe IRI)
-> ParsecT [Char] st Identity (Maybe IRI, Maybe IRI)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe IRI
o, Maybe IRI
v)
      )
    [IRI]
imports <- PrefixMap -> CharParser st [IRI]
forall st. PrefixMap -> CharParser st [IRI]
importEntry PrefixMap
pm
    Annotations
anns <- PrefixMap -> CharParser st Annotations
forall st. PrefixMap -> CharParser st Annotations
optionalAnnos PrefixMap
pm
    [[Axiom]]
axs <- ParsecT [Char] st Identity [Axiom]
-> ParsecT [Char] st Identity [[Axiom]]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (ParsecT [Char] st Identity [Axiom]
 -> ParsecT [Char] st Identity [[Axiom]])
-> ParsecT [Char] st Identity [Axiom]
-> ParsecT [Char] st Identity [[Axiom]]
forall a b. (a -> b) -> a -> b
$ PrefixMap -> ParsecT [Char] st Identity [Axiom]
forall st. PrefixMap -> CharParser st [Axiom]
parseFrame PrefixMap
pm
    case (Maybe IRI
ontologyIRI, Maybe IRI
versionIRI, [IRI]
imports, Annotations
anns, [[Axiom]]
axs) of
      (Nothing, Nothing, [], [], []) -> [Char] -> CharParser st Ontology
forall s (m :: * -> *) t u a.
Stream s m t =>
[Char] -> ParsecT s u m a
unexpected "empty ontology"
      _ -> Ontology -> CharParser st Ontology
forall (m :: * -> *) a. Monad m => a -> m a
return (Ontology -> CharParser st Ontology)
-> Ontology -> CharParser st Ontology
forall a b. (a -> b) -> a -> b
$ Maybe IRI
-> Maybe IRI -> [IRI] -> Annotations -> [Axiom] -> Ontology
Ontology Maybe IRI
ontologyIRI Maybe IRI
versionIRI [IRI]
imports Annotations
anns ([[Axiom]] -> [Axiom]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[Axiom]]
axs)
  

parsePrefixDeclaration :: CharParser st (String, IRI)
parsePrefixDeclaration :: CharParser st ([Char], IRI)
parsePrefixDeclaration =  do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
prefixC
    [Char]
p <- CharParser st [Char] -> CharParser st [Char]
forall st a. CharParser st a -> CharParser st a
skips ([Char] -> CharParser st [Char] -> CharParser st [Char]
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option "" CharParser st [Char]
forall st. CharParser st [Char]
prefix CharParser st [Char]
-> ParsecT [Char] st Identity Char -> CharParser st [Char]
forall (m :: * -> *) a b. Monad m => m a -> m b -> m a
<< Char -> ParsecT [Char] st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char ':')
    IRI
i <- CharParser st IRI -> CharParser st IRI
forall st a. CharParser st a -> CharParser st a
skips CharParser st IRI
forall st. IRIParser st IRI
fullIri
    ([Char], IRI) -> CharParser st ([Char], IRI)
forall (m :: * -> *) a. Monad m => a -> m a
return (([Char], IRI) -> CharParser st ([Char], IRI))
-> ([Char], IRI) -> CharParser st ([Char], IRI)
forall a b. (a -> b) -> a -> b
$ ([Char]
p, IRI
i)
  CharParser st ([Char], IRI)
-> CharParser st ([Char], IRI) -> CharParser st ([Char], IRI)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    [Char] -> CharParser st ()
forall st. [Char] -> CharParser st ()
pkeyword [Char]
namespaceC
    [Char]
p <- CharParser st [Char] -> CharParser st [Char]
forall st a. CharParser st a -> CharParser st a
skips CharParser st [Char]
forall st. CharParser st [Char]
prefix
    IRI
i <- CharParser st IRI -> CharParser st IRI
forall st a. CharParser st a -> CharParser st a
skips CharParser st IRI
forall st. IRIParser st IRI
fullIri
    ([Char], IRI) -> CharParser st ([Char], IRI)
forall (m :: * -> *) a. Monad m => a -> m a
return (([Char], IRI) -> CharParser st ([Char], IRI))
-> ([Char], IRI) -> CharParser st ([Char], IRI)
forall a b. (a -> b) -> a -> b
$ ([Char]
p, IRI
i)

parseOntologyDocument :: GA.PrefixMap -> CharParser st OntologyDocument
parseOntologyDocument :: PrefixMap -> CharParser st OntologyDocument
parseOntologyDocument gapm :: PrefixMap
gapm = do
    ParsecT [Char] st Identity () -> ParsecT [Char] st Identity ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
skipMany (ParsecT [Char] st Identity Char -> ParsecT [Char] st Identity ()
forall (m :: * -> *) a. Monad m => m a -> m ()
forget ParsecT [Char] st Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
space ParsecT [Char] st Identity ()
-> ParsecT [Char] st Identity () -> ParsecT [Char] st Identity ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT [Char] st Identity () -> ParsecT [Char] st Identity ()
forall (m :: * -> *) a. Monad m => m a -> m ()
forget ParsecT [Char] st Identity ()
forall st. GenParser Char st ()
comment)
    [([Char], IRI)]
prefixes <- ParsecT [Char] st Identity ([Char], IRI)
-> ParsecT [Char] st Identity [([Char], IRI)]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT [Char] st Identity ([Char], IRI)
forall st. CharParser st ([Char], IRI)
parsePrefixDeclaration
    let pm :: PrefixMap
pm = [PrefixMap] -> PrefixMap
forall (f :: * -> *) k a.
(Foldable f, Ord k) =>
f (Map k a) -> Map k a
Map.unions [PrefixMap
gapm, ([([Char], IRI)] -> PrefixMap
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList [([Char], IRI)]
prefixes), PrefixMap
predefPrefixesGA]
    Ontology
o <- PrefixMap -> CharParser st Ontology
forall st. PrefixMap -> CharParser st Ontology
parseOntology PrefixMap
pm
    OntologyDocument -> CharParser st OntologyDocument
forall (m :: * -> *) a. Monad m => a -> m a
return (OntologyDocument -> CharParser st OntologyDocument)
-> OntologyDocument -> CharParser st OntologyDocument
forall a b. (a -> b) -> a -> b
$ OntologyMetadata -> PrefixMap -> Ontology -> OntologyDocument
OntologyDocument (OntologySyntaxType -> OntologyMetadata
OntologyMetadata OntologySyntaxType
MS) PrefixMap
pm Ontology
o