RunMixfixParser.hs revision b603f34b79bc0992e5d74f484e5bdc9f9c2346c6
ce5ff829db5f0bb4f16ad4de150eed4401d6acd5Christian MaederModule : $Header$
ce5ff829db5f0bb4f16ad4de150eed4401d6acd5Christian MaederCopyright : (c) Klaus L�ttich, Christian Maeder and Uni Bremen 2002-2006
75a6279dbae159d018ef812185416cf6df386c10Till MossakowskiLicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
eca29a7be76eb73944ec19b06eda3d6a9e6e543dChristian MaederMaintainer : maeder@tzi.de
ce5ff829db5f0bb4f16ad4de150eed4401d6acd5Christian MaederStability : experimental
ce5ff829db5f0bb4f16ad4de150eed4401d6acd5Christian MaederPortability : portable
3f63b98c111e5e2bb2cf13795cf6e084a78b0a8dChristian Maedermake mixfix analysis checkable by RunParsers
1738d16957389457347bee85075d3d33d002158fChristian Maederimport qualified Common.Lib.Set as Set
1738d16957389457347bee85075d3d33d002158fChristian Maeder-- start testing
f9a73de15ef09dbd6b391c7b1f695c79b4446fe2Christian MaederstdOpsL, stdPredsL :: [String]
e76e6a43f51438215737d6fc176c89da05bb86daChristian MaederstdOpsL = ["__^__", "__*__", "__+__", "[__]","__div__","__mod__", "__rem__",
f9a73de15ef09dbd6b391c7b1f695c79b4446fe2Christian Maeder "__-__", "+__", "__E__", "__@@__", "[]", "__::__", "__:::__",
f9a73de15ef09dbd6b391c7b1f695c79b4446fe2Christian Maeder "-__", "__!"] ++
fc7df539e6d41b050161ed8f9ae6e444b1b5ab14Christian Maeder [ "____p", "q____","____x____", "{____}",
f9a73de15ef09dbd6b391c7b1f695c79b4446fe2Christian Maeder "repeat__until__", "while__do__od",
0df692ce8b9293499b2e1768458613a63e7b5cd0Christian Maeder "__none__but__", "__one__done",
e92ae8b45c138b6cf7db8b69e2d099d7f62f24f0Christian Maeder "__ --> __", "__{__}--__-->{__}__"]
fc7df539e6d41b050161ed8f9ae6e444b1b5ab14Christian Maeder ++ map (:[]) "#0123456789abcdefghijklmnopqxABCDEFGHIJKLMNO"
fc7df539e6d41b050161ed8f9ae6e444b1b5ab14Christian Maeder ++ ["A[a[c,d],b]", "B[a[c,d],b]", "__B[a[c,d],b]__",
fc7df539e6d41b050161ed8f9ae6e444b1b5ab14Christian Maeder "a[c,d]", "__a[c,d]__", "A[a]", "A__B",
0f67ca7b0c738a28f6688ba6e96d44d7c14af611Christian Maeder "A__", "__[a]", "__p", "__#", "D__",
f9a73de15ef09dbd6b391c7b1f695c79b4446fe2Christian Maeder "__[__]__", "[__]__", "__[__]",
f9a73de15ef09dbd6b391c7b1f695c79b4446fe2Christian Maeder "not__", "def__", "__if__",
fc7df539e6d41b050161ed8f9ae6e444b1b5ab14Christian Maeder "__=__", "__=>__", "__/\\__", "__\\/__", "__<=>__",
fc7df539e6d41b050161ed8f9ae6e444b1b5ab14Christian Maeder "__when__else__", "if__then__else__"]
0df692ce8b9293499b2e1768458613a63e7b5cd0Christian MaederstdPredsL = ["__<__", "__<=__", "__>__", "__>=__", "__!=__", "__<>__",
cc8b603388a7deb7fb8045db0341f550f8be5844Christian Maeder "__/=__", "even__", "odd__", "__isEmpty",
0df692ce8b9293499b2e1768458613a63e7b5cd0Christian Maeder "__<=__<=__"]
0df692ce8b9293499b2e1768458613a63e7b5cd0Christian MaedermkIds :: [String] -> Set.Set Id
ce5ff829db5f0bb4f16ad4de150eed4401d6acd5Christian MaedermkIds = Set.fromList . map (parseString some_id)
04dada28736b4a237745e92063d8bdd49a362debChristian MaederstdOps, stdPreds :: Set.Set Id
f4741f6b7da52b5417899c8fcbe4349b920b006eChristian MaederstdOps = mkIds stdOpsL
f4741f6b7da52b5417899c8fcbe4349b920b006eChristian MaederstdPreds = mkIds stdPredsL
f4741f6b7da52b5417899c8fcbe4349b920b006eChristian MaederresolveTerm :: GlobalAnnos -> AParser () (Result Term)
f4741f6b7da52b5417899c8fcbe4349b920b006eChristian MaederresolveTerm ga = do
ce5ff829db5f0bb4f16ad4de150eed4401d6acd5Christian Maeder let ids = stdOps `Set.union` stdPreds
cf5149eb4d0faef6272231879c04aa740f5abc2bChristian Maeder newGa = addBuiltins ga
cf5149eb4d0faef6272231879c04aa740f5abc2bChristian Maeder ps = (mkPrecIntMap $ prec_annos newGa, stdPreds)
cf5149eb4d0faef6272231879c04aa740f5abc2bChristian Maeder (addRule, ruleS, _) = makeRules newGa ps ids
cf5149eb4d0faef6272231879c04aa740f5abc2bChristian Maeder chart = evalState (iterateCharts newGa [trm]
cf5149eb4d0faef6272231879c04aa740f5abc2bChristian Maeder $ initChart addRule ruleS)
cf5149eb4d0faef6272231879c04aa740f5abc2bChristian Maeder initialEnv { preIds = ps, globAnnos = newGa }
cf5149eb4d0faef6272231879c04aa740f5abc2bChristian Maeder return $ getResolved (shows . toText newGa . printTerm . parenTerm)
f4741f6b7da52b5417899c8fcbe4349b920b006eChristian Maeder (getRange trm) toMixTerm chart
7abd0c58a5ce51db13f93de82407b2188d55d298Christian MaedertoMyStringParser :: Pretty a => (GlobalAnnos -> AParser () a)
7abd0c58a5ce51db13f93de82407b2188d55d298Christian Maeder -> StringParser
f4741f6b7da52b5417899c8fcbe4349b920b006eChristian MaedertoMyStringParser p ga =
f4741f6b7da52b5417899c8fcbe4349b920b006eChristian Maeder fmap (\ a -> showGlobalDoc (addBuiltins ga) a "") $ p ga