Tools.hs revision 98997f9d65c6bec5e349057af53337d46e57ddba
abd8dd44106c507dd2cb64359b63d7d56fa0a9c8Christian Maeder{- |
abd8dd44106c507dd2cb64359b63d7d56fa0a9c8Christian MaederModule : $Header$
09249711700a6acbc40a2e337688b434d7aafa28Christian MaederDescription : Abstract syntax for reduce
76647324ed70f33b95a881b536d883daccf9568dChristian MaederCopyright : (c) Dominik Dietrich, DFKI Bremen 2010
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu ProdescuLicense : GPLv2 or higher
c00adad2e9459b422dee09e3a2bddba66b433bb7Christian Maeder
3f69b6948966979163bdfe8331c38833d5d90ecdChristian MaederMaintainer : dominik.dietrich@dfki.de
abd8dd44106c507dd2cb64359b63d7d56fa0a9c8Christian MaederStability : experimental
76647324ed70f33b95a881b536d883daccf9568dChristian MaederPortability : portable
f3a94a197960e548ecd6520bb768cb0d547457bbChristian Maeder
f3a94a197960e548ecd6520bb768cb0d547457bbChristian Maeder-}
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder
c00adad2e9459b422dee09e3a2bddba66b433bb7Christian Maedermodule CSL.Tools where
c00adad2e9459b422dee09e3a2bddba66b433bb7Christian Maeder
e8ffec0fa3d3061061bdc16e44247b9cf96b050fChristian Maederimport CSL.AS_BASIC_CSL
c00adad2e9459b422dee09e3a2bddba66b433bb7Christian Maederimport Common.Id
e8ffec0fa3d3061061bdc16e44247b9cf96b050fChristian Maederimport Common.AS_Annotation as AS_Anno
950e053ba55ac9c7d9c26a1ab48bd00202b29511Christian Maeder
0a39036fa485579a7b7c81cdd44a412392571927Christian MaedernegateFormula :: CMD -> CMD
10b02b2343246df6773585636fe3ddbefa3b6a1bChristian MaedernegateFormula (Cmd s exps) = Cmd "Not" [(Op s [] exps nullRange)]
10b02b2343246df6773585636fe3ddbefa3b6a1bChristian MaedernegateFormula _ = error "negateFormula: not implemented" -- TODO: implement this
e8ffec0fa3d3061061bdc16e44247b9cf96b050fChristian Maeder
d48085f765fca838c1d972d2123601997174583dChristian MaedergetAtoms :: EXPRESSION -> [String]
10b02b2343246df6773585636fe3ddbefa3b6a1bChristian MaedergetAtoms e =
10b02b2343246df6773585636fe3ddbefa3b6a1bChristian Maeder case e of
ad270004874ce1d0697fb30d7309f180553bb315Christian Maeder Var tk -> ["var:" ++ tokStr tk]
0a39036fa485579a7b7c81cdd44a412392571927Christian Maeder Op s _ el _ -> ("op:" ++ s) : concatMap getAtoms el
abd8dd44106c507dd2cb64359b63d7d56fa0a9c8Christian Maeder List el _ -> ("list") : concatMap getAtoms el
d48085f765fca838c1d972d2123601997174583dChristian Maeder Int _ _ -> ["int"]
76647324ed70f33b95a881b536d883daccf9568dChristian Maeder Double _ _ -> ["dbl"]
d48085f765fca838c1d972d2123601997174583dChristian Maeder Interval _ _ _ -> ["intv"]
d48085f765fca838c1d972d2123601997174583dChristian Maeder
76647324ed70f33b95a881b536d883daccf9568dChristian MaedergetCmdAtoms :: CMD -> [String]
d48085f765fca838c1d972d2123601997174583dChristian MaedergetCmdAtoms c =
05ae87b9efa19655024b0b6ac344d250b96567cdChristian Maeder case c of
d48085f765fca838c1d972d2123601997174583dChristian Maeder Cmd s el -> ("cmd:" ++ s) : concatMap getAtoms el
d48085f765fca838c1d972d2123601997174583dChristian Maeder Repeat e cl -> "repeat" : (getAtoms e ++ concatMap getCmdAtoms cl)
d48085f765fca838c1d972d2123601997174583dChristian Maeder _ -> [] -- TODO: implement this
d48085f765fca838c1d972d2123601997174583dChristian Maeder
d48085f765fca838c1d972d2123601997174583dChristian Maeder
a39a820684c1974350f46593025e0bb279f41bc6Christian MaedergetBSAtoms :: BASIC_SPEC -> [String]
a39a820684c1974350f46593025e0bb279f41bc6Christian MaedergetBSAtoms (Basic_spec l) = concatMap (f . AS_Anno.item) l
72b9099aeec0762bae4546db3bc4b48721027bf4Christian Maeder where f (Op_decl _) = []
a39a820684c1974350f46593025e0bb279f41bc6Christian Maeder f (Axiom_item ac) = getCmdAtoms $ AS_Anno.item ac
76647324ed70f33b95a881b536d883daccf9568dChristian Maeder f _ = [] -- TODO: implement this
d48085f765fca838c1d972d2123601997174583dChristian Maeder