packages feed

regex-with-pcre 0.10.0.0 → 0.10.0.1

raw patch · 5 files changed

+127/−5 lines, 5 filesdep +regex-tdfadep +unordered-containersdep ~regex

Dependencies added: regex-tdfa, unordered-containers

Dependency ranges changed: regex

Files

README.markdown view
@@ -62,9 +62,11 @@      ☒  2017-03-16  v0.8.0.0  [Tidy up the API](https://github.com/iconnect/regex/milestone/10) -    ☒  2017-03-18  v0.9.0.0  [Finish tidying up the API, Add type-safe replacement templates and exploit TemplateHaskellQuotes](https://github.com/iconnect/regex/milestone/9)+    ☒  2017-03-24  v0.9.0.0  [Finish tidying up the API, Add type-safe replacement templates and exploit TemplateHaskellQuotes](https://github.com/iconnect/regex/milestone/9) -    ☒  2017-03-18  v0.10.0.0 [Tweak TypeSafe SearchReplace templates](https://github.com/iconnect/regex/milestone/11)+    ☒  2017-03-25  v0.10.0.0 [Tweak TypeSafe SearchReplace templates](https://github.com/iconnect/regex/milestone/11)++    ☒  2017-03-26  v0.10.0.1 [Fix release](https://github.com/iconnect/regex/issues/88)      ☐  2017-03-31  v1.0.0.0  [First stable release](https://github.com/iconnect/regex/milestone/3) 
+ Text/RE/Internal/QQ.hs view
@@ -0,0 +1,29 @@+{-# LANGUAGE DeriveDataTypeable         #-}++module Text.RE.Internal.QQ where++import           Control.Exception+import           Data.Typeable+import           Language.Haskell.TH.Quote+++-- | used to throw an exception reporting an abuse of a quasi quoter+data QQFailure =+  QQFailure+    { _qqf_context   :: String  -- ^ in what context was the quasi quoter used+    , _qqf_component :: String  -- ^ how was the quasi quoter being abused+    }+  deriving (Show,Typeable)++instance Exception QQFailure where++-- | a quasi quoter that can be used in no context (to be extended with+-- the appropriate quasi quoter parser)+qq0 :: String -> QuasiQuoter+qq0 ctx =+  QuasiQuoter+    { quoteExp  = const $ throw $ QQFailure ctx "expression"+    , quotePat  = const $ throw $ QQFailure ctx "pattern"+    , quoteType = const $ throw $ QQFailure ctx "type"+    , quoteDec  = const $ throw $ QQFailure ctx "declaration"+    }
+ Text/RE/Internal/SearchReplace.hs view
@@ -0,0 +1,84 @@+{-# LANGUAGE NoImplicitPrelude          #-}+{-# LANGUAGE RecordWildCards            #-}+{-# LANGUAGE CPP                        #-}+#if __GLASGOW_HASKELL__ >= 800+{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}+{-# LANGUAGE TemplateHaskellQuotes      #-}+#else+{-# LANGUAGE QuasiQuotes                #-}+{-# LANGUAGE TemplateHaskell            #-}+#endif+{-# OPTIONS_GHC -fno-warn-orphans       #-}++module Text.RE.Internal.SearchReplace+  ( unsafeCompileSearchReplace_+  , compileSearchReplace_+  , compileSearchAndReplace_+  ) where++import qualified Data.HashMap.Strict            as HMS+import           Prelude.Compat+import           Text.RE.Internal.NamedCaptures+import           Text.RE.Types.Capture+import           Text.RE.Types.CaptureID+import           Text.RE.Types.Matches+import           Text.RE.Types.Replace+import           Text.RE.Types.SearchReplace+import qualified Text.Regex.TDFA                as TDFA+++-- | warapper on 'compileSearchReplace_' that will generate an error+-- if any compilation errors are found+unsafeCompileSearchReplace_ :: (String->s)+                            -> (String->Either String re)+                            -> String+                            -> SearchReplace re s+unsafeCompileSearchReplace_ pk cf = either err id . compileSearchReplace_ pk cf+  where+    err msg = error $ "unsafeCompileSearchReplace_: " ++ msg++-- | compile a SearchReplace template generating errors if the RE or+-- the template are not well formed -- all capture references being checked+compileSearchReplace_ :: (Monad m,Functor m)+                      => (String->s)+                      -> (String->Either String re)+                      -> String+                      -> m (SearchReplace re s)+compileSearchReplace_ pack compile_re sr_tpl = either fail return $ do+    case mainCaptures $ sr_tpl $=~ "///" of+      [cap] ->+        compileSearchAndReplace_ pack compile_re+                      (capturePrefix cap) (captureSuffix cap)+      _ -> Left $ "bad search-replace template syntax: " ++ sr_tpl++-- | compile 'SearcgReplace' from two strings containing the RE+-- and the replacement template+compileSearchAndReplace_ :: (Monad m,Functor m)+                         => (String->s)+                         -> (String->Either String re)+                         -> String+                         -> String+                         -> m (SearchReplace re s)+compileSearchAndReplace_ pack compile_re re_s tpl = either fail return $ do+    re           <- compile_re re_s+    ((n,cnms),_) <- extractNamedCaptures re_s+    mapM_ (check n cnms) $ templateCaptures id tpl+    return $ SearchReplace re $ pack tpl+  where+    check :: Int -> CaptureNames -> CaptureID -> Either String ()+    check n cnms cid = case cid of+      IsCaptureOrdinal co -> check_co n    co+      IsCaptureName    cn -> check_cn cnms cn++    check_co n (CaptureOrdinal i) = case i <= n of+      True  -> return ()+      False -> Left $ "capture ordinal out of range: " +++                                      show i ++ " >= " ++ show n++    check_cn cnms cnm = case cnm `HMS.member` cnms of+      True  -> return ()+      False -> Left $ "capture name not defined: " +++                                      show (getCaptureName cnm)++($=~) :: String -> String -> Matches String+($=~) = (TDFA.=~)
changelog view
@@ -1,5 +1,8 @@ -*-change-log-*- +0.10.0.1 Chris Dornan <chris.dornan@irisconnect.co.uk> 2017-03-26+  * Fix sub-package cabal files (#88)+ 0.10.0.0 Chris Dornan <chris.dornan@irisconnect.co.uk> 2017-03-25   * Tweak Type-Safe SearchReplace templates (#86)   * Add escape methods to IsRegex (#87)
regex-with-pcre.cabal view
@@ -1,5 +1,5 @@ Name:                   regex-with-pcre-Version:                0.10.0.0+Version:                0.10.0.1 Synopsis:               Toolkit for regex-base Description:            A Regular Expression Toolkit for regex-base with                         Compile-time checking of RE syntax, data types for@@ -31,7 +31,7 @@ Source-Repository this     Type:               git     Location:           https://github.com/iconnect/regex.git-    Tag:                0.10.0.0+    Tag:                0.10.0.1   @@ -47,6 +47,8 @@       Text.RE.PCRE.String      Other-Modules:+      Text.RE.Internal.QQ+      Text.RE.Internal.SearchReplace       Text.RE.Internal.SearchReplace.PCRE       Text.RE.Internal.SearchReplace.PCRE.ByteString       Text.RE.Internal.SearchReplace.PCRE.ByteString.Lazy@@ -87,15 +89,17 @@       -Wwarn      Build-depends:-        regex                == 0.10.0.0+        regex                == 0.10.0.1       , base                 >= 4 && < 5       , base-compat          >= 0.6.0       , bytestring           >= 0.10.2.0       , containers           >= 0.4       , regex-base           >= 0.93.2       , regex-pcre-builtin   >= 0.94.4.8.8.35+      , regex-tdfa           >= 1.2.0       , template-haskell     >= 2.7       , transformers         >= 0.2.2+      , unordered-containers >= 0.2.5.1   -- Generated with re-gen-cabals