Skip to content

Commit 62b2657

Browse files
committed
Fix #1 by removing check on dash in regex parser
There are no illegal occurrences of `-` in a bracket expression. Those that are separators of a range (e.g. `a-z`) are simply standing for themselves. A dash can even be an start or end point of a range, as in `[--@]`.
1 parent 6578f80 commit 62b2657

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

lib/Text/Regex/TDFA/ReadRegex.hs

+2-5
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ module Text.Regex.TDFA.ReadRegex (parseRegex) where
1111

1212
import Text.Regex.TDFA.Pattern {- all -}
1313
import Text.ParserCombinators.Parsec((<|>), (<?>),
14-
unexpected, try, runParser, many, getState, setState, CharParser, ParseError,
14+
try, runParser, many, getState, setState, CharParser, ParseError,
1515
sepBy1, option, notFollowedBy, many1, lookAhead, eof, between,
1616
string, noneOf, digit, char, anyChar)
1717

1818
import Control.Applicative (asum)
19-
import Control.Monad(liftM, when, guard)
19+
import Control.Monad (liftM, guard)
2020
import qualified Data.Set as Set(fromList)
2121

2222
-- | An element inside @[...]@, denoting a character class.
@@ -168,9 +168,6 @@ p_set_elem_range = try $ do
168168
p_set_elem_char :: P BracketElement
169169
p_set_elem_char = do
170170
c <- noneOf "]"
171-
when (c == '-') $ do
172-
atEnd <- (lookAhead (char ']') >> return True) <|> (return False)
173-
when (not atEnd) (unexpected "A dash is in the wrong place in a bracket")
174171
return (BEChar c)
175172

176173
-- | Fail when 'BracketElement' is invalid, e.g. empty range @1-0@.

0 commit comments

Comments
 (0)