Commit 0fba9366 authored by Robert Henderson's avatar Robert Henderson
Browse files

Moved 'skipSpaces1' into a central location.

parent 89e7c506
......@@ -44,6 +44,7 @@ module Distribution.Compat.ReadP
munch, -- :: (Char -> Bool) -> ReadP String
munch1, -- :: (Char -> Bool) -> ReadP String
skipSpaces, -- :: ReadP ()
skipSpaces1,-- :: ReadP ()
choice, -- :: [ReadP a] -> ReadP a
count, -- :: Int -> ReadP a -> ReadP [a]
between, -- :: ReadP open -> ReadP close -> ReadP a -> ReadP a
......@@ -297,6 +298,11 @@ skipSpaces =
skip (c:s) | isSpace c = do _ <- get; skip s
skip _ = do return ()
skipSpaces1 :: ReadP r ()
-- ^ Like 'skipSpaces' but succeeds only if there is at least one
-- whitespace character to skip.
skipSpaces1 = satisfy isSpace >> skipSpaces
count :: Int -> ReadP r a -> ReadP r [a]
-- ^ @ count n p @ parses @n@ occurrences of @p@ in sequence. A list of
-- results is returned.
......
......@@ -766,19 +766,19 @@ instance Text UserConstraint where
where
parseConstraint pkgname =
((parse >>= return . UserConstraintVersion pkgname)
+++ (do skipSpaces1
+++ (do Parse.skipSpaces1
_ <- Parse.string "installed"
return (UserConstraintInstalled pkgname))
+++ (do skipSpaces1
+++ (do Parse.skipSpaces1
_ <- Parse.string "source"
return (UserConstraintSource pkgname))
+++ (do skipSpaces1
+++ (do Parse.skipSpaces1
_ <- Parse.string "test"
return (UserConstraintStanzas pkgname [TestStanzas]))
+++ (do skipSpaces1
+++ (do Parse.skipSpaces1
_ <- Parse.string "bench"
return (UserConstraintStanzas pkgname [BenchStanzas])))
<++ (do skipSpaces1
<++ (do Parse.skipSpaces1
flags <- parseFlagAssignment
return (UserConstraintFlags pkgname flags))
......@@ -791,7 +791,7 @@ dispFlagAssignment = Disp.hsep . map dispFlagValue
dispFlagName = Disp.text . unFlagName
parseFlagAssignment :: Parse.ReadP r FlagAssignment
parseFlagAssignment = Parse.sepBy1 parseFlagValue skipSpaces1
parseFlagAssignment = Parse.sepBy1 parseFlagValue Parse.skipSpaces1
where
parseFlagValue =
(do Parse.optional (Parse.char '+')
......@@ -808,7 +808,3 @@ parseFlagAssignment = Parse.sepBy1 parseFlagValue skipSpaces1
identChar c = isAlphaNum c || c == '_' || c == '-'
check ('-':_) = Parse.pfail
check _ = return ()
skipSpaces1 :: Parse.ReadP r ()
skipSpaces1 = Parse.satisfy isSpace >> Parse.skipSpaces
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment