{-# OPTIONS -w -O0 #-}
{-# LANGUAGE CPP, StandaloneDeriving, DeriveDataTypeable, DeriveGeneric #-}
module ATC.Result () where
import ATC.Id
import ATerm.Lib
import Common.Doc as Doc
import Common.DocUtils
import Common.GlobalAnnotations
import Common.Id
import Common.Json.Instances
import Common.Lexer
import Common.Result
import Control.Applicative
import Control.Monad.Identity
import Data.Aeson(ToJSON, FromJSON)
import Data.Data
import Data.Function
import Data.List
import GHC.Generics(Generic)
import Text.ParserCombinators.Parsec (parse)
import Text.ParserCombinators.Parsec.Char (char)
import Text.ParserCombinators.Parsec.Error
import qualified Control.Monad.Fail as Fail
deriving instance GHC.Generics.Generic (Common.Result.Result a)
instance Data.Aeson.ToJSON a => Data.Aeson.ToJSON (Common.Result.Result a) where
instance Data.Aeson.FromJSON a => Data.Aeson.FromJSON (Common.Result.Result a) where
deriving instance GHC.Generics.Generic Common.Result.Diagnosis
instance Data.Aeson.ToJSON Common.Result.Diagnosis where
instance Data.Aeson.FromJSON Common.Result.Diagnosis where
deriving instance GHC.Generics.Generic Common.Result.DiagKind
instance Data.Aeson.ToJSON Common.Result.DiagKind where
instance Data.Aeson.FromJSON Common.Result.DiagKind where
instance ShATermConvertible a => ShATermConvertible (Common.Result.Result a) where
toShATermAux :: ATermTable -> Result a -> IO (ATermTable, Int)
toShATermAux att0 :: ATermTable
att0 xv :: Result a
xv = case Result a
xv of
Result a :: [Diagnosis]
a b :: Maybe a
b -> do
(att1 :: ATermTable
att1, a' :: Int
a') <- ATermTable -> [Diagnosis] -> IO (ATermTable, Int)
forall t.
ShATermConvertible t =>
ATermTable -> t -> IO (ATermTable, Int)
toShATerm' ATermTable
att0 [Diagnosis]
a
(att2 :: ATermTable
att2, b' :: Int
b') <- ATermTable -> Maybe a -> IO (ATermTable, Int)
forall t.
ShATermConvertible t =>
ATermTable -> t -> IO (ATermTable, Int)
toShATerm' ATermTable
att1 Maybe a
b
(ATermTable, Int) -> IO (ATermTable, Int)
forall (m :: * -> *) a. Monad m => a -> m a
return ((ATermTable, Int) -> IO (ATermTable, Int))
-> (ATermTable, Int) -> IO (ATermTable, Int)
forall a b. (a -> b) -> a -> b
$ ShATerm -> ATermTable -> (ATermTable, Int)
addATerm (String -> [Int] -> [Int] -> ShATerm
ShAAppl "Result" [Int
a', Int
b'] []) ATermTable
att2
fromShATermAux :: Int -> ATermTable -> (ATermTable, Result a)
fromShATermAux ix :: Int
ix att0 :: ATermTable
att0 = case Int -> ATermTable -> ShATerm
getShATerm Int
ix ATermTable
att0 of
ShAAppl "Result" [a :: Int
a, b :: Int
b] _ ->
case Int -> ATermTable -> (ATermTable, [Diagnosis])
forall t.
ShATermConvertible t =>
Int -> ATermTable -> (ATermTable, t)
fromShATerm' Int
a ATermTable
att0 of
{ (att1 :: ATermTable
att1, a' :: [Diagnosis]
a') ->
case Int -> ATermTable -> (ATermTable, Maybe a)
forall t.
ShATermConvertible t =>
Int -> ATermTable -> (ATermTable, t)
fromShATerm' Int
b ATermTable
att1 of
{ (att2 :: ATermTable
att2, b' :: Maybe a
b') ->
(ATermTable
att2, [Diagnosis] -> Maybe a -> Result a
forall a. [Diagnosis] -> Maybe a -> Result a
Result [Diagnosis]
a' Maybe a
b') }}
u :: ShATerm
u -> String -> ShATerm -> (ATermTable, Result a)
forall a. String -> ShATerm -> a
fromShATermError "Common.Result.Result" ShATerm
u
instance ShATermConvertible Common.Result.Diagnosis where
toShATermAux :: ATermTable -> Diagnosis -> IO (ATermTable, Int)
toShATermAux att0 :: ATermTable
att0 xv :: Diagnosis
xv = case Diagnosis
xv of
Diag a :: DiagKind
a b :: String
b c :: Range
c -> do
(att1 :: ATermTable
att1, a' :: Int
a') <- ATermTable -> DiagKind -> IO (ATermTable, Int)
forall t.
ShATermConvertible t =>
ATermTable -> t -> IO (ATermTable, Int)
toShATerm' ATermTable
att0 DiagKind
a
(att2 :: ATermTable
att2, b' :: Int
b') <- ATermTable -> String -> IO (ATermTable, Int)
forall t.
ShATermConvertible t =>
ATermTable -> t -> IO (ATermTable, Int)
toShATerm' ATermTable
att1 String
b
(att3 :: ATermTable
att3, c' :: Int
c') <- ATermTable -> Range -> IO (ATermTable, Int)
forall t.
ShATermConvertible t =>
ATermTable -> t -> IO (ATermTable, Int)
toShATerm' ATermTable
att2 Range
c
(ATermTable, Int) -> IO (ATermTable, Int)
forall (m :: * -> *) a. Monad m => a -> m a
return ((ATermTable, Int) -> IO (ATermTable, Int))
-> (ATermTable, Int) -> IO (ATermTable, Int)
forall a b. (a -> b) -> a -> b
$ ShATerm -> ATermTable -> (ATermTable, Int)
addATerm (String -> [Int] -> [Int] -> ShATerm
ShAAppl "Diag" [Int
a', Int
b', Int
c'] []) ATermTable
att3
fromShATermAux :: Int -> ATermTable -> (ATermTable, Diagnosis)
fromShATermAux ix :: Int
ix att0 :: ATermTable
att0 = case Int -> ATermTable -> ShATerm
getShATerm Int
ix ATermTable
att0 of
ShAAppl "Diag" [a :: Int
a, b :: Int
b, c :: Int
c] _ ->
case Int -> ATermTable -> (ATermTable, DiagKind)
forall t.
ShATermConvertible t =>
Int -> ATermTable -> (ATermTable, t)
fromShATerm' Int
a ATermTable
att0 of
{ (att1 :: ATermTable
att1, a' :: DiagKind
a') ->
case Int -> ATermTable -> (ATermTable, String)
forall t.
ShATermConvertible t =>
Int -> ATermTable -> (ATermTable, t)
fromShATerm' Int
b ATermTable
att1 of
{ (att2 :: ATermTable
att2, b' :: String
b') ->
case Int -> ATermTable -> (ATermTable, Range)
forall t.
ShATermConvertible t =>
Int -> ATermTable -> (ATermTable, t)
fromShATerm' Int
c ATermTable
att2 of
{ (att3 :: ATermTable
att3, c' :: Range
c') ->
(ATermTable
att3, DiagKind -> String -> Range -> Diagnosis
Diag DiagKind
a' String
b' Range
c') }}}
u :: ShATerm
u -> String -> ShATerm -> (ATermTable, Diagnosis)
forall a. String -> ShATerm -> a
fromShATermError "Common.Result.Diagnosis" ShATerm
u
instance ShATermConvertible Common.Result.DiagKind where
toShATermAux :: ATermTable -> DiagKind -> IO (ATermTable, Int)
toShATermAux att0 :: ATermTable
att0 xv :: DiagKind
xv = case DiagKind
xv of
Error -> (ATermTable, Int) -> IO (ATermTable, Int)
forall (m :: * -> *) a. Monad m => a -> m a
return ((ATermTable, Int) -> IO (ATermTable, Int))
-> (ATermTable, Int) -> IO (ATermTable, Int)
forall a b. (a -> b) -> a -> b
$ ShATerm -> ATermTable -> (ATermTable, Int)
addATerm (String -> [Int] -> [Int] -> ShATerm
ShAAppl "Error" [] []) ATermTable
att0
Warning -> (ATermTable, Int) -> IO (ATermTable, Int)
forall (m :: * -> *) a. Monad m => a -> m a
return ((ATermTable, Int) -> IO (ATermTable, Int))
-> (ATermTable, Int) -> IO (ATermTable, Int)
forall a b. (a -> b) -> a -> b
$ ShATerm -> ATermTable -> (ATermTable, Int)
addATerm (String -> [Int] -> [Int] -> ShATerm
ShAAppl "Warning" [] []) ATermTable
att0
Hint -> (ATermTable, Int) -> IO (ATermTable, Int)
forall (m :: * -> *) a. Monad m => a -> m a
return ((ATermTable, Int) -> IO (ATermTable, Int))
-> (ATermTable, Int) -> IO (ATermTable, Int)
forall a b. (a -> b) -> a -> b
$ ShATerm -> ATermTable -> (ATermTable, Int)
addATerm (String -> [Int] -> [Int] -> ShATerm
ShAAppl "Hint" [] []) ATermTable
att0
Debug -> (ATermTable, Int) -> IO (ATermTable, Int)
forall (m :: * -> *) a. Monad m => a -> m a
return ((ATermTable, Int) -> IO (ATermTable, Int))
-> (ATermTable, Int) -> IO (ATermTable, Int)
forall a b. (a -> b) -> a -> b
$ ShATerm -> ATermTable -> (ATermTable, Int)
addATerm (String -> [Int] -> [Int] -> ShATerm
ShAAppl "Debug" [] []) ATermTable
att0
MessageW -> (ATermTable, Int) -> IO (ATermTable, Int)
forall (m :: * -> *) a. Monad m => a -> m a
return ((ATermTable, Int) -> IO (ATermTable, Int))
-> (ATermTable, Int) -> IO (ATermTable, Int)
forall a b. (a -> b) -> a -> b
$ ShATerm -> ATermTable -> (ATermTable, Int)
addATerm (String -> [Int] -> [Int] -> ShATerm
ShAAppl "MessageW" [] []) ATermTable
att0
fromShATermAux :: Int -> ATermTable -> (ATermTable, DiagKind)
fromShATermAux ix :: Int
ix att0 :: ATermTable
att0 = case Int -> ATermTable -> ShATerm
getShATerm Int
ix ATermTable
att0 of
ShAAppl "Error" [] _ -> (ATermTable
att0, DiagKind
Error)
ShAAppl "Warning" [] _ -> (ATermTable
att0, DiagKind
Warning)
ShAAppl "Hint" [] _ -> (ATermTable
att0, DiagKind
Hint)
ShAAppl "Debug" [] _ -> (ATermTable
att0, DiagKind
Debug)
ShAAppl "MessageW" [] _ -> (ATermTable
att0, DiagKind
MessageW)
u :: ShATerm
u -> String -> ShATerm -> (ATermTable, DiagKind)
forall a. String -> ShATerm -> a
fromShATermError "Common.Result.DiagKind" ShATerm
u