Sml_cats.hs revision 306763c67bb99228487345b32ab8c5c6cd41f23c
e6d40133bc9f858308654afb1262b8b483ec5922Till MossakowskiModule : $Header$
1549f3abf73c1122acff724f718b615c82fa3648Till MossakowskiCopyright : (c) Klaus L�ttich and Uni Bremen 2002-2004
97018cf5fa25b494adffd7e9b4e87320dae6bf47Christian MaederLicence : similar to LGPL, see HetCATS/LICENCE.txt or LIZENZ.txt
3f69b6948966979163bdfe8331c38833d5d90ecdChristian MaederMaintainer : hets@tzi.de
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian MaederStability : provisional
351145cfe8c03b4d47133c96b209f2bd6cfbf504Christian MaederPortability : portable
e6d40133bc9f858308654afb1262b8b483ec5922Till Mossakowski This module exports functions, that can convert an sml-CATS ATerm
1549f3abf73c1122acff724f718b615c82fa3648Till Mossakowski into the Haskell abstract syntax tree. So it contains all the
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder necessary instances of ATermConvertible and a heuritic function
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder that calculates the new lists of Pos out of Region tuples.
f8b715ab2993083761c0aedb78f1819bcf67b6ccChristian Maeder the templates for the instances are automatically derived by
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder DrIFT. But there were made many hand written changes.
ad270004874ce1d0697fb30d7309f180553bb315Christian Maeder - p_flag from pos-TERM is not considered jet!
23a00c966f2aa8da525d7a7c51933c99964426c0Christian Maedermodule ATC.Sml_cats (from_sml_ATerm,read_sml_ATerm) where
575a55eadc8dcab8ee350324b417cbd9e52e69c0Christian Maederimport Data.List (isPrefixOf)
8e9c3881fb6e710b1e08bf5ac8ff9d393df2e74eChristian Maederimport List (mapAccumL)
575a55eadc8dcab8ee350324b417cbd9e52e69c0Christian Maederimport Common.Lib.Map hiding (map)
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian Maeder-- better recompilation checking without 'import Common.ATerm.Lib'
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder-- for debugging only
986d3f255182539098a97ac86da9eeee5b7a72e3Christian Maeder-- import Debug.Trace (trace)
8e80792f474d154ff11762fac081a422e34f1accChristian Maeder-- the following module provides the ability to parse the "unparsed-anno"
03136b84a0c70d877e227444f0875e209506b9e4Christian Maederimport Common.Lib.Parsec (parse,setPosition)
03136b84a0c70d877e227444f0875e209506b9e4Christian Maederimport qualified Common.Anno_Parser (annotations,parse_anno)
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder--from_sml_ATerm :: ATermTable -> LIB_DEFN
16e124196c6b204769042028c74f533509c9b5d3Christian Maederread_sml_ATerm :: FilePath -> IO LIB_DEFN
16e124196c6b204769042028c74f533509c9b5d3Christian Maeder--from_sml_ATerm = fromShATerm
9eb39c7a0e7a1ddad1eec1d23c6d4e3a99c54023Christian Maederread_sml_ATerm fn = readFile fn >>= return . from_sml_ATermString
9eb39c7a0e7a1ddad1eec1d23c6d4e3a99c54023Christian Maeder----- Convertible class for sml -----------------------------------------
9eb39c7a0e7a1ddad1eec1d23c6d4e3a99c54023Christian Maederclass ATermConvertibleSML t where
9eb39c7a0e7a1ddad1eec1d23c6d4e3a99c54023Christian Maeder -- conversion functions known from Joost Visser
351145cfe8c03b4d47133c96b209f2bd6cfbf504Christian Maeder to_sml_ATerm :: t -> ATerm
351145cfe8c03b4d47133c96b209f2bd6cfbf504Christian Maeder from_sml_ATerm :: ATerm -> t
3c8d067accf18572352351ec42ff905c7297a8a5Christian Maeder -- conversion functions to omit overlapping instances
81101b83a042f5a1bdeeef93b1b49aff05817e44Christian Maeder to_sml_ATermList :: [t] -> ATerm
81101b83a042f5a1bdeeef93b1b49aff05817e44Christian Maeder from_sml_ATermList :: ATerm -> [t]
351145cfe8c03b4d47133c96b209f2bd6cfbf504Christian Maeder -- default functions ignore the Annotation part
351145cfe8c03b4d47133c96b209f2bd6cfbf504Christian Maeder to_sml_ATermList ts = AList (map to_sml_ATerm ts) []
3c8d067accf18572352351ec42ff905c7297a8a5Christian Maeder from_sml_ATermList aterm =
81101b83a042f5a1bdeeef93b1b49aff05817e44Christian Maeder case aterm of
81101b83a042f5a1bdeeef93b1b49aff05817e44Christian Maeder AList aterms _ -> map from_sml_ATerm aterms
81101b83a042f5a1bdeeef93b1b49aff05817e44Christian Maeder _ -> from_sml_ATermError "[a]" aterm
3c8d067accf18572352351ec42ff905c7297a8a5Christian Maeder -- functions for conversion to an ATermTable
81101b83a042f5a1bdeeef93b1b49aff05817e44Christian Maeder to_sml_ShATerm :: ATermTable -> t -> (ATermTable,Int)
81101b83a042f5a1bdeeef93b1b49aff05817e44Christian Maeder to_sml_ShATermList :: ATermTable -> [t] -> (ATermTable,Int)
81101b83a042f5a1bdeeef93b1b49aff05817e44Christian Maeder from_sml_ShATerm :: ATermTable -> t
9eb39c7a0e7a1ddad1eec1d23c6d4e3a99c54023Christian Maeder from_sml_ShATermList :: ATermTable -> [t]
d0c66a832d7b556e20ea4af4852cdc27a5463d51Christian Maeder -- default functions ignore the Annotation part
d0c66a832d7b556e20ea4af4852cdc27a5463d51Christian Maeder to_sml_ShATermList at ts = addATerm (ShAList inds []) at'
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder where (at',inds) = mapAccumL to_sml_ShATerm at ts
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder from_sml_ShATermList at =
4b6aa93c12e4db86ccc7694a48a73e9cf7262d06Christian Maeder case aterm of
4b6aa93c12e4db86ccc7694a48a73e9cf7262d06Christian Maeder ShAList ats _ -> map conv ats
4b6aa93c12e4db86ccc7694a48a73e9cf7262d06Christian Maeder _ -> from_sml_ShATermError "[a]" aterm
4b6aa93c12e4db86ccc7694a48a73e9cf7262d06Christian Maeder where aterm = getATerm at
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder conv i = from_sml_ShATerm (getATermByIndex1 i at)
4b6aa93c12e4db86ccc7694a48a73e9cf7262d06Christian Maederto_sml_ATermString :: ATermConvertibleSML a => a -> String
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maederto_sml_ATermString t = (writeATerm . fst) (to_sml_ShATerm emptyATermTable t)
5e46b572ed576c0494768998b043d9d340594122Till Mossakowskito_sml_SharedATermString :: ATermConvertibleSML a => a -> String
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maederto_sml_SharedATermString t = (writeSharedATerm . fst) (to_sml_ShATerm emptyATermTable t)
fa167e362877db231378e17ba49c66fbb84862fcChristian Maederfrom_sml_ATermString :: ATermConvertibleSML a => String -> a
03136b84a0c70d877e227444f0875e209506b9e4Christian Maederfrom_sml_ATermString s = (\ a -> from_sml_ShATerm a) (readATerm s)
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maederfrom_sml_ATermError :: String -> ATerm -> a
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maederfrom_sml_ATermError t u = error ("Cannot convert ATerm to "++t++": "++(err u))
6a22b2854c3bc9cb4877cb7d29049d6559238639Christian Maeder where err u = case u of
e01299e9b22b96b31b720ca1e9f9f5f25af9b024Christian Maeder AAppl s _ _ -> "!AAppl "++s
7a47fbe6b987bd69a5056ce5d00fc8710f6c5e8aChristian Maeder AList _ _ -> "!AList"
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowskifrom_sml_ShATermError :: String -> ShATerm -> a
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowskifrom_sml_ShATermError t u = error ("Cannot convert Sml-ShATerm to "++t++": "++(err u))
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski where err u = case u of
4b6aa93c12e4db86ccc7694a48a73e9cf7262d06Christian Maeder ShAAppl s l _ -> "!ShAAppl "++s++"("++show (length l)++")"
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder ShAList _ _ -> "!ShAList"
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder _ -> "!ShAInt"
7a47fbe6b987bd69a5056ce5d00fc8710f6c5e8aChristian Maeder-- basic instances -----------------------------------------------
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maederinstance ATermConvertibleSML Bool where
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder to_sml_ATerm _ = error "*** to_sml_ATerm for \"Bool\" not implemented"
4601edb679f0ba530bbb085b25d82a411cd070aaChristian Maeder from_sml_ATerm _ = error "*** from_sml_ATerm for \"Bool\" not implemented"
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder to_sml_ShATerm _ _ = error "*** to_sml_ShATerm for \"Bool\" not implemented"
26d11a256b1433604a3dbc69913b520fff7586acChristian Maeder from_sml_ShATerm att = case at of
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder ShAAppl "true" [] _ -> True
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder ShAAppl "false" [] _ -> False
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder _ -> from_sml_ShATermError "Bool" at
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder where at = getATerm att
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder-- for Integer derive : ATermConvertibleSML hand written!
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maederinstance ATermConvertibleSML Integer where
aea143fff7a50aceb809845fbc42698b0b3f545aChristian Maeder to_sml_ATerm _ = error "*** to_sml_ATerm for \"Integer\" not implemented"
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder from_sml_ATerm _ = error "*** from_sml_ATerm for \"Integer\" not implemented"
aea143fff7a50aceb809845fbc42698b0b3f545aChristian Maeder to_sml_ShATerm _ _ = error "*** to_sml_ShATerm for \"Integer\" not implemented"
aea143fff7a50aceb809845fbc42698b0b3f545aChristian Maeder from_sml_ShATerm att = case at of
aea143fff7a50aceb809845fbc42698b0b3f545aChristian Maeder (ShAInt x _) -> x
6a22b2854c3bc9cb4877cb7d29049d6559238639Christian Maeder _ -> from_sml_ShATermError "Integer" at
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder where at = getATerm att
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maederinstance ATermConvertibleSML Int where
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder to_sml_ATerm _ = error "*** to_sml_ATerm for \"Int\" not implemented"
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder from_sml_ATerm _ = error "*** from_sml_ATerm for \"Int\" not implemented"
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maeder to_sml_ShATerm _ _ = error "*** to_sml_ShATerm for \"Int\" not implemented"
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder from_sml_ShATerm att = case mi y of
7a47fbe6b987bd69a5056ce5d00fc8710f6c5e8aChristian Maeder (Just i) -> i
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder Nothing -> error ("Integer to big for Int: "++(show y))
5e46b572ed576c0494768998b043d9d340594122Till Mossakowski y = from_sml_ShATerm att
74d9a385499bf903b24848dff450a153f525bda7Christian Maeder mi :: (Num a) => Integer -> Maybe a
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder mi x = if toInteger ((fromInteger::Integer->Int) x) == x
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder then Just (fromInteger x)
03136b84a0c70d877e227444f0875e209506b9e4Christian Maederinstance ATermConvertibleSML Char where
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder to_sml_ATerm _ = error "*** to_sml_ATerm for \"Char\" not implemented"
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder from_sml_ATerm _ = error "*** from_sml_ATerm for \"Char\" not implemented"
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder to_sml_ATermList _ = error "*** to_sml_ATerm for \"String\" not implemented"
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder from_sml_ATermList _ = error "*** from_sml_ATerm for \"String\" not implemented"
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder to_sml_ShATerm _ _ = error "*** to_sml_ShATerm for \"Char\" not implemented"
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maeder from_sml_ShATerm att = case at of
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maeder (ShAAppl s [] _) -> conv s
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maeder _ -> from_sml_ShATermError "Char" at
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maeder where at = getATerm att
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maeder to_sml_ShATermList _ _ = error "*** to_sml_ShATerm for \"String\" not implemented"
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maeder from_sml_ShATermList att = case at of
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maeder (ShAAppl s [] _) -> read s
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maeder _ -> from_sml_ShATermError "String" at
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski where at = getATerm att
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maederconv :: String -> Char
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maederconv ('\"':sr) = case reverse sr of
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maeder ('\"':so) -> conv' (reverse so)
ee152ae82dc19d6415119c0019ae1bfa991b1f02Christian Maeder conv' ('\\':x:[]) = case x of
ee152ae82dc19d6415119c0019ae1bfa991b1f02Christian Maeder _ -> error "very strange reach"
ee152ae82dc19d6415119c0019ae1bfa991b1f02Christian Maeder conv' (x:[]) = x
ee152ae82dc19d6415119c0019ae1bfa991b1f02Christian Maeder conv' _ = error "String not convertible to char"
ee152ae82dc19d6415119c0019ae1bfa991b1f02Christian Maeder _ -> error "No matching '\"' found"
ee152ae82dc19d6415119c0019ae1bfa991b1f02Christian Maederconv _ = error "String doesn't begin with '\"'"
ee152ae82dc19d6415119c0019ae1bfa991b1f02Christian Maederinstance (Ord a, ATermConvertibleSML a, ATermConvertibleSML b) => ATermConvertibleSML (Map a b) where
ee152ae82dc19d6415119c0019ae1bfa991b1f02Christian Maeder to_sml_ATerm fm = to_sml_ATerm (toList fm)
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maeder from_sml_ATerm at = fromList $ from_sml_ATerm at
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian Maeder to_sml_ShATerm att fm = to_sml_ShATerm att $ toList fm
575a55eadc8dcab8ee350324b417cbd9e52e69c0Christian Maeder from_sml_ShATerm att = fromList $ from_sml_ShATerm att
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian Maederinstance ATermConvertibleSML a => ATermConvertibleSML [a] where
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski to_sml_ATerm l = to_sml_ATermList l
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maeder from_sml_ATerm at = from_sml_ATermList at
ab642ff136ce716af9e609b667e3f06d766c4ad7Christian Maeder to_sml_ShATerm att l = to_sml_ShATermList att l
99476ac2689c74251219db4782e57fe713a24a52Christian Maeder from_sml_ShATerm att = from_sml_ShATermList att
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maederinstance (ATermConvertibleSML a,ATermConvertibleSML b) => ATermConvertibleSML (a,b) where
99476ac2689c74251219db4782e57fe713a24a52Christian Maeder to_sml_ATerm (a,b) = AAppl "" [to_sml_ATerm a,to_sml_ATerm b] []
99476ac2689c74251219db4782e57fe713a24a52Christian Maeder from_sml_ATerm at = case at of
99476ac2689c74251219db4782e57fe713a24a52Christian Maeder (AAppl "" [a,b] _) -> (from_sml_ATerm a,from_sml_ATerm b)
99476ac2689c74251219db4782e57fe713a24a52Christian Maeder _ -> from_sml_ATermError "(a,b)" at
99476ac2689c74251219db4782e57fe713a24a52Christian Maeder to_sml_ShATerm att (x,y) = addATerm (ShAAppl "" [x',y'] []) att'
99476ac2689c74251219db4782e57fe713a24a52Christian Maeder where (att' ,y') = to_sml_ShATerm att'' y
99476ac2689c74251219db4782e57fe713a24a52Christian Maeder (att'',x') = to_sml_ShATerm att x
ee152ae82dc19d6415119c0019ae1bfa991b1f02Christian Maeder from_sml_ShATerm att = case at of
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maeder (ShAAppl "" [x,y] _) -> (x',y')
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maeder where x' = from_sml_ShATerm (getATermByIndex1 x att)
88124ca824f94153b0a2a24ea1e4b089fff7011fChristian Maeder y' = from_sml_ShATerm (getATermByIndex1 y att)
88124ca824f94153b0a2a24ea1e4b089fff7011fChristian Maeder _ -> from_sml_ShATermError "(a,b)" at
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maeder where at = getATerm att
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maederinstance (ATermConvertibleSML a, ATermConvertibleSML b, ATermConvertibleSML c) => ATermConvertibleSML (a,b,c) where
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maeder to_sml_ATerm (a,b,c) = AAppl "" [to_sml_ATerm a, to_sml_ATerm b, to_sml_ATerm c] []
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maeder from_sml_ATerm at = case at of
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maeder (AAppl "" [a,b,c] _) -> (from_sml_ATerm a, from_sml_ATerm b, from_sml_ATerm c)
88124ca824f94153b0a2a24ea1e4b089fff7011fChristian Maeder _ -> from_sml_ATermError "(a,b,c)" at
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maeder to_sml_ShATerm att (a,b,c) = addATerm (ShAAppl "" [a',b',c'] []) att1
88124ca824f94153b0a2a24ea1e4b089fff7011fChristian Maeder where (att1,c') = to_sml_ShATerm att'' c
88124ca824f94153b0a2a24ea1e4b089fff7011fChristian Maeder (att'',b') = to_sml_ShATerm att' b
88124ca824f94153b0a2a24ea1e4b089fff7011fChristian Maeder (att',a') = to_sml_ShATerm att a
88124ca824f94153b0a2a24ea1e4b089fff7011fChristian Maeder from_sml_ShATerm att = case at of
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maeder (ShAAppl "" [a,b,c] _) -> (a',b',c')
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maeder where a' = from_sml_ShATerm (getATermByIndex1 a att)
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maeder b' = from_sml_ShATerm (getATermByIndex1 b att)
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder c' = from_sml_ShATerm (getATermByIndex1 c att)
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder _ -> from_sml_ShATermError "(a,b,c)" at
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maeder where at = getATerm att
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian Maederinstance (ATermConvertibleSML a, ATermConvertibleSML b, ATermConvertibleSML c, ATermConvertibleSML d) => ATermConvertibleSML (a,b,c,d) where
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian Maeder to_sml_ATerm (a,b,c,d) = AAppl "" [to_sml_ATerm a, to_sml_ATerm b, to_sml_ATerm c,to_sml_ATerm d] []
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder from_sml_ATerm at = case at of
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski (AAppl "" [a,b,c,d] _) -> (from_sml_ATerm a, from_sml_ATerm b, from_sml_ATerm c, from_sml_ATerm d)
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder _ -> from_sml_ATermError "(a,b,c)" at
ee152ae82dc19d6415119c0019ae1bfa991b1f02Christian Maeder to_sml_ShATerm att (a,b,c,d) = addATerm (ShAAppl "" [a',b',c',d'] []) att2
ee152ae82dc19d6415119c0019ae1bfa991b1f02Christian Maeder where (att2,d') = to_sml_ShATerm att1 d
ee152ae82dc19d6415119c0019ae1bfa991b1f02Christian Maeder (att1,c') = to_sml_ShATerm att'' c
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder (att'',b') = to_sml_ShATerm att' b
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski (att',a') = to_sml_ShATerm att a
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski from_sml_ShATerm att = case at of
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder (ShAAppl "" [a,b,c,d] _) -> (a',b',c',d')
aea143fff7a50aceb809845fbc42698b0b3f545aChristian Maeder where a' = from_sml_ShATerm (getATermByIndex1 a att)
575a55eadc8dcab8ee350324b417cbd9e52e69c0Christian Maeder b' = from_sml_ShATerm (getATermByIndex1 b att)
575a55eadc8dcab8ee350324b417cbd9e52e69c0Christian Maeder c' = from_sml_ShATerm (getATermByIndex1 c att)
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder d' = from_sml_ShATerm (getATermByIndex1 d att)
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder _ -> from_sml_ShATermError "(a,b,c)" at
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder where at = getATerm att
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder----- instances of Id.hs ------------------------------------------------
03136b84a0c70d877e227444f0875e209506b9e4Christian Maederinstance ATermConvertibleSML Token where
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder to_sml_ATerm _ = error "*** to_sml_ATerm for \"Token\" not implemented"
e01299e9b22b96b31b720ca1e9f9f5f25af9b024Christian Maeder from_sml_ATerm _ = error "*** from_sml_ATerm for \"Token\" not implemented"
99476ac2689c74251219db4782e57fe713a24a52Christian Maeder to_sml_ShATerm _ _ = error "*** to_sml_ShATerm for \"Token\" not implemented"
99476ac2689c74251219db4782e57fe713a24a52Christian Maeder from_sml_ShATerm att =
99476ac2689c74251219db4782e57fe713a24a52Christian Maeder case aterm of
99476ac2689c74251219db4782e57fe713a24a52Christian Maeder (ShAAppl "token" [ aa ] _) ->
e01299e9b22b96b31b720ca1e9f9f5f25af9b024Christian Maeder aa' = from_sml_ShATerm (getATermByIndex1 aa att)
e01299e9b22b96b31b720ca1e9f9f5f25af9b024Christian Maeder ab' = nullPos
99476ac2689c74251219db4782e57fe713a24a52Christian Maeder in (Token aa' ab')
e01299e9b22b96b31b720ca1e9f9f5f25af9b024Christian Maeder (ShAAppl "place" [] _) ->
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder ab' = nullPos
e01299e9b22b96b31b720ca1e9f9f5f25af9b024Christian Maeder in (Token aa' ab')
e01299e9b22b96b31b720ca1e9f9f5f25af9b024Christian Maeder _ -> from_sml_ShATermError "Token" aterm
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski aterm = getATerm att
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maederinstance ATermConvertibleSML Id where
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder to_sml_ATerm _ = error "*** to_sml_ATerm for \"Id\" not implemented"
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder from_sml_ATerm _ = error "*** from_sml_ATerm for \"Id\" not implemented"
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder to_sml_ShATerm _ _ = error "*** to_sml_ShATerm for \"Id\" not implemented"
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder from_sml_ShATerm att =
7a47fbe6b987bd69a5056ce5d00fc8710f6c5e8aChristian Maeder case aterm of
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder (ShAAppl "compound-id" [ aa,ab ] _) -> -- TOKEN_OR_MIXFIX,[ID]
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder aa' = from_sml_ATermTokenTup (getATermByIndex1 aa att)
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder ab' = from_sml_ShATerm (getATermByIndex1 ab att)
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder in (Id aa' ab' ac')
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder (ShAAppl "simple-id" [ aa ] _) ->
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder aa' = from_sml_ATermTokenTup (getATermByIndex1 aa att)
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder in (Id aa' ab' ac')
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder _ -> from_sml_ShATermError "Id" aterm
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder aterm = getATerm att
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maeder-------------------------------------------------------------------------
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maederfrom_sml_ATermTokenTup :: ATermTable -> [Token]
e82587ca2892d246aa4405c2f5b9f30f287f9ebfChristian Maederfrom_sml_ATermTokenTup att =
2561b4bfc45d280ee2be8a7870314670e4e682e4Christian Maeder case aterm of
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder (ShAAppl "" [tops,_,_] _) ->
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder from_sml_ShATerm (getATermByIndex1 tops att)
fa167e362877db231378e17ba49c66fbb84862fcChristian Maeder _ -> from_sml_ShATermError "Token" aterm
fa167e362877db231378e17ba49c66fbb84862fcChristian Maeder where aterm = getATerm att
fa167e362877db231378e17ba49c66fbb84862fcChristian Maeder----- instances of AS_Annotation.hs -------------------------------------
aea143fff7a50aceb809845fbc42698b0b3f545aChristian Maederinstance ATermConvertibleSML Annotation where
aea143fff7a50aceb809845fbc42698b0b3f545aChristian Maeder to_sml_ATerm _ = error "*** to_sml_ATerm for \"Annotation\" not implemented"
aea143fff7a50aceb809845fbc42698b0b3f545aChristian Maeder from_sml_ATerm _ = error "*** from_sml_ATerm for \"Annotation\" not implemented"
aea143fff7a50aceb809845fbc42698b0b3f545aChristian Maeder to_sml_ShATerm _ _ = error "*** to_sml_ShATerm for \"Annotation\" not implemented"
aea143fff7a50aceb809845fbc42698b0b3f545aChristian Maeder from_sml_ShATerm att =
caf021dd48c90ff6b26117f13e1d8c0ef1ca618aChristian Maeder case aterm of
e01299e9b22b96b31b720ca1e9f9f5f25af9b024Christian Maeder (ShAAppl "comment-line" [ aa ] _) ->
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder aa' = chomp $ from_sml_ShATerm (getATermByIndex1 aa att)
86b1d0c80abdd4ca36491cf7025b718a5fea5080Christian Maeder in (Unparsed_anno Comment_start (Line_anno aa') ab')
fbf1cdad9a9775bd7332e85f01b6a307d7dbb1cfChristian Maeder (ShAAppl "comment" [ aa ] _) ->
a23e572c8f957cc051a1b0831abd6fe9380d45c7Christian Maeder aa' = lines (from_sml_ShATerm (getATermByIndex1 aa att))
68138d26bcddf5e89c30206aa83ab5ec006d170dChristian Maeder in (Unparsed_anno Comment_start (Group_anno aa') ab')
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder (ShAAppl "unparsed-anno" [ aa ] _) ->
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder parse_anno pos_l
68138d26bcddf5e89c30206aa83ab5ec006d170dChristian Maeder (from_sml_ShATerm (getATermByIndex1 aa att))
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder (ShAAppl "annote-line" [ aa,ab ] _) ->
e01299e9b22b96b31b720ca1e9f9f5f25af9b024Christian Maeder aa' = from_sml_ShATerm (getATermByIndex1 aa att)
3c8d067accf18572352351ec42ff905c7297a8a5Christian Maeder ab' = from_sml_ShATerm (getATermByIndex1 ab att)
4fc727afa544a757d1959ce77c02208f8bf330dcChristian Maeder in (Unparsed_anno (Annote_word aa') (Line_anno ab') ac')
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder (ShAAppl "annote-group" [ aa,ab ] _) ->
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder aa' = from_sml_ShATerm (getATermByIndex1 aa att)
68138d26bcddf5e89c30206aa83ab5ec006d170dChristian Maeder ab' = from_sml_ShATerm (getATermByIndex1 ab att)
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder in (Unparsed_anno (Annote_word aa') (Group_anno ab') ac')
6a22b2854c3bc9cb4877cb7d29049d6559238639Christian Maeder (ShAAppl "display-anno" [ aa,ab ] _) ->
86b1d0c80abdd4ca36491cf7025b718a5fea5080Christian Maeder aa' = from_sml_ShATerm (getATermByIndex1 aa att)
4fc727afa544a757d1959ce77c02208f8bf330dcChristian Maeder ab' = parse_disp_anno aa' pos_l
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder (chomp $ from_sml_ShATerm (getATermByIndex1 ab att))
68138d26bcddf5e89c30206aa83ab5ec006d170dChristian Maeder (ShAAppl "string-anno" [ aa,ab ] _) ->
68138d26bcddf5e89c30206aa83ab5ec006d170dChristian Maeder aa' = from_sml_ShATerm (getATermByIndex1 aa att)
86b1d0c80abdd4ca36491cf7025b718a5fea5080Christian Maeder ab' = from_sml_ShATerm (getATermByIndex1 ab att)
d0c66a832d7b556e20ea4af4852cdc27a5463d51Christian Maeder in (String_anno aa' ab' ac')
3c8d067accf18572352351ec42ff905c7297a8a5Christian Maeder (ShAAppl "list-anno" [ aa,ab,ac ] _) ->
22eea35d0effc6582b2951a28b5240fa7a82f3dfChristian Maeder aa' = from_sml_ShATerm (getATermByIndex1 aa att)
86b1d0c80abdd4ca36491cf7025b718a5fea5080Christian Maeder ab' = from_sml_ShATerm (getATermByIndex1 ab att)
5e46b572ed576c0494768998b043d9d340594122Till Mossakowski ac' = from_sml_ShATerm (getATermByIndex1 ac att)
5e46b572ed576c0494768998b043d9d340594122Till Mossakowski in (List_anno aa' ab' ac' ad')
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder (ShAAppl "number-anno" [ aa ] _) ->
5e46b572ed576c0494768998b043d9d340594122Till Mossakowski aa' = from_sml_ShATerm (getATermByIndex1 aa att)
5e46b572ed576c0494768998b043d9d340594122Till Mossakowski in (Number_anno aa' ab')
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder (ShAAppl "floating-anno" [ aa,ab ] _) ->
5e46b572ed576c0494768998b043d9d340594122Till Mossakowski aa' = from_sml_ShATerm (getATermByIndex1 aa att)
5e46b572ed576c0494768998b043d9d340594122Till Mossakowski ab' = from_sml_ShATerm (getATermByIndex1 ab att)
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder in (Float_anno aa' ab' ac')
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maeder (ShAAppl "prec-anno" [ aa,ab,ac ] _) ->
22eea35d0effc6582b2951a28b5240fa7a82f3dfChristian Maeder aa' = from_sml_ShATerm (getATermByIndex1 aa att)
22eea35d0effc6582b2951a28b5240fa7a82f3dfChristian Maeder ab' = from_sml_ShATerm (getATermByIndex1 ab att)
be98c516a8ff1d496fcdeb9b8be8c5f4b908ab95Christian Maeder ac' = from_sml_ShATerm (getATermByIndex1 ac att)
be98c516a8ff1d496fcdeb9b8be8c5f4b908ab95Christian Maeder in (Prec_anno (if aa' then Lower else BothDirections)
be98c516a8ff1d496fcdeb9b8be8c5f4b908ab95Christian Maeder (ShAAppl "lassoc-anno" [ aa ] _) ->
be98c516a8ff1d496fcdeb9b8be8c5f4b908ab95Christian Maeder aa' = from_sml_ShATerm (getATermByIndex1 aa att)
be98c516a8ff1d496fcdeb9b8be8c5f4b908ab95Christian Maeder in (Assoc_anno ALeft aa' ab')
be98c516a8ff1d496fcdeb9b8be8c5f4b908ab95Christian Maeder (ShAAppl "rassoc-anno" [ aa ] _) ->
be98c516a8ff1d496fcdeb9b8be8c5f4b908ab95Christian Maeder aa' = from_sml_ShATerm (getATermByIndex1 aa att)
be98c516a8ff1d496fcdeb9b8be8c5f4b908ab95Christian Maeder in (Assoc_anno ARight aa' ab')
be98c516a8ff1d496fcdeb9b8be8c5f4b908ab95Christian Maeder (ShAAppl "label-anno" [ aa ] _) ->
22eea35d0effc6582b2951a28b5240fa7a82f3dfChristian Maeder lines (showId (from_sml_ShATerm (getATermByIndex1 aa att)) "")
22eea35d0effc6582b2951a28b5240fa7a82f3dfChristian Maeder in (Label aa' ab')
22eea35d0effc6582b2951a28b5240fa7a82f3dfChristian Maeder (ShAAppl "implies" [] _) ->
22eea35d0effc6582b2951a28b5240fa7a82f3dfChristian Maeder in (Semantic_anno SA_implies aa')
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder (ShAAppl "definitional" [] _) ->
d058429727dd696a0327cdc28cadd268c34c36baChristian Maeder in (Semantic_anno SA_def aa')
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maeder (ShAAppl "conservative" [] _) ->
d058429727dd696a0327cdc28cadd268c34c36baChristian Maeder in (Semantic_anno SA_cons aa')
ebc51e8081f6f1fe2f3d39ceff81d8dd0169c0b0Christian Maeder (ShAAppl "mono" [] _) ->
d058429727dd696a0327cdc28cadd268c34c36baChristian Maeder Semantic_anno SA_mono pos_l
d058429727dd696a0327cdc28cadd268c34c36baChristian Maeder _ -> from_sml_ShATermError "Annotation" aterm
d058429727dd696a0327cdc28cadd268c34c36baChristian Maeder aterm = getATerm att'
329d1810c6d5a5a0827e1d07503d94431578d176Christian Maeder (pos_l,att') =
5e46b572ed576c0494768998b043d9d340594122Till Mossakowski case getATerm att of
329d1810c6d5a5a0827e1d07503d94431578d176Christian Maeder (ShAAppl "pos-ANNO" [reg_i,item_i] _) ->
329d1810c6d5a5a0827e1d07503d94431578d176Christian Maeder (posFromRegion reg_i att,getATermByIndex1 item_i att)
d058429727dd696a0327cdc28cadd268c34c36baChristian Maeder _ -> ([],att)
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder--- Well the following instance has to tie together things, that don't
5a9a06d23910b9521e1d1cd39865ac7912ccee4bChristian Maeder--- belong to each other. Because I can't declare instances for
5a9a06d23910b9521e1d1cd39865ac7912ccee4bChristian Maeder--- certain "Annoted types"
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maederinstance (ATermConvertibleSML a) => ATermConvertibleSML (Annoted a) where
d058429727dd696a0327cdc28cadd268c34c36baChristian Maeder to_sml_ATerm _ = error "*** to_sml_ATerm for \"(Annoted a)\" not implemented"
329d1810c6d5a5a0827e1d07503d94431578d176Christian Maeder from_sml_ATerm _ = error "*** from_sml_ATerm for \"(Annoted a)\" not implemented"
5e46b572ed576c0494768998b043d9d340594122Till Mossakowski to_sml_ShATerm _ _ = error "*** to_sml_ShATerm for \"(Annoted a)\" not implemented"
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder from_sml_ShATerm att =
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder case aterm of
86b1d0c80abdd4ca36491cf7025b718a5fea5080Christian Maeder (ShAAppl con as _) ->
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maeder -- Basic Items (including sig_items)
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maeder "pos-BASIC-ITEMS" ->
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maeder let (bi,las) = from_sml_ATermAnnotedBasic_Items att
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maeder in Annoted bi [] las []
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maeder -- L_.* constuctors from SML
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder "" -> Annoted (from_sml_ShATerm (getATermByIndex1
86b1d0c80abdd4ca36491cf7025b718a5fea5080Christian Maeder (toAnnoList (last as) att)
0e2ae85e2453466d03c1fc5884a3d693235bb9d9Christian Maeder _ -> -- "No appropiate constructor for Annoted found"
a7be28e157e9ceeec73a8fd0e642c36ea29d4218Christian Maeder Annoted (from_sml_ShATerm att)
32562a567baac248a00782d2727716c13117dc4aChristian Maeder _ -> from_sml_ShATermError "Annoted a" aterm
32562a567baac248a00782d2727716c13117dc4aChristian Maeder aterm = getATerm att
0e2ae85e2453466d03c1fc5884a3d693235bb9d9Christian Maeder---- functions to convert annoted stuff ---------------------------------
4601edb679f0ba530bbb085b25d82a411cd070aaChristian Maeder-- all these functions are called by instance ATermConvertibleSML Annoted a
32562a567baac248a00782d2727716c13117dc4aChristian Maederfrom_sml_ATermAnnotedBasic_Items :: forall a . ATermConvertibleSML a =>
32562a567baac248a00782d2727716c13117dc4aChristian Maeder ATermTable -> (a,[Annotation])
32562a567baac248a00782d2727716c13117dc4aChristian Maederfrom_sml_ATermAnnotedBasic_Items att =
32562a567baac248a00782d2727716c13117dc4aChristian Maeder if isSig_items then
32562a567baac248a00782d2727716c13117dc4aChristian Maeder ((from_sml_ShATerm att),[])
746440cc1b984a852f5864235b8fa3930963a081Christian Maeder else ((from_sml_ShATerm att),annoList)
32562a567baac248a00782d2727716c13117dc4aChristian Maeder where isSig_items =
7a47fbe6b987bd69a5056ce5d00fc8710f6c5e8aChristian Maeder case aterm of
7a47fbe6b987bd69a5056ce5d00fc8710f6c5e8aChristian Maeder (ShAAppl _ as _)-> -- pos-BASIC-ITEMS
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder case getATerm $ getATermByIndex1 (last as) att of
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder (ShAAppl "sig-items" _ _) -> True
e68f45f355ed9d4026ee9baff5aa75aa7c911cc2Christian Maeder _ -> from_sml_ShATermError "{SIG,BASIC}_items" aterm
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder aterm = getATerm att
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder annoList = case getATerm att of
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder (ShAAppl _ as _) -> getAnnoList (last as) att
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder _ -> error "Wrong ATerm structure: BASIC_ITEMS"
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder{- att' = let (ShAAppl _ as _) = getATerm att -- pos-BASIC-ITEMS
fa167e362877db231378e17ba49c66fbb84862fcChristian Maeder (ShAAppl _ as' _) = getATerm $ -- sig-items
4aa35aadcb28f8a962096efc70d3bdb58ab7d9faChristian Maeder getATermByIndex1 (head as) att
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder in getATermByIndex1 (head as') att -}
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder{-from_sml_ATermAnnotedSig_Items :: ATermTable -> [SIG_ITEMS]
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maederfrom_sml_ATermAnnotedSig_Items att =
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder-- Sig Items have an anno list which now is attached to
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder-- the first item
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder Just "s-items" ->
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder let aterm' = getATerm (getATermByIndex1 (head as) att)
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder as' = case aterm' of ShAAppl _ as _ -> as
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder in Annoted (from_sml_ShATerm att)
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder (getAnnoList (last as) att)
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder-- getAnnoList and toAnnoList are only working with an AIndex as first
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder-- argument is given. If getAnnoList is called every ShAAppl that starts _
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder-- with "pos-" is crossed without consideration. toAnnoList just calls
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder-- the [Annotation] conversion directly.
575a55eadc8dcab8ee350324b417cbd9e52e69c0Christian MaedergetAnnoList :: Int -> ATermTable -> [Annotation]
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaedergetAnnoList ai att = case at of
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder ShAAppl c as _ | isPrefixOf "pos-" c ->
6a22b2854c3bc9cb4877cb7d29049d6559238639Christian Maeder getAnnoList (last as) att
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder ShAAppl _ as _ -> toAnnoList (last as) att
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder _ -> error "wrong storage or missed 'pos-' contructor"
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder where at = getATerm (getATermByIndex1 ai att)
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaedertoAnnoList :: Int -> ATermTable -> [Annotation]
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian MaedertoAnnoList ai att = from_sml_ShATerm $ getATermByIndex1 ai att
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder-------------------------------------------------------------------------
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maederparse_anno :: [Pos] -> String -> Annotation
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maederparse_anno pos_l inp =
d79a4d0d842c212f82f9507fff178ffe4ba2e214Christian Maeder case (parse (set_pos Common.Anno_Parser.annotations) "" inp) of
32562a567baac248a00782d2727716c13117dc4aChristian Maeder Left err -> error ("internal parse error at " ++ (show err))
32562a567baac248a00782d2727716c13117dc4aChristian Maeder Right [x] -> x
32562a567baac248a00782d2727716c13117dc4aChristian Maeder Right _ -> error ("something strange happend to \"" ++
3c8d067accf18572352351ec42ff905c7297a8a5Christian Maeder inp ++ "\" during ATerm Conversion")
32562a567baac248a00782d2727716c13117dc4aChristian Maeder where set_pos p = do setPosition sp
3c8d067accf18572352351ec42ff905c7297a8a5Christian Maeder sp = pos -- newPos "ATermConversion from SML" (fst pos) (snd pos)
32562a567baac248a00782d2727716c13117dc4aChristian Maeder pos = head pos_l
3c8d067accf18572352351ec42ff905c7297a8a5Christian Maederparse_disp_anno :: Id -> [Pos] -> String -> Annotation
3c8d067accf18572352351ec42ff905c7297a8a5Christian Maederparse_disp_anno i pos_l inp =
3c8d067accf18572352351ec42ff905c7297a8a5Christian Maeder case (Common.Anno_Parser.parse_anno (Unparsed_anno (Annote_word "display")
3c8d067accf18572352351ec42ff905c7297a8a5Christian Maeder (Group_anno [inp']) pos_l) sp) of
3c8d067accf18572352351ec42ff905c7297a8a5Christian Maeder Left err -> error ("internal parse error at " ++ (show err))
3c8d067accf18572352351ec42ff905c7297a8a5Christian Maeder --Right [] -> error $ "No displayanno: " ++ inp'
3c8d067accf18572352351ec42ff905c7297a8a5Christian Maeder Right x -> x -- trace ("parsed display anno:" ++ show x) x
3c8d067accf18572352351ec42ff905c7297a8a5Christian Maeder --Right xs -> error $ "More than one displayanno" ++ show xs
3b70d8ee5c2927f843d5d907e6ef724f867f1b40Till Mossakowski where sp = pos -- newPos "ATermConversion from SML" (fst pos) (snd pos)
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder pos = head pos_l
2766ec926fcf3faf72248b10c3305b715b8c3249Christian Maeder inp' = (showId i "") ++ (' ':s_inp)
2766ec926fcf3faf72248b10c3305b715b8c3249Christian Maeder s_inp = case reverse inp of
3b70d8ee5c2927f843d5d907e6ef724f867f1b40Till Mossakowski rin | "%)" `isPrefixOf` rin -> reverse $ drop 2 rin
2766ec926fcf3faf72248b10c3305b715b8c3249Christian Maeder | otherwise -> inp
2766ec926fcf3faf72248b10c3305b715b8c3249Christian Maeder----- instances of AS_Basic_CASL.hs -------------------------------------
2766ec926fcf3faf72248b10c3305b715b8c3249Christian Maederinstance ATermConvertibleSML BASIC_SPEC where
ca732bc259f74cb4f3f725daab7fe80fc7e1d9a0Till Mossakowski to_sml_ATerm _ = error "*** to_sml_ATerm for \"BASIC_SPEC\" not implemented"
2766ec926fcf3faf72248b10c3305b715b8c3249Christian Maeder from_sml_ATerm _ = error "*** from_sml_ATerm for \"BASIC_SPEC\" not implemented"
2766ec926fcf3faf72248b10c3305b715b8c3249Christian Maeder to_sml_ShATerm _ _ = error "*** to_sml_ShATerm for \"BASIC_SPEC\" not implemented"
2766ec926fcf3faf72248b10c3305b715b8c3249Christian Maeder from_sml_ShATerm att =
2766ec926fcf3faf72248b10c3305b715b8c3249Christian Maeder case aterm of
2766ec926fcf3faf72248b10c3305b715b8c3249Christian Maeder (ShAAppl "basic-spec" [ aa ] _) ->
2766ec926fcf3faf72248b10c3305b715b8c3249Christian Maeder aa' = from_sml_ShATerm (getATermByIndex1 aa att)
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang _ -> from_sml_ShATermError "BASIC_SPEC" aterm
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang aterm = getATerm att'
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski case getATerm att of
5824312cc0cfccce61f195fbe92307a21a467049Christian Maeder (ShAAppl "pos-BASIC-SPEC" [_,item_i] _) ->
2561b4bfc45d280ee2be8a7870314670e4e682e4Christian Maeder getATermByIndex1 item_i att
2b2f3b72e82e28b34db9c69af2d1ec38f228272eChristian Maederinstance ATermConvertibleSML BASIC_ITEMS where
9ecf13b5fd914bc7272f1fc17348d7f4a8c77061Christian Maeder to_sml_ATerm _ = error "*** to_sml_ATerm for \"BASIC_ITEMS\" not implemented"
5824312cc0cfccce61f195fbe92307a21a467049Christian Maeder from_sml_ATerm _ = error "*** from_sml_ATerm for \"BASIC_ITEMS\" not implemented"
2b2f3b72e82e28b34db9c69af2d1ec38f228272eChristian Maeder to_sml_ShATerm _ _ = error "*** to_sml_ShATerm for \"BASIC_ITEMS\" not implemented"
d0c66a832d7b556e20ea4af4852cdc27a5463d51Christian Maeder from_sml_ShATerm att =
d0c66a832d7b556e20ea4af4852cdc27a5463d51Christian Maeder case aterm of
d0c66a832d7b556e20ea4af4852cdc27a5463d51Christian Maeder (ShAAppl "sig-items" [ aa ] _) ->
2b2f3b72e82e28b34db9c69af2d1ec38f228272eChristian Maeder aa' = from_sml_ShATerm (getATermByIndex1 aa att)
40d15f6c5f4d15866e085c588f8b5130dfd6cf63Christian Maeder in (Sig_items aa')
40d15f6c5f4d15866e085c588f8b5130dfd6cf63Christian Maeder (ShAAppl "free-datatype" [ aa,_ ] _) ->
40d15f6c5f4d15866e085c588f8b5130dfd6cf63Christian Maeder aa' = from_sml_ShATerm (getATermByIndex1 aa att)
40d15f6c5f4d15866e085c588f8b5130dfd6cf63Christian Maeder in (Free_datatype aa' ab')
d0c66a832d7b556e20ea4af4852cdc27a5463d51Christian Maeder (ShAAppl "sort-gen" [ aa,_ ] _) ->
2b2f3b72e82e28b34db9c69af2d1ec38f228272eChristian Maeder aa' = from_sml_ShATerm (getATermByIndex1 aa att)
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang in (Sort_gen aa' ab')
5824312cc0cfccce61f195fbe92307a21a467049Christian Maeder (ShAAppl "var-items" [ aa,_ ] _) ->
5824312cc0cfccce61f195fbe92307a21a467049Christian Maeder aa' = from_sml_ShATerm (getATermByIndex1 aa att)
-- (CASL.grm:((WORDS,None)))
----- instances of AS_Structured.hs -------------------------------------
in group (Syntax.AS_Structured.Basic_spec aa'') group_flag
----- instances of AS_Architecture.hs -----------------------------------
----- instances of AS_LIbrary.hs ----------------------------------------
in Syntax.AS_Library.Spec_defn aa' ab' ac'' ad'
in (Syntax.AS_Library.View_defn aa' ab' ac' ad'' ae')
in (Syntax.AS_Library.Arch_spec_defn aa' ab' ac')
in (Syntax.AS_Library.Unit_spec_defn aa' ab' ac')
in (Syntax.AS_Library.Download_items aa' ab' ac')
where r :: ((Int,Int),(Int,Int)) -- Id.hs Region