Skip to content

Commit

Permalink
Fix #1 (again) with proper test
Browse files Browse the repository at this point in the history
Ranges beginning with `-` were not recognized.

Write GHC environment files so parallel-doctest picks up correct package.
  • Loading branch information
andreasabel committed Jul 18, 2022
1 parent d1fcc58 commit 16be04c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
packages: .

write-ghc-environment-files: always
3 changes: 3 additions & 0 deletions lib/Text/Regex/TDFA.hs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ a '=~' b :: (String, String, String, [String])
>>> getAllTextMatches ("john anne yifan" =~ "[a-z]+") :: [String]
["john","anne","yifan"]
>>> getAllTextMatches ("* - . a + z" =~ "[--z]+") :: [String]
["-",".","a","z"]
@
= Feature support
Expand Down
4 changes: 2 additions & 2 deletions lib/Text/Regex/TDFA/ReadRegex.hs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ p_bracket :: P Pattern
p_bracket = (char '[') >> ( (char '^' >> p_set True) <|> (p_set False) )

p_set :: Bool -> P Pattern
p_set invert = do initial <- (option "" ((char ']' >> return "]") <|> (char '-' >> return "-")))
p_set invert = do initial <- option "" (char ']' >> return "]")
values <- if null initial then many1 p_set_elem else many p_set_elem
_ <- char ']'
ci <- char_index
Expand Down Expand Up @@ -161,7 +161,7 @@ p_set_elem_coll = liftM BEColl $

p_set_elem_range :: P BracketElement
p_set_elem_range = try $ do
start <- noneOf "]-"
start <- noneOf "]"
_ <- char '-'
end <- noneOf "]"
return $ BERange start end
Expand Down

0 comments on commit 16be04c

Please sign in to comment.