Replace pcre-light with regex-tdfa
The regex-tdfa package implements POSIX extended regular expressions, which are what Nix uses.
This commit is contained in:
parent
1a01f85de9
commit
002a7ad1b9
|
@ -14,7 +14,7 @@
|
|||
{-# OPTIONS_GHC -Wno-missing-signatures #-}
|
||||
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
|
||||
|
||||
module Nix.Builtins (MonadBuiltins, baseEnv) where
|
||||
module Nix.Builtins where --(MonadBuiltins, baseEnv) where
|
||||
|
||||
import Control.Monad
|
||||
import Control.Monad.Fix
|
||||
|
@ -28,6 +28,7 @@ import Data.Aeson (toJSON)
|
|||
import qualified Data.Aeson as A
|
||||
import qualified Data.Aeson.Encoding as A
|
||||
import Data.Align (alignWith)
|
||||
import Data.Array
|
||||
import Data.ByteString (ByteString)
|
||||
import Data.ByteString.Base16 as Base16
|
||||
import qualified Data.ByteString.Lazy as LBS
|
||||
|
@ -62,9 +63,9 @@ import Nix.Stack
|
|||
import Nix.Thunk
|
||||
import Nix.Utils
|
||||
import Nix.XML
|
||||
import Text.Regex.TDFA
|
||||
import System.FilePath
|
||||
import System.Posix.Files
|
||||
import Text.Regex.PCRE.Light
|
||||
|
||||
type MonadBuiltins e m =
|
||||
(MonadEval e m, MonadNix m, MonadFix m, MonadFile m, MonadVar m)
|
||||
|
@ -394,12 +395,12 @@ match_ pat str = force pat $ \pat' -> force str $ \str' ->
|
|||
-- jww (2018-04-05): We should create a fundamental type for compiled
|
||||
-- regular expressions if it turns out they get used often.
|
||||
(NVStr p _, NVStr s _) -> return $ NVList $
|
||||
let re = compile (encodeUtf8 p <> "$") []
|
||||
in case match re (encodeUtf8 s) [exec_anchored] of
|
||||
Nothing -> []
|
||||
Just s ->
|
||||
let re = makeRegex (encodeUtf8 p) :: Regex
|
||||
in case matchOnceText re (encodeUtf8 s) of
|
||||
Just ("", sarr, "") -> let s = map fst (elems sarr) in
|
||||
map (valueThunk @m . flip NVStr mempty . decodeUtf8)
|
||||
(if captureCount re > 0 then tail s else s)
|
||||
(if length s > 1 then tail s else s)
|
||||
_ -> []
|
||||
(p, s) ->
|
||||
throwError $ "builtins.match: expected a regex"
|
||||
++ " and a string, but got: " ++ show (p, s)
|
||||
|
|
|
@ -123,8 +123,8 @@ data Antiquoted v r = Plain !v | Antiquoted !r
|
|||
-- the final string is constructed by concating all the parts.
|
||||
data NString r
|
||||
= DoubleQuoted ![Antiquoted Text r]
|
||||
-- ^ Strings wrapped with double-quotes (") are not allowed to contain
|
||||
-- literal newline characters.
|
||||
-- ^ Strings wrapped with double-quotes (") can contain literal newline
|
||||
-- characters, but the newlines are preserved and no indentation is stripped.
|
||||
| Indented ![Antiquoted Text r]
|
||||
-- ^ Strings wrapped with two single quotes ('') can contain newlines,
|
||||
-- and their indentation will be stripped.
|
||||
|
|
|
@ -49,6 +49,7 @@ Library
|
|||
base >= 4.9 && < 5
|
||||
, aeson
|
||||
, ansi-wl-pprint
|
||||
, array >= 0.4 && < 0.6
|
||||
, base16-bytestring
|
||||
, containers
|
||||
, cryptohash
|
||||
|
@ -79,7 +80,6 @@ Library
|
|||
, syb
|
||||
, vector
|
||||
, xml
|
||||
, pcre-light
|
||||
if flag(parsec)
|
||||
Cpp-options: -DUSE_PARSEC
|
||||
Build-depends: parsec
|
||||
|
|
Loading…
Reference in a new issue