{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, DeriveDataTypeable
  , GeneralizedNewtypeDeriving, DeriveGeneric #-}
{- |
Module      :  ./DMU/Logic_DMU.hs
Description :  Instance of class Logic for DMU
Copyright   :  (c) Christian Maeder DFKI, Uni Bremen 2009
License     :  GPLv2 or higher, see LICENSE.txt

Maintainer  :  Christian.Maeder@dfki.de
Stability   :  provisional
Portability :  non-portable (imports Logic.Logic)

dummy instance of class Logic for DMU

-}

module DMU.Logic_DMU where

import Logic.Logic

import Common.DefaultMorphism
import Common.Doc
import Common.DocUtils
import Common.ExtSign
import Common.Id
import Common.Utils

import ATerm.Lib

import Text.ParserCombinators.Parsec

import Data.List
import Data.Monoid ()
import qualified Data.Map as Map
import qualified Data.Set as Set
import Data.Typeable
import GHC.Generics

data DMU = DMU deriving Int -> DMU -> ShowS
[DMU] -> ShowS
DMU -> String
(Int -> DMU -> ShowS)
-> (DMU -> String) -> ([DMU] -> ShowS) -> Show DMU
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DMU] -> ShowS
$cshowList :: [DMU] -> ShowS
show :: DMU -> String
$cshow :: DMU -> String
showsPrec :: Int -> DMU -> ShowS
$cshowsPrec :: Int -> DMU -> ShowS
Show

instance Language DMU where
  description :: DMU -> String
description _ = "a logic to wrap output of the CAD tool Catia"

newtype Text = Text { Text -> String
fromText :: String }
  deriving (Int -> Text -> ShowS
[Text] -> ShowS
Text -> String
(Int -> Text -> ShowS)
-> (Text -> String) -> ([Text] -> ShowS) -> Show Text
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Text] -> ShowS
$cshowList :: [Text] -> ShowS
show :: Text -> String
$cshow :: Text -> String
showsPrec :: Int -> Text -> ShowS
$cshowsPrec :: Int -> Text -> ShowS
Show, Text -> Text -> Bool
(Text -> Text -> Bool) -> (Text -> Text -> Bool) -> Eq Text
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Text -> Text -> Bool
$c/= :: Text -> Text -> Bool
== :: Text -> Text -> Bool
$c== :: Text -> Text -> Bool
Eq, Eq Text
Eq Text =>
(Text -> Text -> Ordering)
-> (Text -> Text -> Bool)
-> (Text -> Text -> Bool)
-> (Text -> Text -> Bool)
-> (Text -> Text -> Bool)
-> (Text -> Text -> Text)
-> (Text -> Text -> Text)
-> Ord Text
Text -> Text -> Bool
Text -> Text -> Ordering
Text -> Text -> Text
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Text -> Text -> Text
$cmin :: Text -> Text -> Text
max :: Text -> Text -> Text
$cmax :: Text -> Text -> Text
>= :: Text -> Text -> Bool
$c>= :: Text -> Text -> Bool
> :: Text -> Text -> Bool
$c> :: Text -> Text -> Bool
<= :: Text -> Text -> Bool
$c<= :: Text -> Text -> Bool
< :: Text -> Text -> Bool
$c< :: Text -> Text -> Bool
compare :: Text -> Text -> Ordering
$ccompare :: Text -> Text -> Ordering
$cp1Ord :: Eq Text
Ord, Text -> [Pos]
Text -> Range
(Text -> Range) -> (Text -> [Pos]) -> GetRange Text
forall a. (a -> Range) -> (a -> [Pos]) -> GetRange a
rangeSpan :: Text -> [Pos]
$crangeSpan :: Text -> [Pos]
getRange :: Text -> Range
$cgetRange :: Text -> Range
GetRange, Typeable, Typeable Text
Typeable Text =>
(ATermTable -> Text -> IO (ATermTable, Int))
-> (ATermTable -> [Text] -> IO (ATermTable, Int))
-> (Int -> ATermTable -> (ATermTable, Text))
-> (Int -> ATermTable -> (ATermTable, [Text]))
-> ShATermConvertible Text
Int -> ATermTable -> (ATermTable, [Text])
Int -> ATermTable -> (ATermTable, Text)
ATermTable -> [Text] -> IO (ATermTable, Int)
ATermTable -> Text -> IO (ATermTable, Int)
forall t.
Typeable t =>
(ATermTable -> t -> IO (ATermTable, Int))
-> (ATermTable -> [t] -> IO (ATermTable, Int))
-> (Int -> ATermTable -> (ATermTable, t))
-> (Int -> ATermTable -> (ATermTable, [t]))
-> ShATermConvertible t
fromShATermList' :: Int -> ATermTable -> (ATermTable, [Text])
$cfromShATermList' :: Int -> ATermTable -> (ATermTable, [Text])
fromShATermAux :: Int -> ATermTable -> (ATermTable, Text)
$cfromShATermAux :: Int -> ATermTable -> (ATermTable, Text)
toShATermList' :: ATermTable -> [Text] -> IO (ATermTable, Int)
$ctoShATermList' :: ATermTable -> [Text] -> IO (ATermTable, Int)
toShATermAux :: ATermTable -> Text -> IO (ATermTable, Int)
$ctoShATermAux :: ATermTable -> Text -> IO (ATermTable, Int)
$cp1ShATermConvertible :: Typeable Text
ShATermConvertible, (forall x. Text -> Rep Text x)
-> (forall x. Rep Text x -> Text) -> Generic Text
forall x. Rep Text x -> Text
forall x. Text -> Rep Text x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Text x -> Text
$cfrom :: forall x. Text -> Rep Text x
Generic)

instance Pretty Text where
  pretty :: Text -> Doc
pretty (Text s :: String
s) = String -> Doc
text String
s

-- use generic Category instance from Logic.Logic

instance Semigroup Text where
    (Text l1 :: String
l1) <> :: Text -> Text -> Text
<> (Text l2 :: String
l2) = String -> Text
Text
      (String -> Text) -> ([String] -> String) -> [String] -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [String] -> String
unlines ([String] -> Text) -> [String] -> Text
forall a b. (a -> b) -> a -> b
$ String -> [String]
lines String
l1 [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ String -> [String]
lines String
l2
instance Monoid Text where
    mempty :: Text
mempty = String -> Text
Text ""

instance Syntax DMU Text () () () where
  parse_basic_spec :: DMU -> Maybe (PrefixMap -> AParser st Text)
parse_basic_spec DMU = (PrefixMap -> AParser st Text)
-> Maybe (PrefixMap -> AParser st Text)
forall a. a -> Maybe a
Just (\ _ -> (String -> Text)
-> ParsecT String (AnnoState st) Identity String -> AParser st Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Text
Text (ParsecT String (AnnoState st) Identity String -> AParser st Text)
-> ParsecT String (AnnoState st) Identity String -> AParser st Text
forall a b. (a -> b) -> a -> b
$ ParsecT String (AnnoState st) Identity Char
-> ParsecT String (AnnoState st) Identity String
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT String (AnnoState st) Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
anyChar)

instance Sentences DMU () Text (DefaultMorphism Text) () where
  map_sen :: DMU -> DefaultMorphism Text -> () -> Result ()
map_sen DMU _ = () -> Result ()
forall (m :: * -> *) a. Monad m => a -> m a
return
  sym_of :: DMU -> Text -> [Set ()]
sym_of DMU _ = [() -> Set ()
forall a. a -> Set a
Set.singleton ()]
  symmap_of :: DMU -> DefaultMorphism Text -> EndoMap ()
symmap_of DMU _ = EndoMap ()
forall k a. Map k a
Map.empty
  sym_name :: DMU -> () -> Id
sym_name DMU _ = String -> Id
genName "DMU"

instance StaticAnalysis DMU Text () () () Text (DefaultMorphism Text) () ()
  where
  basic_analysis :: DMU
-> Maybe
     ((Text, Text, GlobalAnnos)
      -> Result (Text, ExtSign Text (), [Named ()]))
basic_analysis DMU = ((Text, Text, GlobalAnnos)
 -> Result (Text, ExtSign Text (), [Named ()]))
-> Maybe
     ((Text, Text, GlobalAnnos)
      -> Result (Text, ExtSign Text (), [Named ()]))
forall a. a -> Maybe a
Just (((Text, Text, GlobalAnnos)
  -> Result (Text, ExtSign Text (), [Named ()]))
 -> Maybe
      ((Text, Text, GlobalAnnos)
       -> Result (Text, ExtSign Text (), [Named ()])))
-> ((Text, Text, GlobalAnnos)
    -> Result (Text, ExtSign Text (), [Named ()]))
-> Maybe
     ((Text, Text, GlobalAnnos)
      -> Result (Text, ExtSign Text (), [Named ()]))
forall a b. (a -> b) -> a -> b
$ \ (s :: Text
s, _, _) ->
    (Text, ExtSign Text (), [Named ()])
-> Result (Text, ExtSign Text (), [Named ()])
forall (m :: * -> *) a. Monad m => a -> m a
return (Text
s, Text -> ExtSign Text ()
forall sign symbol. sign -> ExtSign sign symbol
mkExtSign Text
s, [])
  empty_signature :: DMU -> Text
empty_signature DMU = String -> Text
Text ""
  is_subsig :: DMU -> Text -> Text -> Bool
is_subsig DMU (Text s1 :: String
s1) (Text s2 :: String
s2) = String -> String -> Bool
forall a. Eq a => [a] -> [a] -> Bool
isInfixOf (ShowS
trim String
s1) String
s2

instance Logic DMU () Text () () () Text (DefaultMorphism Text) () () ()