module OWL2.Translate where
import Common.IRI
import Common.Id
import Common.ProofUtils
import Data.Char
import OWL2.Parse
idToAnonIRI :: Bool -> Id -> IRI
idToAnonIRI :: Bool -> Id -> IRI
idToAnonIRI = Int -> Bool -> Id -> IRI
idToAnonNumberedIRI (-1)
idToNumberedIRI :: Id -> Int -> IRI
idToNumberedIRI :: Id -> Int -> IRI
idToNumberedIRI i :: Id
i n :: Int
n = Int -> Bool -> Id -> IRI
idToAnonNumberedIRI Int
n Bool
False Id
i
idToAnonNumberedIRI :: Int -> Bool -> Id -> IRI
idToAnonNumberedIRI :: Int -> Bool -> Id -> IRI
idToAnonNumberedIRI n :: Int
n b :: Bool
b i :: Id
i = IRI
nullIRI
{ iriPath :: Id
iriPath = String -> Id
stringToId ((if Bool
b then ('_' Char -> String -> String
forall a. a -> [a] -> [a]
:) else String -> String
forall a. a -> a
id) (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$ String -> String
transString (Id -> String
forall a. Show a => a -> String
show Id
i)
String -> String -> String
forall a. [a] -> [a] -> [a]
++ if Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< 0 then "" else '_' Char -> String -> String
forall a. a -> [a] -> [a]
: Int -> String
forall a. Show a => a -> String
show Int
n)
, iriPos :: Range
iriPos = Id -> Range
rangeOfId Id
i
, isAbbrev :: Bool
isAbbrev = Bool
True }
transString :: String -> String
transString :: String -> String
transString str :: String
str = let
x :: Char
x = 'x'
replaceChar1 :: Char -> String
replaceChar1 d :: Char
d | Char
d Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
x = [Char
x, Char
x]
| Char -> Bool
iunreserved Char
d = [Char
d]
| Bool
otherwise = Char
x Char -> String -> String
forall a. a -> [a] -> [a]
: Char -> String
replaceChar Char
d
in case String
str of
"" -> [Char
x]
c :: Char
c : s :: String
s -> let l :: String
l = Char -> String
replaceChar1 Char
c in
(if Char -> Bool
isDigit Char
c Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== '_' then [Char
x, Char
c]
else String
l) String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Char -> String) -> String -> String
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Char -> String
replaceChar1 String
s
replaceChar :: Char -> String
replaceChar :: Char -> String
replaceChar c :: Char
c = if Char -> Bool
isAlphaNum Char
c then [Char
c] else Char -> String
lookupCharMap Char
c