diff options
| author | Roman Smrž <roman.smrz@seznam.cz> | 2025-04-22 19:50:47 +0200 | 
|---|---|---|
| committer | Roman Smrž <roman.smrz@seznam.cz> | 2025-04-24 22:23:50 +0200 | 
| commit | 4ff632e50313b7d2bf03a35d78ede5d8c6b8331e (patch) | |
| tree | 1cf99fca069ebbdf3cc6a78921c6bd2d65092bf3 | |
| parent | 47ec9619f90af3264b11ad26654610a043ed0d8d (diff) | |
Fix parsing regexes containing only a variable expansion
| -rw-r--r-- | src/Parser/Expr.hs | 4 | ||||
| -rw-r--r-- | src/Script/Expr.hs | 3 | 
2 files changed, 3 insertions, 4 deletions
| diff --git a/src/Parser/Expr.hs b/src/Parser/Expr.hs index bf94c2d..3700602 100644 --- a/src/Parser/Expr.hs +++ b/src/Parser/Expr.hs @@ -37,8 +37,6 @@ import Text.Megaparsec hiding (State)  import Text.Megaparsec.Char  import Text.Megaparsec.Char.Lexer qualified as L  import Text.Megaparsec.Error.Builder qualified as Err -import Text.Regex.TDFA qualified as RE -import Text.Regex.TDFA.Text qualified as RE  import Parser.Core  import Script.Expr @@ -161,7 +159,7 @@ regex = label "regular expression" $ lexeme $ do      let testEval = \case              Pure (RegexPart p) -> p              _ -> "" -    case RE.compile RE.defaultCompOpt RE.defaultExecOpt $ T.concat $ map testEval parts of +    case regexCompile $ T.concat $ map testEval parts of          Left err -> registerParseError $ FancyError off $ S.singleton $ ErrorFail $ T.unpack $ T.concat              [ "failed to parse regular expression: ", T.pack err ]          Right _ -> return () diff --git a/src/Script/Expr.hs b/src/Script/Expr.hs index 0c401e2..ced807c 100644 --- a/src/Script/Expr.hs +++ b/src/Script/Expr.hs @@ -23,7 +23,8 @@ module Script.Expr (      module Script.Var, -    Regex(RegexPart, RegexString), regexMatch, +    Regex(RegexPart, RegexString), +    regexCompile, regexMatch,  ) where  import Control.Monad |