Parse_AS.hs revision 10e8873de4a89035222d077fe80b9fd7b9631473
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder{- Spickzettel f�r's Parsen
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder-- Definition aus Logic.hs
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maedertype ParseFun a = FilePath -> Int -> Int -> String -> (a,String,Int,Int)
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder -- args: filename, line, column, input text
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder -- result: value, remaining text, line, column
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder-- ParsecInterface.hs
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian MaedertoParseFun :: GenParser Char st a -> st -> ParseFun a
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder-- Klassenfunktion, die meine Instanz implementiert
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maederparse_basic_spec :: id -> Maybe(ParseFun basic_spec)
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder-- ^ R�ckgabetyp
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder-}
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maedermodule Parse_AS where
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maederimport AnnoState
97c9d39efee30883aa578294c46506ff8a9478c8Christian Maederimport Id
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maederimport Token
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maederimport Keywords
ae4309002e3121468cc3f3f77b821d4620ca24ccChristian Maederimport Lexer
ae4309002e3121468cc3f3f77b821d4620ca24ccChristian Maederimport AS_Modal
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder-- import AS_Annotation
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder-- import Maybe
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maederimport Common.Lib.Parsec
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder--import Formula
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder--import SortItem
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder--import OpItem
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder--import TypeItem
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maederimport ItemList
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder-- aus CASL, kann bleiben
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian MaederbasicSpec :: AParser BASIC_SPEC
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian MaederbasicSpec = (fmap Basic_spec $ many1 $
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder try $ annoParser basicItems)
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder <|> try (oBraceT >> cBraceT >> return (Basic_spec []))
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian MaederbasicItems :: AParser BASIC_ITEMS
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian MaederbasicItems = fmap Sig_items sigItems
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder <|> dotFormulae -- sp�ter!
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian MaedersigItems :: AParser SIG_ITEMS
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian MaedersigItems = propItems
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian MaederpropItem :: AParser PROP_ITEM
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian MaederpropItem = do s <- sortId ; -- Props are the same as sorts (in declaration)
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder commaPropDecl s
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder <|>
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder return (Prop_decl [s] [])
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian MaederpropItems :: AParser SIG_ITEMS
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian MaederpropItems = itemList propS propItem Prop_items
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian Maeder
ad772a9e1c0a951a5fa508a3a3ec35e3fda2aec2Christian MaedercommaPropDecl :: Id -> AParser PROP_ITEM
c7af9fa9874262288327ea398b2466e1f4c20fe2Christian MaedercommaPropDecl s = do c <- anComma
c7af9fa9874262288327ea398b2466e1f4c20fe2Christian Maeder (is, cs) <- sortId `separatedBy` anComma
c7af9fa9874262288327ea398b2466e1f4c20fe2Christian Maeder let l = s : is
c7af9fa9874262288327ea398b2466e1f4c20fe2Christian Maeder p = tokPos c : map tokPos cs in return (Prop_decl l p)
ae4309002e3121468cc3f3f77b821d4620ca24ccChristian Maeder
c7af9fa9874262288327ea398b2466e1f4c20fe2Christian Maeder