Skip to content

Commit b079773

Browse files
committed
Fix #1 (again) with proper test
Ranges beginning with `-` were not recognized.
1 parent d1fcc58 commit b079773

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

cabal.project

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
packages: .
2+
3+
write-ghc-environment-files: always

lib/Text/Regex/TDFA.hs

+3
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ a '=~' b :: (String, String, String, [String])
124124
>>> getAllTextMatches ("john anne yifan" =~ "[a-z]+") :: [String]
125125
["john","anne","yifan"]
126126
127+
>>> getAllTextMatches ("* - . a + z" =~ "[--z]+") :: [String]
128+
["-",".","a","z"]
129+
127130
@
128131
129132
= Feature support

lib/Text/Regex/TDFA/ReadRegex.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ p_bracket :: P Pattern
120120
p_bracket = (char '[') >> ( (char '^' >> p_set True) <|> (p_set False) )
121121

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

162162
p_set_elem_range :: P BracketElement
163163
p_set_elem_range = try $ do
164-
start <- noneOf "]-"
164+
start <- noneOf "]"
165165
_ <- char '-'
166166
end <- noneOf "]"
167167
return $ BERange start end

0 commit comments

Comments
 (0)