Commit 377d4365 authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Use the Text Bool instance for parsing literals in conditions

Since it exactly matches what the previous condition parser did.
So we have two different ways of parsing Bool depending on
context. Sigh. Both match exactly what was done in Cabal-1.2.
parent e92d6573
......@@ -145,7 +145,7 @@ parseCondition = condOr
where
condOr = sepBy1 condAnd (oper "||") >>= return . foldl1 COr
condAnd = sepBy1 cond (oper "&&")>>= return . foldl1 CAnd
cond = sp >> (lit +++ inparens condOr +++ notCond +++ osCond
cond = sp >> (boolLiteral +++ inparens condOr +++ notCond +++ osCond
+++ archCond +++ flagCond +++ implCond )
inparens = between (ReadP.char '(' >> sp) (sp >> ReadP.char ')' >> sp)
notCond = ReadP.char '!' >> sp >> cond >>= return . CNot
......@@ -154,8 +154,7 @@ parseCondition = condOr
flagCond = string "flag" >> sp >> inparens flagIdent >>= return . Var . Flag . ConfFlag
implCond = string "impl" >> sp >> inparens implIdent >>= return . Var
ident = munch1 isIdentChar >>= return . map toLower
lit = ((string "true" <++ string "True") >> return (Lit True)) <++
((string "false" <++ string "False") >> return (Lit False))
boolLiteral = fmap Lit parse
archIdent = fmap Arch parse
osIdent = fmap OS parse
flagIdent = ident
......
......@@ -29,10 +29,10 @@ simpleParse str = case [ p | (p, s) <- Parse.readP_to_S parse str
instance Text Bool where
disp = Disp.text . show
parse = Parse.choice [ (Parse.string "true" Parse.<++
Parse.string "True") >> return True
, (Parse.string "false" Parse.<++
Parse.string "False") >> return False ]
parse = Parse.choice [ (Parse.string "True" Parse.+++
Parse.string "true") >> return True
, (Parse.string "False" Parse.+++
Parse.string "false") >> return False ]
instance Text Version where
disp (Version branch tags)
......
Supports Markdown
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