From 4ff632e50313b7d2bf03a35d78ede5d8c6b8331e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Tue, 22 Apr 2025 19:50:47 +0200 Subject: Fix parsing regexes containing only a variable expansion --- src/Parser/Expr.hs | 4 +--- 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 -- cgit v1.2.3