RunMixfixParser.hs revision e9458b1a7a19a63aa4c179f9ab20f4d50681c168
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder{- |
c3d42e13d2a7c3749229498658aec34e7e4fd0a0Christian MaederModule : ./CASL/RunMixfixParser.hs
c3d42e13d2a7c3749229498658aec34e7e4fd0a0Christian MaederDescription : make mixfix analysis checkable by RunParsers
cd7372fc7e6e43c389619f63daa6eb872d9d5b16Christian MaederCopyright : (c) Klaus Luettich, Christian Maeder and Uni Bremen 2002-2003
97018cf5fa25b494adffd7e9b4e87320dae6bf47Christian MaederLicense : GPLv2 or higher, see LICENSE.txt
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder
c3d42e13d2a7c3749229498658aec34e7e4fd0a0Christian MaederMaintainer : Christian.Maeder@dfki.de
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian MaederStability : experimental
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian MaederPortability : portable
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder
99c923311eab71a85f1dcc4785d349609c828da4Christian MaederMake mixfix analysis checkable by RunParsers
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder-}
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maedermodule CASL.RunMixfixParser where
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maeder
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maederimport Common.AnnoState
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maederimport Common.GlobalAnnotations
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maederimport Common.Result
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maederimport Common.Doc
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maederimport Common.DocUtils
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maederimport Common.ExampleMixIds
d4e8d3a0ddb1a63754edc3571b6a3a54a7b62d04Paolo Torrini
d4e8d3a0ddb1a63754edc3571b6a3a54a7b62d04Paolo Torriniimport CASL.Formula
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maederimport CASL.ShowMixfix
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maederimport CASL.MixfixParser
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maederimport CASL.AS_Basic_CASL
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maeder
99c923311eab71a85f1dcc4785d349609c828da4Christian Maederimport qualified Data.Set as Set
99c923311eab71a85f1dcc4785d349609c828da4Christian Maeder
99c923311eab71a85f1dcc4785d349609c828da4Christian MaedermyIdSets :: IdSets
120c9bff9059626735fc12b0399dcc9e5a62c345Christian MaedermyIdSets = mkIdSets Set.empty (mkIds stdOpsL) stdPreds
99c923311eab71a85f1dcc4785d349609c828da4Christian Maeder
99c923311eab71a85f1dcc4785d349609c828da4Christian MaederresolveForm :: GlobalAnnos -> AParser () (Result (FORMULA ()))
d4e8d3a0ddb1a63754edc3571b6a3a54a7b62d04Paolo TorriniresolveForm ga =
d4e8d3a0ddb1a63754edc3571b6a3a54a7b62d04Paolo Torrini resolveFormula id (const $ const return) ga (makeRules ga myIdSets)
d4e8d3a0ddb1a63754edc3571b6a3a54a7b62d04Paolo Torrini `fmap` formula []
99c923311eab71a85f1dcc4785d349609c828da4Christian Maeder
99c923311eab71a85f1dcc4785d349609c828da4Christian MaederresolveTerm :: GlobalAnnos -> AParser () (Result (TERM ()))
120c9bff9059626735fc12b0399dcc9e5a62c345Christian MaederresolveTerm ga =
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maeder resolveMixfix id (const $ const return) ga (makeRules ga myIdSets)
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maeder `fmap` term []
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maeder
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maeder-- | a helper type to pretty print (wrapped) strings
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maederdata WrapString = WrapString String
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maederinstance Show WrapString where
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maeder showsPrec _ (WrapString s) _ = s
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maeder
603e326e7b189de8c1e4ea8c89470b3a61154019Christian Maederinstance Pretty WrapString where
603e326e7b189de8c1e4ea8c89470b3a61154019Christian Maeder pretty (WrapString s) = text s
603e326e7b189de8c1e4ea8c89470b3a61154019Christian Maeder
120c9bff9059626735fc12b0399dcc9e5a62c345Christian MaedertestTerm :: AParser () WrapString
120c9bff9059626735fc12b0399dcc9e5a62c345Christian MaedertestTerm = do
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maeder t <- term [] :: AParser () (TERM ())
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maeder return $ WrapString $ showDoc (mapTerm id t) ""
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maeder
120c9bff9059626735fc12b0399dcc9e5a62c345Christian MaedertestTermMix :: GlobalAnnos -> AParser () WrapString
120c9bff9059626735fc12b0399dcc9e5a62c345Christian MaedertestTermMix ga = do
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maeder Result ds mt <- resolveTerm ga
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maeder return $ WrapString $ case mt of
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maeder Just t -> showGlobalDoc ga (mapTerm id t) ""
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maeder _ -> show ds
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maeder
120c9bff9059626735fc12b0399dcc9e5a62c345Christian MaedertestFormula :: AParser () WrapString
120c9bff9059626735fc12b0399dcc9e5a62c345Christian MaedertestFormula = do
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maeder f <- formula [] :: AParser () (FORMULA ())
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maeder return $ WrapString $ showDoc (mapFormula id f) ""
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maeder
120c9bff9059626735fc12b0399dcc9e5a62c345Christian MaedertestFormulaMix :: GlobalAnnos -> AParser () WrapString
120c9bff9059626735fc12b0399dcc9e5a62c345Christian MaedertestFormulaMix ga = do
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maeder Result ds m <- resolveForm ga
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maeder return $ WrapString $ case m of
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maeder Just f -> showGlobalDoc ga (mapFormula id f) ""
62dd3cd58cda003c32ac69ff12dc82b0a6f5d9d3Christian Maeder _ -> show ds
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maeder