Parse_AS.hs revision 01f164e57224294d74f7bdbfdd4f7b4987607e51
53d399c20374a99bd95db1f9b5b93980cbf6a984Christian Maeder Authors: Wiebke Herding
b4fbc96e05117839ca409f5f20f97b3ac872d1edTill Mossakowski parse Modal Logic Items
e4e1509ff358e739fddf1483ad39467e0e1becc2Christian Maeder-- aus CASL, kann bleiben
53d399c20374a99bd95db1f9b5b93980cbf6a984Christian MaederbasicSpec :: AParser BASIC_SPEC
e4e1509ff358e739fddf1483ad39467e0e1becc2Christian MaederbasicSpec = (fmap Basic_spec $ annosParser basicItems)
35db0960aa2e2a13652381c756fae5fb2b27213bChristian Maeder <|> (oBraceT >> cBraceT >> return (Basic_spec []))
53d399c20374a99bd95db1f9b5b93980cbf6a984Christian MaederbasicItems :: AParser BASIC_ITEMS
cc6df32dd55910aac7de12b30cc5049d96b8f770Wiebke HerdingbasicItems = fmap Sig_items sigItems
414ffa281d82f05a2d742c702f8e06b0cb05b229Christian Maeder <|> dotFormulae -- sp�ter!
856bdbffc895793cc5739dbb862323944cb76fdbChristian MaedersigItems :: AParser SIG_ITEMS
856bdbffc895793cc5739dbb862323944cb76fdbChristian MaedersigItems = propItems
856bdbffc895793cc5739dbb862323944cb76fdbChristian MaederpropItem :: AParser PROP_ITEM
f7d2e793728bbb7fd185e027eb9dfd7b9dd11c21Christian MaederpropItem = do s <- sortId ; -- Props are the same as sorts (in declaration)
856bdbffc895793cc5739dbb862323944cb76fdbChristian Maeder commaPropDecl s
856bdbffc895793cc5739dbb862323944cb76fdbChristian Maeder return (Prop_decl [s] [])
856bdbffc895793cc5739dbb862323944cb76fdbChristian MaederpropItems :: AParser SIG_ITEMS
f7d2e793728bbb7fd185e027eb9dfd7b9dd11c21Christian MaederpropItems = itemList propS propItem Prop_items
856bdbffc895793cc5739dbb862323944cb76fdbChristian MaedercommaPropDecl :: Id -> AParser PROP_ITEM
856bdbffc895793cc5739dbb862323944cb76fdbChristian MaedercommaPropDecl s = do c <- anComma
856bdbffc895793cc5739dbb862323944cb76fdbChristian Maeder (is, cs) <- sortId `separatedBy` anComma
b645cf3dc1e449038ed291bbd11fcc6e02b2fc7fChristian Maeder let l = s : is
b1f52a36d45c5031c462291e263cec114975add1Wiebke Herding p = tokPos c : map tokPos cs in return (Prop_decl l p)
d297778800daa7ceba73ad9b19884c883487dee7Christian MaederdotFormulae :: AParser BASIC_ITEMS
d183a4514d8a5b6a5d48d15a8dff52d0c96691eaChristian MaederdotFormulae = do d <- dotT
d183a4514d8a5b6a5d48d15a8dff52d0c96691eaChristian Maeder (fs, ds) <- aFormula `separatedBy` dotT
d183a4514d8a5b6a5d48d15a8dff52d0c96691eaChristian Maeder (m, an) <- optSemi
53d399c20374a99bd95db1f9b5b93980cbf6a984Christian Maeder let ps = map tokPos (d:ds)
2b4130336e941b7d01c78a6da55449a4c6eca609Till Mossakowski ns = init fs ++ [appendAnno (last fs) an]
414ffa281d82f05a2d742c702f8e06b0cb05b229Christian Maeder Nothing -> return (Axiom_items ns ps)
53d399c20374a99bd95db1f9b5b93980cbf6a984Christian Maeder Just t -> return (Axiom_items ns
e953bea49e7f0e1a43bccf2a66c5e2a2b50848e0Christian Maeder (ps ++ [tokPos t]))
414ffa281d82f05a2d742c702f8e06b0cb05b229Christian MaederaFormula :: AParser (Annoted FORMULA)
53d399c20374a99bd95db1f9b5b93980cbf6a984Christian MaederaFormula = bind appendAnno (annoParser formula) lineAnnos
50dce6b011347f92377adb8bbabaeeb80975e86dChristian Maederformula :: AParser FORMULA
e953bea49e7f0e1a43bccf2a66c5e2a2b50848e0Christian Maederformula = impFormula []
53d399c20374a99bd95db1f9b5b93980cbf6a984Christian MaederimpFormula :: [String] -> AParser FORMULA
53d399c20374a99bd95db1f9b5b93980cbf6a984Christian MaederimpFormula k =
b1f52a36d45c5031c462291e263cec114975add1Wiebke Herding do f <- andOrFormula k
414ffa281d82f05a2d742c702f8e06b0cb05b229Christian Maeder do c <- implKey
5bc645bae86e7cc7714ab73934b77bb98ecbd078Christian Maeder (fs, ps) <- andOrFormula k `separatedBy` implKey
b1f52a36d45c5031c462291e263cec114975add1Wiebke Herding return (makeImpl (f:fs) (map tokPos (c:ps)))
53d399c20374a99bd95db1f9b5b93980cbf6a984Christian Maeder do c <- ifKey
310532f8a7a1a1f1b6c25c67b7c340abc0889335Christian Maeder (fs, ps) <- andOrFormula k `separatedBy` ifKey
310532f8a7a1a1f1b6c25c67b7c340abc0889335Christian Maeder return (makeIf (f:fs) (map tokPos (c:ps)))
53d399c20374a99bd95db1f9b5b93980cbf6a984Christian Maeder do c <- asKey equivS
310532f8a7a1a1f1b6c25c67b7c340abc0889335Christian Maeder g <- andOrFormula k
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski return (Equivalence f g [tokPos c])
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski where makeImpl [f,g] p = Implication f g p
310532f8a7a1a1f1b6c25c67b7c340abc0889335Christian Maeder makeImpl (f:r) (c:p) =
53d399c20374a99bd95db1f9b5b93980cbf6a984Christian Maeder Implication f (makeImpl r p) [c]
310532f8a7a1a1f1b6c25c67b7c340abc0889335Christian Maeder makeImpl _ _ = error "makeImpl got illegal argument"
e953bea49e7f0e1a43bccf2a66c5e2a2b50848e0Christian Maeder makeIf l p = makeImpl (reverse l) (reverse p)
e953bea49e7f0e1a43bccf2a66c5e2a2b50848e0Christian MaederandOrFormula :: [String] -> AParser FORMULA
e953bea49e7f0e1a43bccf2a66c5e2a2b50848e0Christian MaederandOrFormula k =
e953bea49e7f0e1a43bccf2a66c5e2a2b50848e0Christian Maeder do f <- primFormula k
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski do c <- andKey
e953bea49e7f0e1a43bccf2a66c5e2a2b50848e0Christian Maeder (fs, ps) <- primFormula k `separatedBy` andKey
e953bea49e7f0e1a43bccf2a66c5e2a2b50848e0Christian Maeder return (Conjunction (f:fs) (map tokPos (c:ps)))
53d399c20374a99bd95db1f9b5b93980cbf6a984Christian Maeder do c <- orKey
-- No when...else