{- |
Module      :  ./OWL2/Parse.hs
Description :  Manchester syntax parser for OWL 2
Copyright   :  (c) DFKI GmbH, Uni Bremen 2007-2010
License     :  GPLv2 or higher, see LICENSE.txt

Maintainer  :  Christian.Maeder@dfki.de
Stability   :  provisional
Portability :  portable

Contains    :  Parser for the Manchester Syntax into Abstract Syntax of OWL 2

References  :  <http://www.w3.org/TR/2009/NOTE-owl2-manchester-syntax-20091027/>
-}

module OWL2.Parse where

import OWL2.AS
import OWL2.Symbols
import OWL2.Keywords
import OWL2.ColonKeywords

import Common.Keywords
import Common.IRI
import Common.Lexer
import Common.Parsec
import Common.AnnoParser (commentLine)
import Common.Token (criticalKeywords)
import Common.Utils (nubOrd)
import qualified Common.IRI as IRI
import qualified Common.GlobalAnnotations as GA (PrefixMap)

import Text.ParserCombinators.Parsec
import Control.Monad (liftM2)
import Data.Char
import qualified Data.Map as Map
import Data.Maybe (isJust)

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 :: [String]
owlKeywords = String
notS String -> [String] -> [String]
forall a. a -> [a] -> [a]
: String
stringS String -> [String] -> [String]
forall a. a -> [a] -> [a]
: (EntityType -> String) -> [EntityType] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map EntityType -> String
forall a. Show a => a -> String
show [EntityType]
entityTypes
  [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ (Character -> String) -> [Character] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map Character -> String
forall a. Show a => a -> String
show [Character]
characters [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String]
keywords [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String]
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 -> String -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
elem Char
c ".+-_\183"

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

iunreserved :: Char -> Bool
iunreserved :: Char -> Bool
iunreserved c :: Char
c = Char -> Bool
isAlphaNum Char
c Bool -> Bool -> Bool
|| Char -> String -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
elem Char
c "-._~" Bool -> Bool -> Bool
|| Char -> Int
ord Char
c Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= 160 Bool -> Bool -> Bool
&& Char -> Int
ord Char
c Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= 55295

-- maybe lower case hex-digits should be illegal
pctEncoded :: CharParser st String
pctEncoded :: CharParser st String
pctEncoded = Char -> ParsecT String st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char '%' ParsecT String st Identity Char
-> CharParser st String -> CharParser st String
forall (m :: * -> *) a. Monad m => m a -> m [a] -> m [a]
<:> ParsecT String st Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
hexDigit ParsecT String st Identity Char
-> CharParser st String -> CharParser st String
forall (m :: * -> *) a. Monad m => m a -> m [a] -> m [a]
<:> ParsecT String st Identity Char -> CharParser st String
forall (m :: * -> *) a. Monad m => m a -> m [a]
single ParsecT String st Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
hexDigit

{- comma and parens are removed here
   but would cause no problems for full IRIs within angle brackets -}
subDelims :: Char -> Bool
subDelims :: Char -> Bool
subDelims c :: Char
c = Char -> String -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
elem Char
c "!$&'*+;="

iunreservedSubDelims :: String -> CharParser st Char
iunreservedSubDelims :: String -> CharParser st Char
iunreservedSubDelims cs :: String
cs =
    (Char -> Bool) -> CharParser st Char
forall s (m :: * -> *) u.
Stream s m Char =>
(Char -> Bool) -> ParsecT s u m Char
satisfy ((Char -> Bool) -> CharParser st Char)
-> (Char -> Bool) -> CharParser st Char
forall a b. (a -> b) -> a -> b
$ \ c :: Char
c -> Char -> Bool
iunreserved Char
c Bool -> Bool -> Bool
|| Char -> Bool
subDelims Char
c Bool -> Bool -> Bool
|| Char -> String -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
elem Char
c String
cs

iunreservedPctEncodedSubDelims :: String -> CharParser st String
iunreservedPctEncodedSubDelims :: String -> CharParser st String
iunreservedPctEncodedSubDelims cs :: String
cs =
    ParsecT String st Identity Char -> CharParser st String
forall (m :: * -> *) a. Monad m => m a -> m [a]
single (String -> ParsecT String st Identity Char
forall st. String -> CharParser st Char
iunreservedSubDelims String
cs) CharParser st String
-> CharParser st String -> CharParser st String
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> CharParser st String
forall st. CharParser st String
pctEncoded

ipChar :: CharParser st String
ipChar :: CharParser st String
ipChar = String -> CharParser st String
forall st. String -> CharParser st String
iunreservedPctEncodedSubDelims ":@"

ifragment :: CharParser st String
ifragment :: CharParser st String
ifragment = ParsecT String st Identity [String] -> CharParser st String
forall (m :: * -> *) a. Monad m => m [[a]] -> m [a]
flat (ParsecT String st Identity [String] -> CharParser st String)
-> ParsecT String st Identity [String] -> CharParser st String
forall a b. (a -> b) -> a -> b
$ CharParser st String -> ParsecT String st Identity [String]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (CharParser st String
forall st. CharParser st String
ipChar CharParser st String
-> CharParser st String -> CharParser st String
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT String st Identity Char -> CharParser st String
forall (m :: * -> *) a. Monad m => m a -> m [a]
single (Char -> ParsecT String st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char '/' ParsecT String st Identity Char
-> ParsecT String st Identity Char
-> ParsecT String st Identity Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Char -> ParsecT String st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char '?'))

iquery :: CharParser st String
iquery :: CharParser st String
iquery = CharParser st String
forall st. CharParser st String
ifragment -- ignore iprivate

iregName :: CharParser st String
iregName :: CharParser st String
iregName = ParsecT String st Identity [String] -> CharParser st String
forall (m :: * -> *) a. Monad m => m [[a]] -> m [a]
flat (ParsecT String st Identity [String] -> CharParser st String)
-> ParsecT String st Identity [String] -> CharParser st String
forall a b. (a -> b) -> a -> b
$ CharParser st String -> ParsecT String st Identity [String]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (CharParser st String -> ParsecT String st Identity [String])
-> CharParser st String -> ParsecT String st Identity [String]
forall a b. (a -> b) -> a -> b
$ String -> CharParser st String
forall st. String -> CharParser st String
iunreservedPctEncodedSubDelims ""

iuserinfo :: CharParser st String
iuserinfo :: CharParser st String
iuserinfo = ParsecT String st Identity [String] -> CharParser st String
forall (m :: * -> *) a. Monad m => m [[a]] -> m [a]
flat (ParsecT String st Identity [String] -> CharParser st String)
-> ParsecT String st Identity [String] -> CharParser st String
forall a b. (a -> b) -> a -> b
$ CharParser st String -> ParsecT String st Identity [String]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (CharParser st String -> ParsecT String st Identity [String])
-> CharParser st String -> ParsecT String st Identity [String]
forall a b. (a -> b) -> a -> b
$ String -> CharParser st String
forall st. String -> CharParser st String
iunreservedPctEncodedSubDelims ":"

-- | 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

decOctet :: CharParser st String
decOctet :: CharParser st String
decOctet = Int -> GenParser Char st Char -> CharParser st String
forall tok st a. Int -> GenParser tok st a -> GenParser tok st [a]
atMost 3 GenParser Char st Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
digit
  CharParser st String -> (String -> Bool) -> CharParser st String
forall a tok st.
Show a =>
GenParser tok st a -> (a -> Bool) -> GenParser tok st a
`checkWith` \ s :: String
s -> let v :: Int
v = Int -> String -> Int
value 10 String
s in Int
v Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= 255 Bool -> Bool -> Bool
&&
                             (if Int
v Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== 0 then String
s String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== "0" else Int -> String -> String
forall a. Int -> [a] -> [a]
take 1 String
s String -> String -> Bool
forall a. Eq a => a -> a -> Bool
/= "0")

iPv4Adress :: CharParser st String
iPv4Adress :: CharParser st String
iPv4Adress = CharParser st String
forall st. CharParser st String
decOctet CharParser st String
-> CharParser st String -> CharParser st String
forall (m :: * -> *) a. Monad m => m [a] -> m [a] -> m [a]
<++> String -> CharParser st String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string "."
  CharParser st String
-> CharParser st String -> CharParser st String
forall (m :: * -> *) a. Monad m => m [a] -> m [a] -> m [a]
<++> CharParser st String
forall st. CharParser st String
decOctet CharParser st String
-> CharParser st String -> CharParser st String
forall (m :: * -> *) a. Monad m => m [a] -> m [a] -> m [a]
<++> String -> CharParser st String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string "."
  CharParser st String
-> CharParser st String -> CharParser st String
forall (m :: * -> *) a. Monad m => m [a] -> m [a] -> m [a]
<++> CharParser st String
forall st. CharParser st String
decOctet CharParser st String
-> CharParser st String -> CharParser st String
forall (m :: * -> *) a. Monad m => m [a] -> m [a] -> m [a]
<++> String -> CharParser st String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string "."
  CharParser st String
-> CharParser st String -> CharParser st String
forall (m :: * -> *) a. Monad m => m [a] -> m [a] -> m [a]
<++> CharParser st String
forall st. CharParser st String
decOctet

ihost :: CharParser st String
ihost :: CharParser st String
ihost = CharParser st String
forall st. CharParser st String
iregName CharParser st String
-> CharParser st String -> CharParser st String
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> CharParser st String
forall st. CharParser st String
iPv4Adress -- or ipLiteral

port :: CharParser st String
port :: CharParser st String
port = ParsecT String st Identity Char -> CharParser st String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT String st Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
digit

iauthority :: CharParser st String
iauthority :: CharParser st String
iauthority = CharParser st String -> CharParser st String
forall tok st a. GenParser tok st [a] -> GenParser tok st [a]
optionL (CharParser st String -> CharParser st String
forall tok st a. GenParser tok st a -> GenParser tok st a
try (CharParser st String -> CharParser st String)
-> CharParser st String -> CharParser st String
forall a b. (a -> b) -> a -> b
$ CharParser st String
forall st. CharParser st String
iuserinfo CharParser st String
-> CharParser st String -> CharParser st String
forall (m :: * -> *) a. Monad m => m [a] -> m [a] -> m [a]
<++> String -> CharParser st String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string "@") CharParser st String
-> CharParser st String -> CharParser st String
forall (m :: * -> *) a. Monad m => m [a] -> m [a] -> m [a]
<++> CharParser st String
forall st. CharParser st String
ihost
    CharParser st String
-> CharParser st String -> CharParser st String
forall (m :: * -> *) a. Monad m => m [a] -> m [a] -> m [a]
<++> CharParser st String -> CharParser st String
forall tok st a. GenParser tok st [a] -> GenParser tok st [a]
optionL (Char -> ParsecT String st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char ':' ParsecT String st Identity Char
-> CharParser st String -> CharParser st String
forall (m :: * -> *) a. Monad m => m a -> m [a] -> m [a]
<:> CharParser st String
forall st. CharParser st String
port)

isegment :: CharParser st String
isegment :: CharParser st String
isegment = ParsecT String st Identity [String] -> CharParser st String
forall (m :: * -> *) a. Monad m => m [[a]] -> m [a]
flat (ParsecT String st Identity [String] -> CharParser st String)
-> ParsecT String st Identity [String] -> CharParser st String
forall a b. (a -> b) -> a -> b
$ CharParser st String -> ParsecT String st Identity [String]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many CharParser st String
forall st. CharParser st String
ipChar

isegmentNz :: CharParser st String
isegmentNz :: CharParser st String
isegmentNz = ParsecT String st Identity [String] -> CharParser st String
forall (m :: * -> *) a. Monad m => m [[a]] -> m [a]
flat (ParsecT String st Identity [String] -> CharParser st String)
-> ParsecT String st Identity [String] -> CharParser st String
forall a b. (a -> b) -> a -> b
$ CharParser st String -> ParsecT String st Identity [String]
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 CharParser st String
forall st. CharParser st String
ipChar

ipathAbempty :: CharParser st String
ipathAbempty :: CharParser st String
ipathAbempty = ParsecT String st Identity [String] -> CharParser st String
forall (m :: * -> *) a. Monad m => m [[a]] -> m [a]
flat (ParsecT String st Identity [String] -> CharParser st String)
-> ParsecT String st Identity [String] -> CharParser st String
forall a b. (a -> b) -> a -> b
$ CharParser st String -> ParsecT String st Identity [String]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (Char -> ParsecT String st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char '/' ParsecT String st Identity Char
-> CharParser st String -> CharParser st String
forall (m :: * -> *) a. Monad m => m a -> m [a] -> m [a]
<:> CharParser st String
forall st. CharParser st String
isegment)

ipathAbsolute :: CharParser st String
ipathAbsolute :: CharParser st String
ipathAbsolute = Char -> ParsecT String st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char '/' ParsecT String st Identity Char
-> CharParser st String -> CharParser st String
forall (m :: * -> *) a. Monad m => m a -> m [a] -> m [a]
<:> CharParser st String -> CharParser st String
forall tok st a. GenParser tok st [a] -> GenParser tok st [a]
optionL (CharParser st String
forall st. CharParser st String
isegmentNz CharParser st String
-> CharParser st String -> CharParser st String
forall (m :: * -> *) a. Monad m => m [a] -> m [a] -> m [a]
<++> CharParser st String
forall st. CharParser st String
ipathAbempty)

{- within abbreviated IRIs only ipath-noscheme should be used
   that excludes colons via isegment-nz-nc -}
ipathRootless :: CharParser st String
ipathRootless :: CharParser st String
ipathRootless = CharParser st String
forall st. CharParser st String
isegmentNz CharParser st String
-> CharParser st String -> CharParser st String
forall (m :: * -> *) a. Monad m => m [a] -> m [a] -> m [a]
<++> CharParser st String
forall st. CharParser st String
ipathAbempty

iauthorityWithPath :: CharParser st String
iauthorityWithPath :: CharParser st String
iauthorityWithPath = String -> CharParser st String
forall st. String -> CharParser st String
tryString "//" CharParser st String
-> CharParser st String -> CharParser st String
forall (m :: * -> *) a. Monad m => m [a] -> m [a] -> m [a]
<++> CharParser st String
forall st. CharParser st String
iauthority CharParser st String
-> CharParser st String -> CharParser st String
forall (m :: * -> *) a. Monad m => m [a] -> m [a] -> m [a]
<++> CharParser st String
forall st. CharParser st String
ipathAbempty

optQueryOrFrag :: CharParser st String
optQueryOrFrag :: CharParser st String
optQueryOrFrag = CharParser st String -> CharParser st String
forall tok st a. GenParser tok st [a] -> GenParser tok st [a]
optionL (Char -> ParsecT String st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char '?' ParsecT String st Identity Char
-> CharParser st String -> CharParser st String
forall (m :: * -> *) a. Monad m => m a -> m [a] -> m [a]
<:> CharParser st String
forall st. CharParser st String
iquery)
  CharParser st String
-> CharParser st String -> CharParser st String
forall (m :: * -> *) a. Monad m => m [a] -> m [a] -> m [a]
<++> CharParser st String -> CharParser st String
forall tok st a. GenParser tok st [a] -> GenParser tok st [a]
optionL (Char -> ParsecT String st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char '#' ParsecT String st Identity Char
-> CharParser st String -> CharParser st String
forall (m :: * -> *) a. Monad m => m a -> m [a] -> m [a]
<:> CharParser st String
forall st. CharParser st String
ifragment)

-- | covers irelative-part (therefore we omit curie)
ihierPart :: CharParser st String
ihierPart :: CharParser st String
ihierPart =
  CharParser st String
forall st. CharParser st String
iauthorityWithPath CharParser st String
-> CharParser st String -> CharParser st String
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> CharParser st String
forall st. CharParser st String
ipathAbsolute CharParser st String
-> CharParser st String -> CharParser st String
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> CharParser st String
forall st. CharParser st String
ipathRootless

hierPartWithOpts :: CharParser st String
hierPartWithOpts :: CharParser st String
hierPartWithOpts = (Char -> ParsecT String st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char '#' ParsecT String st Identity Char
-> CharParser st String -> CharParser st String
forall (m :: * -> *) a. Monad m => m a -> m [a] -> m [a]
<:> CharParser st String
forall st. CharParser st String
ifragment) CharParser st String
-> CharParser st String -> CharParser st String
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> CharParser st String
forall st. CharParser st String
ihierPart CharParser st String
-> CharParser st String -> CharParser st String
forall (m :: * -> *) a. Monad m => m [a] -> m [a] -> m [a]
<++> CharParser st String
forall st. CharParser st String
optQueryOrFrag

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


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

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

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 String st Identity Char
-> ParsecT String 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 String st Identity Char
 -> ParsecT String st Identity (Maybe Char))
-> (ParsecT String st Identity Char
    -> ParsecT String st Identity Char)
-> ParsecT String st Identity Char
-> ParsecT String st Identity (Maybe Char)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParsecT String st Identity Char -> ParsecT String st Identity Char
forall tok st a. GenParser tok st a -> GenParser tok st a
try (ParsecT String st Identity Char
 -> ParsecT String st Identity Char)
-> (ParsecT String st Identity Char
    -> ParsecT String st Identity Char)
-> ParsecT String st Identity Char
-> ParsecT String st Identity Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParsecT String st Identity Char -> ParsecT String 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 String st Identity Char
 -> ParsecT String st Identity (Maybe Char))
-> ParsecT String st Identity Char
-> ParsecT String st Identity (Maybe Char)
forall a b. (a -> b) -> a -> b
$ Char -> ParsecT String st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char ':'
  (IRI -> String)
-> CharParser st IRI -> (IRI -> Bool) -> CharParser st IRI
forall a tok st.
(a -> String)
-> GenParser tok st a -> (a -> Bool) -> GenParser tok st a
checkWithUsing (\i :: IRI
i -> "keyword \"" String -> String -> String
forall a. [a] -> [a] -> [a]
++ IRI -> String
showIRI IRI
i String -> String -> String
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 :: String
p = IRI -> String
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 String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
p then String -> [String] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
notElem (IRI -> String
iFragment IRI
q) [String]
owlKeywords
    else String -> [String] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
notElem String
p ([String] -> Bool) -> [String] -> Bool
forall a b. (a -> b) -> a -> b
$ (String -> String) -> [String] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map ((Char -> Bool) -> String -> String
forall a. (a -> Bool) -> [a] -> [a]
takeWhile (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
/= ':'))
        ([String] -> [String]) -> [String] -> [String]
forall a b. (a -> b) -> a -> b
$ [String]
colonKeywords
        [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [ EquivOrDisjoint -> String
forall a. Show a => a -> String
show EquivOrDisjoint
d String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
e | EquivOrDisjoint
d <- [EquivOrDisjoint]
equivOrDisjointL, String
e <- [String
classesC, String
propertiesC]]

extEntity :: CharParser st ExtEntityType
extEntity :: CharParser st ExtEntityType
extEntity =
    (EntityType -> ExtEntityType)
-> ParsecT String st Identity EntityType
-> CharParser st ExtEntityType
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap EntityType -> ExtEntityType
EntityType ParsecT String st Identity EntityType
forall st. CharParser st EntityType
entityType
   CharParser st ExtEntityType
-> CharParser st ExtEntityType -> CharParser st ExtEntityType
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ExtEntityType
-> CharParser st ExtEntityType -> CharParser st ExtEntityType
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option ExtEntityType
AnyEntity (String -> CharParser st ()
forall st. String -> CharParser st ()
pkeyword "Prefix" CharParser st ()
-> CharParser st ExtEntityType -> CharParser st ExtEntityType
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ExtEntityType -> CharParser st ExtEntityType
forall (m :: * -> *) a. Monad m => a -> m a
return ExtEntityType
PrefixO)

symbItem :: GenParser Char st SymbItems
symbItem :: GenParser Char st SymbItems
symbItem = do
    ExtEntityType
ext <- CharParser st ExtEntityType
forall st. CharParser st ExtEntityType
extEntity
    IRI
i <- CharParser st IRI
forall st. IRIParser st IRI
uriP
    SymbItems -> GenParser Char st SymbItems
forall (m :: * -> *) a. Monad m => a -> m a
return (SymbItems -> GenParser Char st SymbItems)
-> SymbItems -> GenParser Char st SymbItems
forall a b. (a -> b) -> a -> b
$ ExtEntityType -> [IRI] -> SymbItems
SymbItems ExtEntityType
ext [IRI
i]

symbItems :: GenParser Char st SymbItems
symbItems :: GenParser Char st SymbItems
symbItems = do
    ExtEntityType
ext <- CharParser st ExtEntityType
forall st. CharParser st ExtEntityType
extEntity
    [IRI]
iris <- GenParser Char st [IRI]
forall st. GenParser Char st [IRI]
symbs
    SymbItems -> GenParser Char st SymbItems
forall (m :: * -> *) a. Monad m => a -> m a
return (SymbItems -> GenParser Char st SymbItems)
-> SymbItems -> GenParser Char st SymbItems
forall a b. (a -> b) -> a -> b
$ ExtEntityType -> [IRI] -> SymbItems
SymbItems ExtEntityType
ext [IRI]
iris

-- | parse a comma separated list of uris
symbs :: GenParser Char st [IRI]
symbs :: GenParser Char st [IRI]
symbs = CharParser st IRI
forall st. IRIParser st IRI
uriP CharParser st IRI
-> (IRI -> GenParser Char st [IRI]) -> GenParser Char st [IRI]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \ u :: IRI
u -> do
    CharParser st ()
forall st. CharParser st ()
commaP CharParser st () -> CharParser st IRI -> CharParser st ()
forall tok st a b.
GenParser tok st a -> GenParser tok st b -> GenParser tok st a
`followedWith` CharParser st IRI
forall st. IRIParser st IRI
uriP
    [IRI]
us <- GenParser Char st [IRI]
forall st. GenParser Char st [IRI]
symbs
    [IRI] -> GenParser Char st [IRI]
forall (m :: * -> *) a. Monad m => a -> m a
return ([IRI] -> GenParser Char st [IRI])
-> [IRI] -> GenParser Char st [IRI]
forall a b. (a -> b) -> a -> b
$ IRI
u IRI -> [IRI] -> [IRI]
forall a. a -> [a] -> [a]
: [IRI]
us
  GenParser Char st [IRI]
-> GenParser Char st [IRI] -> GenParser Char st [IRI]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> [IRI] -> GenParser Char st [IRI]
forall (m :: * -> *) a. Monad m => a -> m a
return [IRI
u]

-- | parse a possibly kinded list of comma separated symbol pairs
symbMapItems :: GenParser Char st SymbMapItems
symbMapItems :: GenParser Char st SymbMapItems
symbMapItems = do
  ExtEntityType
ext <- CharParser st ExtEntityType
forall st. CharParser st ExtEntityType
extEntity
  [(IRI, Maybe IRI)]
iris <- GenParser Char st [(IRI, Maybe IRI)]
forall st. GenParser Char st [(IRI, Maybe IRI)]
symbPairs
  SymbMapItems -> GenParser Char st SymbMapItems
forall (m :: * -> *) a. Monad m => a -> m a
return (SymbMapItems -> GenParser Char st SymbMapItems)
-> SymbMapItems -> GenParser Char st SymbMapItems
forall a b. (a -> b) -> a -> b
$ ExtEntityType -> [(IRI, Maybe IRI)] -> SymbMapItems
SymbMapItems ExtEntityType
ext [(IRI, Maybe IRI)]
iris

-- | parse a comma separated list of uri pairs
symbPairs :: GenParser Char st [(IRI, Maybe IRI)]
symbPairs :: GenParser Char st [(IRI, Maybe IRI)]
symbPairs = GenParser Char st (IRI, Maybe IRI)
forall st. GenParser Char st (IRI, Maybe IRI)
uriPair GenParser Char st (IRI, Maybe IRI)
-> ((IRI, Maybe IRI) -> GenParser Char st [(IRI, Maybe IRI)])
-> GenParser Char st [(IRI, Maybe IRI)]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \ u :: (IRI, Maybe IRI)
u -> do
    CharParser st ()
forall st. CharParser st ()
commaP CharParser st () -> GenParser Char st IRI -> CharParser st ()
forall tok st a b.
GenParser tok st a -> GenParser tok st b -> GenParser tok st a
`followedWith` GenParser Char st IRI
forall st. IRIParser st IRI
uriP
    [(IRI, Maybe IRI)]
us <- GenParser Char st [(IRI, Maybe IRI)]
forall st. GenParser Char st [(IRI, Maybe IRI)]
symbPairs
    [(IRI, Maybe IRI)] -> GenParser Char st [(IRI, Maybe IRI)]
forall (m :: * -> *) a. Monad m => a -> m a
return ([(IRI, Maybe IRI)] -> GenParser Char st [(IRI, Maybe IRI)])
-> [(IRI, Maybe IRI)] -> GenParser Char st [(IRI, Maybe IRI)]
forall a b. (a -> b) -> a -> b
$ (IRI, Maybe IRI)
u (IRI, Maybe IRI) -> [(IRI, Maybe IRI)] -> [(IRI, Maybe IRI)]
forall a. a -> [a] -> [a]
: [(IRI, Maybe IRI)]
us
  GenParser Char st [(IRI, Maybe IRI)]
-> GenParser Char st [(IRI, Maybe IRI)]
-> GenParser Char st [(IRI, Maybe IRI)]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> [(IRI, Maybe IRI)] -> GenParser Char st [(IRI, Maybe IRI)]
forall (m :: * -> *) a. Monad m => a -> m a
return [(IRI, Maybe IRI)
u]

uriPair :: GenParser Char st (IRI, Maybe IRI)
uriPair :: GenParser Char st (IRI, Maybe IRI)
uriPair = CharParser st IRI
forall st. IRIParser st IRI
uriP CharParser st IRI
-> (IRI -> GenParser Char st (IRI, Maybe IRI))
-> GenParser Char st (IRI, Maybe IRI)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \ u :: IRI
u -> do
    CharParser st String -> CharParser st Token
forall st. CharParser st String -> CharParser st Token
pToken (CharParser st String -> CharParser st Token)
-> CharParser st String -> CharParser st Token
forall a b. (a -> b) -> a -> b
$ String -> CharParser st String
forall st. String -> CharParser st String
toKey String
mapsTo
    IRI
u2 <- CharParser st IRI
forall st. IRIParser st IRI
uriP
    (IRI, Maybe IRI) -> GenParser Char st (IRI, Maybe IRI)
forall (m :: * -> *) a. Monad m => a -> m a
return (IRI
u, IRI -> Maybe IRI
forall a. a -> Maybe a
Just IRI
u2)
  GenParser Char st (IRI, Maybe IRI)
-> GenParser Char st (IRI, Maybe IRI)
-> GenParser Char st (IRI, Maybe IRI)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (IRI, Maybe IRI) -> GenParser Char st (IRI, Maybe IRI)
forall (m :: * -> *) a. Monad m => a -> m a
return (IRI
u, Maybe IRI
forall a. Maybe a
Nothing)

datatypeUri :: CharParser st IRI
datatypeUri :: CharParser st IRI
datatypeUri = (String -> IRI)
-> ParsecT String st Identity String -> CharParser st IRI
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> IRI
mkIRI ([ParsecT String st Identity String]
-> ParsecT String st Identity String
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice ([ParsecT String st Identity String]
 -> ParsecT String st Identity String)
-> [ParsecT String st Identity String]
-> ParsecT String st Identity String
forall a b. (a -> b) -> a -> b
$ (String -> ParsecT String st Identity String)
-> [String] -> [ParsecT String st Identity String]
forall a b. (a -> b) -> [a] -> [b]
map String -> ParsecT String st Identity String
forall st. String -> CharParser st String
keyword [String]
datatypeKeys) 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
<|> CharParser st IRI
forall st. IRIParser st IRI
uriP

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 String 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
== '-') (String -> ParsecT String st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
oneOf "+-")

postDecimal :: CharParser st NNInt
postDecimal :: CharParser st NNInt
postDecimal = Char -> ParsecT String st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char '.' ParsecT String 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 = (String -> NNInt)
-> ParsecT String st Identity String -> CharParser st NNInt
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ([Int] -> NNInt
NNInt ([Int] -> NNInt) -> (String -> [Int]) -> String -> NNInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Int) -> String -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map Char -> Int
digitToInt) ParsecT String st Identity String
forall st. CharParser st String
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

decimalLit :: CharParser st DecLit
decimalLit :: CharParser st DecLit
decimalLit = (IntLit -> NNInt -> DecLit)
-> ParsecT String st Identity IntLit
-> ParsecT String 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 String st Identity IntLit
forall st. CharParser st IntLit
intLit (ParsecT String st Identity NNInt -> CharParser st DecLit)
-> ParsecT String st Identity NNInt -> CharParser st DecLit
forall a b. (a -> b) -> a -> b
$ NNInt
-> ParsecT String st Identity NNInt
-> ParsecT String 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 String 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 String st Identity IntLit
-> ParsecT String 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 (String -> ParsecT String st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
oneOf "eE" ParsecT String st Identity Char
-> ParsecT String st Identity IntLit
-> ParsecT String st Identity IntLit
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT String st Identity IntLit
forall st. CharParser st IntLit
intLit)
   ParsecT String st Identity Char
-> ParsecT String 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 String st Identity Char
 -> ParsecT String st Identity (Maybe Char))
-> ParsecT String st Identity Char
-> ParsecT String st Identity (Maybe Char)
forall a b. (a -> b) -> a -> b
$ String -> ParsecT String st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> 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 String
languageTag = Int -> GenParser Char st Char -> CharParser st String
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 String
-> CharParser st String -> CharParser st String
forall (m :: * -> *) a. Monad m => m [a] -> m [a] -> m [a]
<++> ParsecT String st Identity [String] -> CharParser st String
forall (m :: * -> *) a. Monad m => m [[a]] -> m [a]
flat (CharParser st String -> ParsecT String st Identity [String]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (CharParser st String -> ParsecT String st Identity [String])
-> CharParser st String -> ParsecT String st Identity [String]
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 String -> CharParser st String
forall (m :: * -> *) a. Monad m => m a -> m [a] -> m [a]
<:> Int -> GenParser Char st Char -> CharParser st String
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 :: String -> String
rmQuotes s :: String
s = case String
s of
  _ : tl :: String
tl@(_ : _) -> String -> String
forall a. [a] -> [a]
init String
tl
  _ -> String -> String
forall a. HasCallStack => String -> a
error "rmQuotes"

stringLiteral :: CharParser st Literal
stringLiteral :: CharParser st Literal
stringLiteral = do
  String
s <- (String -> String)
-> ParsecT String st Identity String
-> ParsecT String st Identity String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> String
rmQuotes ParsecT String st Identity String
forall st. CharParser st String
stringLit
  do
      String -> ParsecT String st Identity String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
cTypeS
      IRI
d <- CharParser st IRI
forall st. IRIParser st IRI
datatypeUri
      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
$ String -> TypedOrUntyped -> Literal
Literal String
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
        String -> ParsecT String st Identity String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
asP
        Maybe String
t <- CharParser st (Maybe String) -> CharParser st (Maybe String)
forall st a. CharParser st a -> CharParser st a
skips (CharParser st (Maybe String) -> CharParser st (Maybe String))
-> CharParser st (Maybe String) -> CharParser st (Maybe String)
forall a b. (a -> b) -> a -> b
$ ParsecT String st Identity String -> CharParser st (Maybe String)
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m (Maybe a)
optionMaybe ParsecT String st Identity String
forall st. CharParser st String
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
$ String -> TypedOrUntyped -> Literal
Literal String
s (TypedOrUntyped -> Literal) -> TypedOrUntyped -> Literal
forall a b. (a -> b) -> a -> b
$ Maybe String -> TypedOrUntyped
Untyped Maybe String
t
    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 (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
$ String -> TypedOrUntyped -> Literal
Literal String
s (TypedOrUntyped -> Literal) -> TypedOrUntyped -> Literal
forall a b. (a -> b) -> a -> b
$ IRI -> TypedOrUntyped
Typed (IRI -> TypedOrUntyped) -> IRI -> TypedOrUntyped
forall a b. (a -> b) -> a -> b
$ (String -> IRI
mkIRI String
stringS) {prefixName :: String
prefixName = "xsd"} )

literal :: CharParser st Literal
literal :: CharParser st Literal
literal = 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 String st Identity DecLit -> CharParser st FloatLit
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap DecLit -> FloatLit
decToFloat ParsecT String 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
forall st. CharParser st Literal
stringLiteral

-- * description

owlClassUri :: CharParser st IRI
owlClassUri :: CharParser st IRI
owlClassUri = CharParser st IRI
forall st. IRIParser st IRI
uriP

individualUri :: CharParser st IRI
individualUri :: CharParser st IRI
individualUri = CharParser st IRI
forall st. IRIParser st IRI
uriP

individual :: CharParser st Individual
individual :: CharParser st IRI
individual = do
    IRI
i <- CharParser st IRI
forall st. IRIParser st IRI
individualUri
    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 -> String
prefixName IRI
i String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== "_" then IRI
i {isBlankNode :: Bool
isBlankNode = Bool
True}
                                    else IRI
i

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

parensP :: CharParser st a -> CharParser st a
parensP :: CharParser st a -> CharParser st a
parensP = ParsecT String st Identity ()
-> ParsecT String 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 String st Identity ()
forall st. Char -> CharParser st ()
skipChar '(') (Char -> ParsecT String st Identity ()
forall st. Char -> CharParser st ()
skipChar ')')

bracesP :: CharParser st a -> CharParser st a
bracesP :: CharParser st a -> CharParser st a
bracesP = ParsecT String st Identity ()
-> ParsecT String 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 String st Identity ()
forall st. Char -> CharParser st ()
skipChar '{') (Char -> ParsecT String st Identity ()
forall st. Char -> CharParser st ()
skipChar '}')

bracketsP :: CharParser st a -> CharParser st a
bracketsP :: CharParser st a -> CharParser st a
bracketsP = ParsecT String st Identity ()
-> ParsecT String 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 String st Identity ()
forall st. Char -> CharParser st ()
skipChar '[') (Char -> ParsecT String st Identity ()
forall st. Char -> CharParser st ()
skipChar ']')

commaP :: CharParser st ()
commaP :: CharParser st ()
commaP = CharParser st () -> CharParser st ()
forall (m :: * -> *) a. Monad m => m a -> m ()
forget (CharParser st () -> CharParser st ())
-> CharParser st () -> CharParser st ()
forall a b. (a -> b) -> a -> b
$ 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 String st Identity () -> CharParser st [a]
forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
sepBy1 CharParser st a
p ParsecT String st Identity ()
forall st. CharParser st ()
commaP

-- | plain string parser with skip
pkeyword :: String -> CharParser st ()
pkeyword :: String -> CharParser st ()
pkeyword s :: String
s = ParsecT String st Identity String -> CharParser st ()
forall (m :: * -> *) a. Monad m => m a -> m ()
forget (ParsecT String st Identity String -> CharParser st ())
-> (CharParser st Char -> ParsecT String st Identity String)
-> CharParser st Char
-> CharParser st ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> CharParser st Char -> ParsecT String st Identity String
forall st. String -> CharParser st Char -> CharParser st String
keywordNotFollowedBy String
s (CharParser st Char -> CharParser st ())
-> CharParser st Char -> CharParser st ()
forall a b. (a -> b) -> a -> b
$ 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 :: String -> CharParser st Char -> CharParser st String
keywordNotFollowedBy s :: String
s c :: CharParser st Char
c = CharParser st String -> CharParser st String
forall st a. CharParser st a -> CharParser st a
skips (CharParser st String -> CharParser st String)
-> CharParser st String -> CharParser st String
forall a b. (a -> b) -> a -> b
$ CharParser st String -> CharParser st String
forall tok st a. GenParser tok st a -> GenParser tok st a
try (CharParser st String -> CharParser st String)
-> CharParser st String -> CharParser st String
forall a b. (a -> b) -> a -> b
$ String -> CharParser st String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
s CharParser st String
-> ParsecT String st Identity () -> CharParser st String
forall (m :: * -> *) a b. Monad m => m a -> m b -> m a
<< CharParser st Char -> ParsecT String 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 :: String -> CharParser st String
keyword s :: String
s = String -> CharParser st Char -> CharParser st String
forall st. String -> CharParser st Char -> CharParser st String
keywordNotFollowedBy String
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 :: CharParser st ClassExpression
atomic :: CharParser st ClassExpression
atomic = CharParser st ClassExpression -> CharParser st ClassExpression
forall st a. CharParser st a -> CharParser st a
parensP CharParser st ClassExpression
forall st. CharParser st ClassExpression
description
  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)
-> ParsecT String st Identity [IRI]
-> CharParser st ClassExpression
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [IRI] -> ClassExpression
ObjectOneOf (ParsecT String st Identity [IRI]
-> ParsecT String st Identity [IRI]
forall st a. CharParser st a -> CharParser st a
bracesP (ParsecT String st Identity [IRI]
 -> ParsecT String st Identity [IRI])
-> ParsecT String st Identity [IRI]
-> ParsecT String st Identity [IRI]
forall a b. (a -> b) -> a -> b
$ CharParser st IRI -> ParsecT String st Identity [IRI]
forall st a. CharParser st a -> CharParser st [a]
sepByComma CharParser st IRI
forall st. IRIParser st IRI
individual)

objectPropertyExpr :: CharParser st ObjectPropertyExpression
objectPropertyExpr :: CharParser st ObjectPropertyExpression
objectPropertyExpr = do
    String -> CharParser st String
forall st. String -> CharParser st String
keyword String
inverseS
    (ObjectPropertyExpression -> ObjectPropertyExpression)
-> CharParser st ObjectPropertyExpression
-> CharParser st ObjectPropertyExpression
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ObjectPropertyExpression -> ObjectPropertyExpression
ObjectInverseOf CharParser st ObjectPropertyExpression
forall st. CharParser st ObjectPropertyExpression
objectPropertyExpr
  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)
-> ParsecT String st Identity IRI
-> CharParser st ObjectPropertyExpression
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap IRI -> ObjectPropertyExpression
ObjectProp ParsecT String st Identity IRI
forall st. IRIParser st IRI
uriP

-- creating the facet-value pairs
facetValuePair :: CharParser st (ConstrainingFacet, RestrictionValue)
facetValuePair :: CharParser st (IRI, Literal)
facetValuePair = do
  DatatypeFacet
df <- [ParsecT String st Identity DatatypeFacet]
-> ParsecT String 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 String st Identity DatatypeFacet]
 -> ParsecT String st Identity DatatypeFacet)
-> [ParsecT String st Identity DatatypeFacet]
-> ParsecT String st Identity DatatypeFacet
forall a b. (a -> b) -> a -> b
$ (DatatypeFacet -> ParsecT String st Identity DatatypeFacet)
-> [DatatypeFacet] -> [ParsecT String st Identity DatatypeFacet]
forall a b. (a -> b) -> [a] -> [b]
map (\ f :: DatatypeFacet
f -> String -> CharParser st String
forall st. String -> CharParser st String
keyword (DatatypeFacet -> String
showFacet DatatypeFacet
f) CharParser st String
-> ParsecT String st Identity DatatypeFacet
-> ParsecT String st Identity DatatypeFacet
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> DatatypeFacet -> ParsecT String 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 String st Identity DatatypeFacet]
-> [ParsecT String st Identity DatatypeFacet]
-> [ParsecT String st Identity DatatypeFacet]
forall a. [a] -> [a] -> [a]
++ (DatatypeFacet -> ParsecT String st Identity DatatypeFacet)
-> [DatatypeFacet] -> [ParsecT String st Identity DatatypeFacet]
forall a b. (a -> b) -> [a] -> [b]
map
      (\ f :: DatatypeFacet
f -> String -> CharParser st Char -> CharParser st String
forall st. String -> CharParser st Char -> CharParser st String
keywordNotFollowedBy (DatatypeFacet -> String
showFacet DatatypeFacet
f) (String -> CharParser st Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
oneOf "<>=")
              CharParser st String
-> ParsecT String st Identity DatatypeFacet
-> ParsecT String st Identity DatatypeFacet
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> DatatypeFacet -> ParsecT String st Identity DatatypeFacet
forall (m :: * -> *) a. Monad m => a -> m a
return DatatypeFacet
f)
      [ DatatypeFacet
MININCLUSIVE
      , DatatypeFacet
MINEXCLUSIVE
      , DatatypeFacet
MAXINCLUSIVE
      , DatatypeFacet
MAXEXCLUSIVE ]
  Literal
rv <- CharParser st Literal
forall st. CharParser st Literal
literal
  (IRI, Literal) -> CharParser st (IRI, Literal)
forall (m :: * -> *) a. Monad m => a -> m a
return (DatatypeFacet -> IRI
facetToIRI DatatypeFacet
df, Literal
rv)

-- it returns DataType Datatype or DatatypeRestriction Datatype [facetValuePair]
dataRangeRestriction :: CharParser st DataRange
dataRangeRestriction :: CharParser st DataRange
dataRangeRestriction = do
  IRI
e <- CharParser st IRI
forall st. IRIParser st IRI
datatypeUri
  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 String 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 String st Identity [(IRI, Literal)]
 -> CharParser st DataRange)
-> ParsecT String st Identity [(IRI, Literal)]
-> CharParser st DataRange
forall a b. (a -> b) -> a -> b
$ ParsecT String st Identity [(IRI, Literal)]
-> ParsecT String st Identity [(IRI, Literal)]
forall st a. CharParser st a -> CharParser st a
bracketsP
    (ParsecT String st Identity [(IRI, Literal)]
 -> ParsecT String st Identity [(IRI, Literal)])
-> ParsecT String st Identity [(IRI, Literal)]
-> ParsecT String st Identity [(IRI, Literal)]
forall a b. (a -> b) -> a -> b
$ CharParser st (IRI, Literal)
-> ParsecT String st Identity [(IRI, Literal)]
forall st a. CharParser st a -> CharParser st [a]
sepByComma CharParser st (IRI, Literal)
forall st. CharParser st (IRI, Literal)
facetValuePair

dataConjunct :: CharParser st DataRange
dataConjunct :: CharParser st DataRange
dataConjunct = ([DataRange] -> DataRange)
-> ParsecT String 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 String st Identity [DataRange] -> CharParser st DataRange)
-> ParsecT String st Identity [DataRange]
-> CharParser st DataRange
forall a b. (a -> b) -> a -> b
$ CharParser st DataRange
-> ParsecT String st Identity String
-> ParsecT String st Identity [DataRange]
forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
sepBy1 CharParser st DataRange
forall st. CharParser st DataRange
dataPrimary (ParsecT String st Identity String
 -> ParsecT String st Identity [DataRange])
-> ParsecT String st Identity String
-> ParsecT String st Identity [DataRange]
forall a b. (a -> b) -> a -> b
$ String -> ParsecT String st Identity String
forall st. String -> CharParser st String
keyword String
andS

dataRange :: CharParser st DataRange
dataRange :: CharParser st DataRange
dataRange = ([DataRange] -> DataRange)
-> ParsecT String 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 String st Identity [DataRange] -> CharParser st DataRange)
-> ParsecT String st Identity [DataRange]
-> CharParser st DataRange
forall a b. (a -> b) -> a -> b
$ CharParser st DataRange
-> ParsecT String st Identity String
-> ParsecT String st Identity [DataRange]
forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
sepBy1 CharParser st DataRange
forall st. CharParser st DataRange
dataConjunct (ParsecT String st Identity String
 -> ParsecT String st Identity [DataRange])
-> ParsecT String st Identity String
-> ParsecT String st Identity [DataRange]
forall a b. (a -> b) -> a -> b
$ String -> ParsecT String st Identity String
forall st. String -> CharParser st String
keyword String
orS

dataPrimary :: CharParser st DataRange
dataPrimary :: CharParser st DataRange
dataPrimary = do
    String -> CharParser st String
forall st. String -> CharParser st String
keyword String
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 CharParser st DataRange
forall st. CharParser st DataRange
dataPrimary
   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 String st Identity [Literal] -> CharParser st DataRange
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Literal] -> DataRange
DataOneOf (ParsecT String st Identity [Literal]
-> ParsecT String st Identity [Literal]
forall st a. CharParser st a -> CharParser st a
bracesP (ParsecT String st Identity [Literal]
 -> ParsecT String st Identity [Literal])
-> ParsecT String st Identity [Literal]
-> ParsecT String st Identity [Literal]
forall a b. (a -> b) -> a -> b
$ CharParser st Literal -> ParsecT String st Identity [Literal]
forall st a. CharParser st a -> CharParser st [a]
sepByComma CharParser st Literal
forall st. CharParser st Literal
literal)
   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
forall st. CharParser st DataRange
dataRangeRestriction

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
  [] -> String -> DataRange
forall a. HasCallStack => String -> 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 -> String -> CharParser st String
forall st. String -> CharParser st String
keyword (QuantifierType -> String
showQuantifierType QuantifierType
f) CharParser st String
-> 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 String st Identity CardinalityType]
-> ParsecT String 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 String st Identity CardinalityType]
 -> ParsecT String st Identity CardinalityType)
-> [ParsecT String st Identity CardinalityType]
-> ParsecT String st Identity CardinalityType
forall a b. (a -> b) -> a -> b
$ (CardinalityType -> ParsecT String st Identity CardinalityType)
-> [CardinalityType]
-> [ParsecT String st Identity CardinalityType]
forall a b. (a -> b) -> [a] -> [b]
map (\ f :: CardinalityType
f -> String -> CharParser st Char -> CharParser st String
forall st. String -> CharParser st Char -> CharParser st String
keywordNotFollowedBy (CardinalityType -> String
showCardinalityType CardinalityType
f) CharParser st Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
letter
                            CharParser st String
-> ParsecT String st Identity CardinalityType
-> ParsecT String st Identity CardinalityType
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> CardinalityType -> ParsecT String st Identity CardinalityType
forall (m :: * -> *) a. Monad m => a -> m a
return CardinalityType
f)
             [CardinalityType
MinCardinality, CardinalityType
MaxCardinality, CardinalityType
ExactCardinality]
  String
n <- CharParser st String -> CharParser st String
forall st a. CharParser st a -> CharParser st a
skips CharParser st String
forall st. CharParser st String
getNumber
  (CardinalityType, Int) -> CharParser st (CardinalityType, Int)
forall (m :: * -> *) a. Monad m => a -> m a
return (CardinalityType
c, Int -> String -> Int
value 10 String
n)

-- tries to parse either a IRI or a literal
individualOrConstant :: CharParser st (Either Individual Literal)
individualOrConstant :: CharParser st (Either IRI Literal)
individualOrConstant = (Literal -> Either IRI Literal)
-> ParsecT String 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 ParsecT String st Identity Literal
forall st. CharParser st Literal
literal 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 String 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 ParsecT String st Identity IRI
forall st. IRIParser st IRI
individual

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

primaryOrDataRange :: CharParser st (Either ClassExpression DataRange)
primaryOrDataRange :: CharParser st (Either ClassExpression DataRange)
primaryOrDataRange = do
  [String]
ns <- ParsecT String st Identity String
-> ParsecT String st Identity [String]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (ParsecT String st Identity String
 -> ParsecT String st Identity [String])
-> ParsecT String st Identity String
-> ParsecT String st Identity [String]
forall a b. (a -> b) -> a -> b
$ String -> ParsecT String st Identity String
forall st. String -> CharParser st String
keyword String
notS  -- allows multiple not before primary
  Either ClassExpression DataRange
ed <- do
      IRI
u <- CharParser st IRI
forall st. IRIParser st IRI
datatypeUri
      (ClassExpression -> Either ClassExpression DataRange)
-> ParsecT String 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 (ObjectPropertyExpression
-> ParsecT String st Identity ClassExpression
forall st.
ObjectPropertyExpression -> CharParser st ClassExpression
restrictionAny (ObjectPropertyExpression
 -> ParsecT String st Identity ClassExpression)
-> ObjectPropertyExpression
-> ParsecT String 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 String 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 String st Identity [(IRI, Literal)]
-> ParsecT String st Identity [(IRI, Literal)]
forall st a. CharParser st a -> CharParser st a
bracketsP (ParsecT String st Identity [(IRI, Literal)]
 -> ParsecT String st Identity [(IRI, Literal)])
-> ParsecT String st Identity [(IRI, Literal)]
-> ParsecT String st Identity [(IRI, Literal)]
forall a b. (a -> b) -> a -> b
$ CharParser st (IRI, Literal)
-> ParsecT String st Identity [(IRI, Literal)]
forall st a. CharParser st a -> CharParser st [a]
sepByComma CharParser st (IRI, Literal)
forall st. CharParser st (IRI, Literal)
facetValuePair)
        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])
forall st. CharParser st (Either [IRI] [Literal])
individualOrConstantList
      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 String 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 ParsecT String st Identity ClassExpression
forall st. CharParser st ClassExpression
restrictionOrAtomic
  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 ([String] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [String]
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
  [] -> String -> ClassExpression
forall a. HasCallStack => String -> a
error "mkObjectJunction"
  [x :: ClassExpression
x] -> ClassExpression
x
  ns :: [ClassExpression]
ns -> JunctionType -> [ClassExpression] -> ClassExpression
ObjectJunction JunctionType
ty [ClassExpression]
ns

restrictionAny :: ObjectPropertyExpression -> CharParser st ClassExpression
restrictionAny :: ObjectPropertyExpression -> CharParser st ClassExpression
restrictionAny opExpr :: ObjectPropertyExpression
opExpr = do
      String -> CharParser st String
forall st. String -> CharParser st String
keyword String
valueS
      Either IRI Literal
e <- CharParser st (Either IRI Literal)
forall st. CharParser st (Either IRI Literal)
individualOrConstant
      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
          _ -> String -> CharParser st ClassExpression
forall s (m :: * -> *) t u a.
Stream s m t =>
String -> 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
      String -> CharParser st String
forall st. String -> CharParser st String
keyword String
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
      String -> CharParser st String
forall st. String -> CharParser st String
keyword String
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
forall st. CharParser st ClassExpression
description
      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
      String -> CharParser st String
forall st. String -> CharParser st String
keyword String
hasS
      IRI
iu <- CharParser st IRI
forall st. IRIParser st IRI
individual
      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 <- CharParser st (Either ClassExpression DataRange)
forall st. CharParser st (Either ClassExpression DataRange)
primaryOrDataRange
      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
          _ -> String -> CharParser st ClassExpression
forall s (m :: * -> *) t u a.
Stream s m t =>
String -> ParsecT s u m a
unexpected (String -> CharParser st ClassExpression)
-> String -> CharParser st ClassExpression
forall a b. (a -> b) -> a -> b
$ "dataRange after " String -> String -> String
forall a. [a] -> [a] -> [a]
++ QuantifierType -> String
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
     String 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)
forall st. CharParser st (Either ClassExpression DataRange)
primaryOrDataRange
      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
             _ -> String -> CharParser st ClassExpression
forall s (m :: * -> *) t u a.
Stream s m t =>
String -> ParsecT s u m a
unexpected (String -> CharParser st ClassExpression)
-> String -> CharParser st ClassExpression
forall a b. (a -> b) -> a -> b
$ "dataRange after " String -> String -> String
forall a. [a] -> [a] -> [a]
++ CardinalityType -> String
showCardinalityType CardinalityType
c

restriction :: CharParser st ClassExpression
restriction :: CharParser st ClassExpression
restriction = CharParser st ObjectPropertyExpression
forall st. CharParser st ObjectPropertyExpression
objectPropertyExpr CharParser st ObjectPropertyExpression
-> (ObjectPropertyExpression -> CharParser st ClassExpression)
-> CharParser st ClassExpression
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ObjectPropertyExpression -> CharParser st ClassExpression
forall st.
ObjectPropertyExpression -> CharParser st ClassExpression
restrictionAny

restrictionOrAtomic :: CharParser st ClassExpression
restrictionOrAtomic :: CharParser st ClassExpression
restrictionOrAtomic = do
    ObjectPropertyExpression
opExpr <- CharParser st ObjectPropertyExpression
forall st. CharParser st ObjectPropertyExpression
objectPropertyExpr
    ObjectPropertyExpression -> CharParser st ClassExpression
forall st.
ObjectPropertyExpression -> CharParser st ClassExpression
restrictionAny 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
       _ -> String -> CharParser st ClassExpression
forall s (m :: * -> *) t u a.
Stream s m t =>
String -> 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
<|> CharParser st ClassExpression
forall st. CharParser st ClassExpression
atomic

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 = (String -> CharParser st String
forall st. String -> CharParser st String
keyword String
notS CharParser st String -> 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 :: CharParser st ClassExpression
primary :: CharParser st ClassExpression
primary = (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
forall st. CharParser st ClassExpression
restrictionOrAtomic

conjunction :: CharParser st ClassExpression
conjunction :: CharParser st ClassExpression
conjunction = do
    ClassExpression
curi <- (IRI -> ClassExpression)
-> ParsecT String st Identity IRI -> CharParser st ClassExpression
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap IRI -> ClassExpression
Expression (ParsecT String st Identity IRI -> CharParser st ClassExpression)
-> ParsecT String st Identity IRI -> CharParser st ClassExpression
forall a b. (a -> b) -> a -> b
$ ParsecT String st Identity IRI -> ParsecT String st Identity IRI
forall tok st a. GenParser tok st a -> GenParser tok st a
try (ParsecT String st Identity IRI
forall st. IRIParser st IRI
owlClassUri ParsecT String st Identity IRI
-> ParsecT String st Identity String
-> ParsecT String st Identity IRI
forall (m :: * -> *) a b. Monad m => m a -> m b -> m a
<< String -> ParsecT String st Identity String
forall st. String -> CharParser st String
keyword String
thatS)
    [ClassExpression]
rs <- CharParser st ClassExpression
-> ParsecT String st Identity String
-> ParsecT String st Identity [ClassExpression]
forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> 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
forall st. CharParser st ClassExpression
restriction) (ParsecT String st Identity String
 -> ParsecT String st Identity [ClassExpression])
-> ParsecT String st Identity String
-> ParsecT String st Identity [ClassExpression]
forall a b. (a -> b) -> a -> b
$ String -> ParsecT String st Identity String
forall st. String -> CharParser st String
keyword String
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
<|> ([ClassExpression] -> ClassExpression)
-> ParsecT String st Identity [ClassExpression]
-> CharParser st ClassExpression
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (JunctionType -> [ClassExpression] -> ClassExpression
mkObjectJunction JunctionType
IntersectionOf)
      (CharParser st ClassExpression
-> ParsecT String st Identity String
-> ParsecT String st Identity [ClassExpression]
forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
sepBy1 CharParser st ClassExpression
forall st. CharParser st ClassExpression
primary (ParsecT String st Identity String
 -> ParsecT String st Identity [ClassExpression])
-> ParsecT String st Identity String
-> ParsecT String st Identity [ClassExpression]
forall a b. (a -> b) -> a -> b
$ String -> ParsecT String st Identity String
forall st. String -> CharParser st String
keyword String
andS)

description :: CharParser st ClassExpression
description :: CharParser st ClassExpression
description =
  ([ClassExpression] -> ClassExpression)
-> ParsecT String st Identity [ClassExpression]
-> CharParser st ClassExpression
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (JunctionType -> [ClassExpression] -> ClassExpression
mkObjectJunction JunctionType
UnionOf) (ParsecT String st Identity [ClassExpression]
 -> CharParser st ClassExpression)
-> ParsecT String st Identity [ClassExpression]
-> CharParser st ClassExpression
forall a b. (a -> b) -> a -> b
$ CharParser st ClassExpression
-> ParsecT String st Identity String
-> ParsecT String st Identity [ClassExpression]
forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
sepBy1 CharParser st ClassExpression
forall st. CharParser st ClassExpression
conjunction (ParsecT String st Identity String
 -> ParsecT String st Identity [ClassExpression])
-> ParsecT String st Identity String
-> ParsecT String st Identity [ClassExpression]
forall a b. (a -> b) -> a -> b
$ String -> ParsecT String st Identity String
forall st. String -> CharParser st String
keyword String
orS

entityType :: CharParser st EntityType
entityType :: CharParser st EntityType
entityType = [CharParser st EntityType] -> CharParser st EntityType
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice ([CharParser st EntityType] -> CharParser st EntityType)
-> [CharParser st EntityType] -> CharParser st EntityType
forall a b. (a -> b) -> a -> b
$ (EntityType -> CharParser st EntityType)
-> [EntityType] -> [CharParser st EntityType]
forall a b. (a -> b) -> [a] -> [b]
map (\ f :: EntityType
f -> String -> CharParser st String
forall st. String -> CharParser st String
keyword (EntityType -> String
forall a. Show a => a -> String
show EntityType
f) CharParser st String
-> CharParser st EntityType -> CharParser st EntityType
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> EntityType -> CharParser st EntityType
forall (m :: * -> *) a. Monad m => a -> m a
return EntityType
f)
  [EntityType]
entityTypes

{- | same as annotation Target in Manchester Syntax,
      named annotation Value in Abstract Syntax -}
annotationValue :: CharParser st AnnotationValue
annotationValue :: CharParser st AnnotationValue
annotationValue = do
    Literal
l <- CharParser st Literal
forall st. CharParser st Literal
literal
    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 <- CharParser st IRI
forall st. IRIParser st IRI
individual
    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]

equivOrDisjoint :: CharParser st EquivOrDisjoint
equivOrDisjoint :: CharParser st EquivOrDisjoint
equivOrDisjoint = [CharParser st EquivOrDisjoint] -> CharParser st EquivOrDisjoint
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice
  ([CharParser st EquivOrDisjoint] -> CharParser st EquivOrDisjoint)
-> [CharParser st EquivOrDisjoint] -> CharParser st EquivOrDisjoint
forall a b. (a -> b) -> a -> b
$ (EquivOrDisjoint -> CharParser st EquivOrDisjoint)
-> [EquivOrDisjoint] -> [CharParser st EquivOrDisjoint]
forall a b. (a -> b) -> [a] -> [b]
map (\ f :: EquivOrDisjoint
f -> String -> CharParser st ()
forall st. String -> CharParser st ()
pkeyword (EquivOrDisjoint -> String
showEquivOrDisjoint EquivOrDisjoint
f) CharParser st ()
-> CharParser st EquivOrDisjoint -> CharParser st EquivOrDisjoint
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> EquivOrDisjoint -> CharParser st EquivOrDisjoint
forall (m :: * -> *) a. Monad m => a -> m a
return EquivOrDisjoint
f)
  [EquivOrDisjoint]
equivOrDisjointL

subPropertyKey :: CharParser st ()
subPropertyKey :: CharParser st ()
subPropertyKey = String -> CharParser st ()
forall st. String -> CharParser st ()
pkeyword String
subPropertyOfC

characterKey :: CharParser st ()
characterKey :: CharParser st ()
characterKey = String -> CharParser st ()
forall st. String -> CharParser st ()
pkeyword String
characteristicsC

sameOrDifferent :: CharParser st SameOrDifferent
sameOrDifferent :: CharParser st SameOrDifferent
sameOrDifferent = [CharParser st SameOrDifferent] -> CharParser st SameOrDifferent
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice
  ([CharParser st SameOrDifferent] -> CharParser st SameOrDifferent)
-> [CharParser st SameOrDifferent] -> CharParser st SameOrDifferent
forall a b. (a -> b) -> a -> b
$ (SameOrDifferent -> CharParser st SameOrDifferent)
-> [SameOrDifferent] -> [CharParser st SameOrDifferent]
forall a b. (a -> b) -> [a] -> [b]
map (\ f :: SameOrDifferent
f -> String -> CharParser st ()
forall st. String -> CharParser st ()
pkeyword (SameOrDifferent -> String
showSameOrDifferent SameOrDifferent
f) CharParser st ()
-> CharParser st SameOrDifferent -> CharParser st SameOrDifferent
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SameOrDifferent -> CharParser st SameOrDifferent
forall (m :: * -> *) a. Monad m => a -> m a
return SameOrDifferent
f)
  [SameOrDifferent
Same, SameOrDifferent
Different]

sameOrDifferentIndu :: CharParser st SameOrDifferent
sameOrDifferentIndu :: CharParser st SameOrDifferent
sameOrDifferentIndu = (String -> CharParser st ()
forall st. String -> CharParser st ()
pkeyword String
sameIndividualC CharParser st ()
-> CharParser st SameOrDifferent -> CharParser st SameOrDifferent
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SameOrDifferent -> CharParser st SameOrDifferent
forall (m :: * -> *) a. Monad m => a -> m a
return SameOrDifferent
Same)
    CharParser st SameOrDifferent
-> CharParser st SameOrDifferent -> CharParser st SameOrDifferent
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (String -> CharParser st ()
forall st. String -> CharParser st ()
pkeyword String
differentIndividualsC CharParser st ()
-> CharParser st SameOrDifferent -> CharParser st SameOrDifferent
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SameOrDifferent -> CharParser st SameOrDifferent
forall (m :: * -> *) a. Monad m => a -> m a
return SameOrDifferent
Different)

equivOrDisjointKeyword :: String -> CharParser st EquivOrDisjoint
equivOrDisjointKeyword :: String -> CharParser st EquivOrDisjoint
equivOrDisjointKeyword ext :: String
ext = [CharParser st EquivOrDisjoint] -> CharParser st EquivOrDisjoint
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice
  ([CharParser st EquivOrDisjoint] -> CharParser st EquivOrDisjoint)
-> [CharParser st EquivOrDisjoint] -> CharParser st EquivOrDisjoint
forall a b. (a -> b) -> a -> b
$ (EquivOrDisjoint -> CharParser st EquivOrDisjoint)
-> [EquivOrDisjoint] -> [CharParser st EquivOrDisjoint]
forall a b. (a -> b) -> [a] -> [b]
map (\ f :: EquivOrDisjoint
f -> String -> CharParser st ()
forall st. String -> CharParser st ()
pkeyword (EquivOrDisjoint -> String
forall a. Show a => a -> String
show EquivOrDisjoint
f String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
ext) CharParser st ()
-> CharParser st EquivOrDisjoint -> CharParser st EquivOrDisjoint
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> EquivOrDisjoint -> CharParser st EquivOrDisjoint
forall (m :: * -> *) a. Monad m => a -> m a
return EquivOrDisjoint
f)
  [EquivOrDisjoint]
equivOrDisjointL

objectPropertyCharacter :: CharParser st Character
objectPropertyCharacter :: CharParser st Character
objectPropertyCharacter =
  [CharParser st Character] -> CharParser st Character
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice ([CharParser st Character] -> CharParser st Character)
-> [CharParser st Character] -> CharParser st Character
forall a b. (a -> b) -> a -> b
$ (Character -> CharParser st Character)
-> [Character] -> [CharParser st Character]
forall a b. (a -> b) -> [a] -> [b]
map (\ f :: Character
f -> String -> CharParser st String
forall st. String -> CharParser st String
keyword (Character -> String
forall a. Show a => a -> String
show Character
f) CharParser st String
-> CharParser st Character -> CharParser st Character
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Character -> CharParser st Character
forall (m :: * -> *) a. Monad m => a -> m a
return Character
f) [Character]
characters

domainOrRange :: CharParser st DomainOrRange
domainOrRange :: CharParser st DomainOrRange
domainOrRange = [CharParser st DomainOrRange] -> CharParser st DomainOrRange
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice
  ([CharParser st DomainOrRange] -> CharParser st DomainOrRange)
-> [CharParser st DomainOrRange] -> CharParser st DomainOrRange
forall a b. (a -> b) -> a -> b
$ (DomainOrRange -> CharParser st DomainOrRange)
-> [DomainOrRange] -> [CharParser st DomainOrRange]
forall a b. (a -> b) -> [a] -> [b]
map (\ f :: DomainOrRange
f -> String -> CharParser st ()
forall st. String -> CharParser st ()
pkeyword (DomainOrRange -> String
showDomainOrRange DomainOrRange
f) CharParser st ()
-> CharParser st DomainOrRange -> CharParser st DomainOrRange
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> DomainOrRange -> CharParser st DomainOrRange
forall (m :: * -> *) a. Monad m => a -> m a
return DomainOrRange
f)
  [DomainOrRange
ADomain, DomainOrRange
ARange]

nsEntry :: CharParser st (String, IRI)
nsEntry :: CharParser st (String, IRI)
nsEntry = do
    String -> CharParser st ()
forall st. String -> CharParser st ()
pkeyword String
prefixC
    String
p <- CharParser st String -> CharParser st String
forall st a. CharParser st a -> CharParser st a
skips (String -> CharParser st String -> CharParser st String
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option "" CharParser st String
forall st. CharParser st String
prefix CharParser st String
-> ParsecT String st Identity Char -> CharParser st String
forall (m :: * -> *) a b. Monad m => m a -> m b -> m a
<< Char -> ParsecT String 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
    (String, IRI) -> CharParser st (String, IRI)
forall (m :: * -> *) a. Monad m => a -> m a
return (String
p, IRI
i)
  CharParser st (String, IRI)
-> CharParser st (String, IRI) -> CharParser st (String, IRI)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do
    String -> CharParser st ()
forall st. String -> CharParser st ()
pkeyword String
namespaceC
    String
p <- CharParser st String -> CharParser st String
forall st a. CharParser st a -> CharParser st a
skips CharParser st String
forall st. CharParser st String
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
    (String, IRI) -> CharParser st (String, IRI)
forall (m :: * -> *) a. Monad m => a -> m a
return (String
p, IRI
i)

importEntry :: CharParser st IRI
importEntry :: CharParser st IRI
importEntry = String -> CharParser st ()
forall st. String -> CharParser st ()
pkeyword String
importC CharParser st () -> CharParser st IRI -> CharParser st IRI
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> CharParser st IRI
forall st. IRIParser st IRI
uriP

convertPrefixMap :: GA.PrefixMap -> Map.Map String String
convertPrefixMap :: PrefixMap -> Map String String
convertPrefixMap = (IRI -> String) -> PrefixMap -> Map String String
forall a b k. (a -> b) -> Map k a -> Map k b
Map.map ((IRI -> String) -> PrefixMap -> Map String String)
-> (IRI -> String) -> PrefixMap -> Map String String
forall a b. (a -> b) -> a -> b
$ IRI -> String
IRI.iriToStringUnsecure (IRI -> String) -> (IRI -> IRI) -> IRI -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> IRI -> IRI
IRI.setAngles Bool
False