ATC_sml_cats.hs revision b3e31d2c629f0f861483c1dcd5d81d2ce1434833
d3f2015ae170a15e5b57d4880ded53073d725ac0Till Mossakowski-- needs: -ifgl:haterm-1.0/src -package util -package data -fglasgow-exts -fallow-overlapping-instances
d3f2015ae170a15e5b57d4880ded53073d725ac0Till Mossakowski Author: Klaus L�ttich
89118fd658073a87eddf4ead4bb63c6adb30550dTill Mossakowski This module exports functions, that can convert an sml-CATS ATerm
89118fd658073a87eddf4ead4bb63c6adb30550dTill Mossakowski into the Haskell abstract syntax tree. So it contains all the
89118fd658073a87eddf4ead4bb63c6adb30550dTill Mossakowski necessary instances of ATermConvertible and a heuritic function
89118fd658073a87eddf4ead4bb63c6adb30550dTill Mossakowski that calculates the new lists of Pos out of Region tuples.
89118fd658073a87eddf4ead4bb63c6adb30550dTill Mossakowski the templates for the instances are automatically derived by
89118fd658073a87eddf4ead4bb63c6adb30550dTill Mossakowski DrIFT. But there were made many hand written changes.
89118fd658073a87eddf4ead4bb63c6adb30550dTill Mossakowski - p_flag from pos-TERM is not considered jet!
89118fd658073a87eddf4ead4bb63c6adb30550dTill Mossakowskimodule ATC_sml_cats (from_sml_ATerm,read_sml_ATerm) where
89118fd658073a87eddf4ead4bb63c6adb30550dTill Mossakowski-- for debugging only
89118fd658073a87eddf4ead4bb63c6adb30550dTill Mossakowski-- import IOExts (trace)
89118fd658073a87eddf4ead4bb63c6adb30550dTill Mossakowskiimport List (isPrefixOf)
89118fd658073a87eddf4ead4bb63c6adb30550dTill Mossakowskiimport ATermLib
89118fd658073a87eddf4ead4bb63c6adb30550dTill Mossakowskiimport AS_Annotation
89118fd658073a87eddf4ead4bb63c6adb30550dTill Mossakowskiimport AS_Basic_CASL
89118fd658073a87eddf4ead4bb63c6adb30550dTill Mossakowskiimport Logic_CASL
89118fd658073a87eddf4ead4bb63c6adb30550dTill Mossakowskiimport Grothendieck
89118fd658073a87eddf4ead4bb63c6adb30550dTill Mossakowskiimport AS_Structured
89118fd658073a87eddf4ead4bb63c6adb30550dTill Mossakowskiimport AS_Architecture
89118fd658073a87eddf4ead4bb63c6adb30550dTill Mossakowskiimport AS_Library
89118fd658073a87eddf4ead4bb63c6adb30550dTill Mossakowski-- the following module provides the ability to parse the "unparsed-anno"
89118fd658073a87eddf4ead4bb63c6adb30550dTill Mossakowskiimport Parsec (parse,setPosition)
89118fd658073a87eddf4ead4bb63c6adb30550dTill Mossakowskiimport ParsecPos (newPos)
89118fd658073a87eddf4ead4bb63c6adb30550dTill Mossakowskiimport Anno_Parser (annotations)
89118fd658073a87eddf4ead4bb63c6adb30550dTill Mossakowskiimport CaslLanguage
89118fd658073a87eddf4ead4bb63c6adb30550dTill Mossakowskifrom_sml_ATerm :: ATermTable -> LIB_DEFN
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowskiread_sml_ATerm :: FilePath -> IO LIB_DEFN
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowskifrom_sml_ATerm = fromATerm
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowskiread_sml_ATerm fn = readFile fn >>= return . fromATermString
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski----- instances of Id.hs ------------------------------------------------
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowskiinstance ATermConvertible Token where
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski toATerm _ _ = error "*** toATerm for \"Token\" not implemented"
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski fromATerm att =
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski case aterm of
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski (AAppl "token" [ aa ]) ->
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski aa' = fromATerm (getATermByIndexSp1 aa att)
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski ab' = nullPos
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski in (Token aa' ab')
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski (AAppl "place" []) ->
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski ab' = nullPos
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski in (Token aa' ab')
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski _ -> fromATermError "Token" aterm
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski aterm = findATerm att (map (getATermSp att) pat_list)
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski pat_list = [(AAppl "token" [ ]),(AAppl "place" [ ]) ]
a22936ffa58b0b92b957098a1ebc75a22cc48f85Christoph Langeinstance ATermConvertible Id where
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski toATerm _ _ = error "*** toATerm for \"Id\" not implemented"
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski fromATerm att =
a22936ffa58b0b92b957098a1ebc75a22cc48f85Christoph Lange case aterm of
a22936ffa58b0b92b957098a1ebc75a22cc48f85Christoph Lange (AAppl "compound-id" [ aa,ab ]) -> -- TOKEN_OR_MIXFIX,[ID]
a22936ffa58b0b92b957098a1ebc75a22cc48f85Christoph Lange aa' = fromATermTokenTup (getATermByIndexSp1 aa att)
a22936ffa58b0b92b957098a1ebc75a22cc48f85Christoph Lange ab' = fromATerm (getATermByIndexSp1 ab att)
a22936ffa58b0b92b957098a1ebc75a22cc48f85Christoph Lange in (Id aa' ab' ac')
a22936ffa58b0b92b957098a1ebc75a22cc48f85Christoph Lange (AAppl "simple-id" [ aa ]) ->
a22936ffa58b0b92b957098a1ebc75a22cc48f85Christoph Lange aa' = fromATermTokenTup (getATermByIndexSp1 aa att)
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski in (Id aa' ab' ac')
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski _ -> fromATermError "Id" aterm
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski aterm = findATerm att (map (getATermSp att) pat_list)
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski pat_list = [(AAppl "compound-id" [ ]),(AAppl "simple-id" [ ]) ]
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski-------------------------------------------------------------------------
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till MossakowskifromATermTokenTup :: ATermTable -> [Token]
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till MossakowskifromATermTokenTup att =
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski case aterm of
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski (AAppl "tuple" [tops,_,_]) ->
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski fromATerm (getATermByIndexSp1 tops att)
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski _ -> fromATermError "Token" aterm
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski where aterm = getATerm att
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski----- instances of AS_Annotation.hs -------------------------------------
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowskiinstance ATermConvertible Annotation where
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski toATerm _ _ = error "*** toATerm for \"Annotation\" not implemented"
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski fromATerm att =
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski case aterm of
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski (AAppl "comment-line" [ aa ]) ->
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski aa' = fromATerm (getATermByIndexSp1 aa att)
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski in (Comment_line aa' ab')
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski (AAppl "comment" [ aa ]) ->
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski aa' = lines (fromATerm (getATermByIndexSp1 aa att))
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski in (Comment_group aa' ab')
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski (AAppl "unparsed-anno" [ aa ]) ->
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski parse_anno pos_l (fromATerm (getATermByIndexSp1 aa att))
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski (AAppl "annote-line" [ aa,ab ]) ->
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski aa' = fromATerm (getATermByIndexSp1 aa att)
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski ab' = fromATerm (getATermByIndexSp1 ab att)
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski in (Annote_line aa' ab' ac')
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski (AAppl "annote-group" [ aa,ab ]) ->
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski aa' = fromATerm (getATermByIndexSp1 aa att)
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski ab' = fromATerm (getATermByIndexSp1 ab att)
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski in (Annote_group aa' ab' ac')
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski (AAppl "display-anno" [ aa,ab ]) ->
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski aa' = fromATerm (getATermByIndexSp1 aa att)
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski ab' = parse_disp_anno aa' pos_l
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski (fromATerm (getATermByIndexSp1 ab att))
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski (AAppl "string-anno" [ aa,ab ]) ->
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski aa' = fromATerm (getATermByIndexSp1 aa att)
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski ab' = fromATerm (getATermByIndexSp1 ab att)
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski in (String_anno aa' ab' ac')
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski (AAppl "list-anno" [ aa,ab,ac ]) ->
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski aa' = fromATerm (getATermByIndexSp1 aa att)
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski ab' = fromATerm (getATermByIndexSp1 ab att)
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski ac' = fromATerm (getATermByIndexSp1 ac att)
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski in (List_anno aa' ab' ac' ad')
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski (AAppl "number-anno" [ aa ]) ->
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski aa' = fromATerm (getATermByIndexSp1 aa att)
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski in (Number_anno aa' ab')
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski (AAppl "floating-anno" [ aa,ab ]) ->
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski aa' = fromATerm (getATermByIndexSp1 aa att)
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski ab' = fromATerm (getATermByIndexSp1 ab att)
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski in (Float_anno aa' ab' ac')
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski (AAppl "prec-anno" [ aa,ab,ac ]) ->
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski aa' = fromATerm (getATermByIndexSp1 aa att)
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski ab' = fromATerm (getATermByIndexSp1 ab att)
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski ac' = fromATerm (getATermByIndexSp1 ac att)
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski in (Prec_anno aa' ab' ac' ad')
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski (AAppl "lassoc-anno" [ aa ]) ->
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski aa' = fromATerm (getATermByIndexSp1 aa att)
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski in (Lassoc_anno aa' ab')
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski (AAppl "rassoc-anno" [ aa ]) ->
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski aa' = fromATerm (getATermByIndexSp1 aa att)
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski in (Rassoc_anno aa' ab')
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski (AAppl "label-anno" [ aa ]) ->
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski lines (showId (fromATerm (getATermByIndexSp1 aa att)) "")
4b41220e2b76251e0bb0760c016e79994bb2c2bbChristian Maeder in (Label aa' ab')
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski (AAppl "implies" []) ->
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski in (Implies aa')
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski (AAppl "definitional" []) ->
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski in (Definitional aa')
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski (AAppl "conservative" []) ->
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski in (Conservative aa')
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski _ -> fromATermError "Annotation" aterm
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski aterm = findATerm att' (map (getATermSp att') pat_list)
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski pat_list = [(AAppl "comment-line" [ ])
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski ,(AAppl "comment" [ ])
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski ,(AAppl "unparsed-anno" [ ])
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski ,(AAppl "annote-line" [ ])
9c3b1fb1952bb78a1942fe612215f940fc8e5f31Till Mossakowski ,(AAppl "annote-group" [ ])
2c66eeb1cc9ad264525901f10c35c66638f91865Till Mossakowski ,(AAppl "display-anno" [ ])
2c66eeb1cc9ad264525901f10c35c66638f91865Till Mossakowski ,(AAppl "string-anno" [ ])
2c66eeb1cc9ad264525901f10c35c66638f91865Till Mossakowski ,(AAppl "list-anno" [ ])
2c66eeb1cc9ad264525901f10c35c66638f91865Till Mossakowski ,(AAppl "number-anno" [ ])
4b41220e2b76251e0bb0760c016e79994bb2c2bbChristian Maeder ,(AAppl "floating-anno" [ ])
30256573a343132354b122097b0ee1215dda1364Till Mossakowski ,(AAppl "prec-anno" [ ])
30256573a343132354b122097b0ee1215dda1364Till Mossakowski ,(AAppl "lassoc-anno" [ ])
30256573a343132354b122097b0ee1215dda1364Till Mossakowski ,(AAppl "rassoc-anno" [ ])
2c66eeb1cc9ad264525901f10c35c66638f91865Till Mossakowski ,(AAppl "label-anno" [ ])
2c66eeb1cc9ad264525901f10c35c66638f91865Till Mossakowski ,(AAppl "implies" [ ])
2c66eeb1cc9ad264525901f10c35c66638f91865Till Mossakowski ,(AAppl "definitional" [ ])
2c66eeb1cc9ad264525901f10c35c66638f91865Till Mossakowski ,(AAppl "conservative" [ ]) ]
2c66eeb1cc9ad264525901f10c35c66638f91865Till Mossakowski (pos_l,att') =
30256573a343132354b122097b0ee1215dda1364Till Mossakowski case getATerm att of
30256573a343132354b122097b0ee1215dda1364Till Mossakowski (AAppl "pos-ANNO" [reg_i,item_i]) ->
2c66eeb1cc9ad264525901f10c35c66638f91865Till Mossakowski (fromATerm_reg reg_i att,getATermByIndexSp1 item_i att)
2c66eeb1cc9ad264525901f10c35c66638f91865Till Mossakowski _ -> ([],att)
2c66eeb1cc9ad264525901f10c35c66638f91865Till Mossakowski--- Well the following instance has to tie together things, that don't
2c66eeb1cc9ad264525901f10c35c66638f91865Till Mossakowski--- belong to each other. Because I can't declare instances for
30256573a343132354b122097b0ee1215dda1364Till Mossakowski--- certain "Annoted types"
30256573a343132354b122097b0ee1215dda1364Till Mossakowskiinstance (ATermConvertible a) => ATermConvertible (Annoted a) where
30256573a343132354b122097b0ee1215dda1364Till Mossakowski toATerm _ _ = error "*** toATerm for \"(Annoted a)\" not implemented"
30256573a343132354b122097b0ee1215dda1364Till Mossakowski fromATerm att =
30256573a343132354b122097b0ee1215dda1364Till Mossakowski case aterm of
30256573a343132354b122097b0ee1215dda1364Till Mossakowski (AAppl con as) ->
30256573a343132354b122097b0ee1215dda1364Till Mossakowski -- Basic Items (including sig_items)
30256573a343132354b122097b0ee1215dda1364Till Mossakowski "pos-BASIC-ITEMS" ->
30256573a343132354b122097b0ee1215dda1364Till Mossakowski let (bi,las) = fromATermAnnotedBasic_Items att
30256573a343132354b122097b0ee1215dda1364Till Mossakowski in Annoted bi [] las []
30256573a343132354b122097b0ee1215dda1364Till Mossakowski -- L_.* constuctors from SML
30256573a343132354b122097b0ee1215dda1364Till Mossakowski "tuple" -> Annoted (fromATerm (getATermByIndexSp1
30256573a343132354b122097b0ee1215dda1364Till Mossakowski (toAnnoList (last as) att)
30256573a343132354b122097b0ee1215dda1364Till Mossakowski _ -> -- "No appropiate constructor for Annoted found"
30256573a343132354b122097b0ee1215dda1364Till Mossakowski Annoted (fromATerm att)
30256573a343132354b122097b0ee1215dda1364Till Mossakowski _ -> fromATermError "Annoted a" aterm
30256573a343132354b122097b0ee1215dda1364Till Mossakowski aterm = getATerm att
30256573a343132354b122097b0ee1215dda1364Till Mossakowski---- functions to convert annoted stuff ---------------------------------
30256573a343132354b122097b0ee1215dda1364Till Mossakowski-- all these functions are called by instance ATermConvertible Annoted a
30256573a343132354b122097b0ee1215dda1364Till MossakowskifromATermAnnotedBasic_Items :: forall a . ATermConvertible a =>
30256573a343132354b122097b0ee1215dda1364Till Mossakowski ATermTable -> (a,[Annotation])
30256573a343132354b122097b0ee1215dda1364Till MossakowskifromATermAnnotedBasic_Items att =
30256573a343132354b122097b0ee1215dda1364Till Mossakowski if isSig_items then
30256573a343132354b122097b0ee1215dda1364Till Mossakowski ((fromATerm att),[])
30256573a343132354b122097b0ee1215dda1364Till Mossakowski else ((fromATerm att),annoList)
30256573a343132354b122097b0ee1215dda1364Till Mossakowski where isSig_items =
30256573a343132354b122097b0ee1215dda1364Till Mossakowski case aterm of
30256573a343132354b122097b0ee1215dda1364Till Mossakowski AAppl _ as -> -- pos-BASIC-ITEMS
30256573a343132354b122097b0ee1215dda1364Till Mossakowski case getATerm $ getATermByIndexSp1 (last as) att of
30256573a343132354b122097b0ee1215dda1364Till Mossakowski AAppl "sig-items" _ -> True
30256573a343132354b122097b0ee1215dda1364Till Mossakowski _ -> fromATermError "{SIG,BASIC}_items" aterm
30256573a343132354b122097b0ee1215dda1364Till Mossakowski aterm = getATerm att
30256573a343132354b122097b0ee1215dda1364Till Mossakowski annoList = case getATerm att of
30256573a343132354b122097b0ee1215dda1364Till Mossakowski AAppl _ as -> getAnnoList (last as) att
30256573a343132354b122097b0ee1215dda1364Till Mossakowski _ -> error "Wrong ATerm structure: BASIC_ITEMS"
30256573a343132354b122097b0ee1215dda1364Till Mossakowski{- att' = let (AAppl _ as) = getATerm att -- pos-BASIC-ITEMS
30256573a343132354b122097b0ee1215dda1364Till Mossakowski (AAppl _ as') = getATerm $ -- sig-items
30256573a343132354b122097b0ee1215dda1364Till Mossakowski getATermByIndexSp1 (head as) att
30256573a343132354b122097b0ee1215dda1364Till Mossakowski in getATermByIndexSp1 (head as') att -}
30256573a343132354b122097b0ee1215dda1364Till Mossakowski{-fromATermAnnotedSig_Items :: ATermTable -> [SIG_ITEMS]
30256573a343132354b122097b0ee1215dda1364Till MossakowskifromATermAnnotedSig_Items att =
30256573a343132354b122097b0ee1215dda1364Till Mossakowski-- Sig Items have an anno list which now is attached to
30256573a343132354b122097b0ee1215dda1364Till Mossakowski-- the first item
30256573a343132354b122097b0ee1215dda1364Till Mossakowski Just "s-items" ->
30256573a343132354b122097b0ee1215dda1364Till Mossakowski let aterm' = getATerm (getATermByIndexSp1 (head as) att)
30256573a343132354b122097b0ee1215dda1364Till Mossakowski as' = case aterm' of AAppl _ as -> as
30256573a343132354b122097b0ee1215dda1364Till Mossakowski in Annoted (fromATerm att)
30256573a343132354b122097b0ee1215dda1364Till Mossakowski (getAnnoList (last as) att)
30256573a343132354b122097b0ee1215dda1364Till Mossakowski-- getAnnoList and toAnnoList are only working with an AIndex as first
30256573a343132354b122097b0ee1215dda1364Till Mossakowski-- argument is given. If getAnnoList is called every AAppl that starts
30256573a343132354b122097b0ee1215dda1364Till Mossakowski-- with "pos-" is crossed without consideration. toAnnoList just calls
30256573a343132354b122097b0ee1215dda1364Till Mossakowski-- the [Annotation] conversion directly.
30256573a343132354b122097b0ee1215dda1364Till MossakowskigetAnnoList :: ATerm -> ATermTable -> [Annotation]
30256573a343132354b122097b0ee1215dda1364Till MossakowskigetAnnoList ai att = case at of
30256573a343132354b122097b0ee1215dda1364Till Mossakowski AAppl c as | isPrefixOf "pos-" c ->
30256573a343132354b122097b0ee1215dda1364Till Mossakowski getAnnoList (last as) att
30256573a343132354b122097b0ee1215dda1364Till Mossakowski AAppl _ as -> toAnnoList (last as) att
30256573a343132354b122097b0ee1215dda1364Till Mossakowski _ -> error "wrong storage or missed 'pos-' contructor"
30256573a343132354b122097b0ee1215dda1364Till Mossakowski where at = getATerm (getATermByIndexSp1 ai att)
30256573a343132354b122097b0ee1215dda1364Till MossakowskitoAnnoList :: ATerm -> ATermTable -> [Annotation]
30256573a343132354b122097b0ee1215dda1364Till MossakowskitoAnnoList ai att = fromATerm $ getATermByIndexSp1 ai att
30256573a343132354b122097b0ee1215dda1364Till Mossakowski-------------------------------------------------------------------------
30256573a343132354b122097b0ee1215dda1364Till Mossakowskiparse_anno :: [Pos] -> String -> Annotation
30256573a343132354b122097b0ee1215dda1364Till Mossakowskiparse_anno pos_l inp =
30256573a343132354b122097b0ee1215dda1364Till Mossakowski case (parse (set_pos annotations) "" inp) of
30256573a343132354b122097b0ee1215dda1364Till Mossakowski Left err -> error ("internal parse error at " ++ (show err))
30256573a343132354b122097b0ee1215dda1364Till Mossakowski Right [x] -> x
30256573a343132354b122097b0ee1215dda1364Till Mossakowski where set_pos p = do setPosition sp
30256573a343132354b122097b0ee1215dda1364Till Mossakowski sp = newPos "ATermConversion from SML" (fst pos) (snd pos)
30256573a343132354b122097b0ee1215dda1364Till Mossakowski pos = head pos_l
30256573a343132354b122097b0ee1215dda1364Till Mossakowskiparse_disp_anno :: Id -> [Pos] -> String -> Annotation
30256573a343132354b122097b0ee1215dda1364Till Mossakowskiparse_disp_anno i pos_l inp =
30256573a343132354b122097b0ee1215dda1364Till Mossakowski case (parse (set_pos annotations) "" inp') of
30256573a343132354b122097b0ee1215dda1364Till Mossakowski Left err -> error ("internal parse error at " ++ (show err))
30256573a343132354b122097b0ee1215dda1364Till Mossakowski Right [x] -> x
30256573a343132354b122097b0ee1215dda1364Till Mossakowski where set_pos p = do setPosition sp
30256573a343132354b122097b0ee1215dda1364Till Mossakowski sp = newPos "ATermConversion from SML" (fst pos) (snd pos)
30256573a343132354b122097b0ee1215dda1364Till Mossakowski pos = head pos_l
30256573a343132354b122097b0ee1215dda1364Till Mossakowski inp' = (showId i "") ++ (' ':inp)
30256573a343132354b122097b0ee1215dda1364Till Mossakowski----- instances of AS_Basic_CASL.hs -------------------------------------
30256573a343132354b122097b0ee1215dda1364Till Mossakowskiinstance ATermConvertible BASIC_SPEC where
30256573a343132354b122097b0ee1215dda1364Till Mossakowski toATerm _ _ = error "*** toATerm for \"BASIC_SPEC\" not implemented"
4b41220e2b76251e0bb0760c016e79994bb2c2bbChristian Maeder fromATerm att =
4b41220e2b76251e0bb0760c016e79994bb2c2bbChristian Maeder case aterm of
4b41220e2b76251e0bb0760c016e79994bb2c2bbChristian Maeder (AAppl "basic-spec" [ aa ]) ->
4b41220e2b76251e0bb0760c016e79994bb2c2bbChristian Maeder aa' = fromATerm (getATermByIndexSp1 aa att)
4b41220e2b76251e0bb0760c016e79994bb2c2bbChristian Maeder _ -> fromATermError "BASIC_SPEC" aterm
4b41220e2b76251e0bb0760c016e79994bb2c2bbChristian Maeder aterm = findATerm att' (map (getATermSp att') pat_list)
4b41220e2b76251e0bb0760c016e79994bb2c2bbChristian Maeder pat_list = [(AAppl "basic-spec" [ ]) ]
4b41220e2b76251e0bb0760c016e79994bb2c2bbChristian Maeder case getATerm att of
4b41220e2b76251e0bb0760c016e79994bb2c2bbChristian Maeder (AAppl "pos-BASIC-SPEC" [_,item_i]) ->
dd29aea0190ac8707f2a0896a4a4b8bb2aac13ffEugen Kuksa getATermByIndexSp1 item_i att
dd29aea0190ac8707f2a0896a4a4b8bb2aac13ffEugen Kuksainstance ATermConvertible BASIC_ITEMS where
dd29aea0190ac8707f2a0896a4a4b8bb2aac13ffEugen Kuksa toATerm _ _ = error "*** toATerm for \"BASIC_ITEMS\" not implemented"
dd29aea0190ac8707f2a0896a4a4b8bb2aac13ffEugen Kuksa fromATerm att =
dd29aea0190ac8707f2a0896a4a4b8bb2aac13ffEugen Kuksa case aterm of
dd29aea0190ac8707f2a0896a4a4b8bb2aac13ffEugen Kuksa (AAppl "sig-items" [ aa ]) ->
-- (CASL.grm:((WORDS,None)))
----- instances of AS_Structured.hs -------------------------------------
in group (AS_Structured.Basic_spec aa'') group_flag
----- instances of AS_Architecture.hs -----------------------------------
----- instances of AS_LIbrary.hs ----------------------------------------
in (AS_Library.Spec_defn aa' ab' ac'' ad')
in (AS_Library.View_defn aa' ab' ac' ad'' ae')
in (AS_Library.Arch_spec_defn aa' ab' ac')
in (AS_Library.Unit_spec_defn aa' ab' ac')
in (AS_Library.Download_items aa' ab' ac')