diff options
author | Ian Lynagh <ian@well-typed.com> | 2012-10-09 00:27:28 +0100 |
---|---|---|
committer | Ian Lynagh <ian@well-typed.com> | 2012-10-09 12:32:04 +0100 |
commit | 0a768bcbe6f7238d0bcdddd85fe24c99189453a0 (patch) | |
tree | a1e75804cc73c1f88fb3deae9fa7aaf0aaa75753 /compiler/main/CmdLineParser.hs | |
parent | 9c6223dd780b5a41be98702a583a1b7229841305 (diff) | |
download | haskell-0a768bcbe6f7238d0bcdddd85fe24c99189453a0.tar.gz |
Make the opt_UF_* static flags dynamic
I also removed the default values from the "Discounts and thresholds"
note: most of them were no longer up-to-date.
Along the way I added FloatSuffix to the argument parser, analogous to
IntSuffix.
Diffstat (limited to 'compiler/main/CmdLineParser.hs')
-rw-r--r-- | compiler/main/CmdLineParser.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/main/CmdLineParser.hs b/compiler/main/CmdLineParser.hs index f87039a2e5..b6618af1a9 100644 --- a/compiler/main/CmdLineParser.hs +++ b/compiler/main/CmdLineParser.hs @@ -48,6 +48,7 @@ data OptKind m -- Suppose the flag is -f | OptPrefix (String -> EwM m ()) -- -f or -farg (i.e. the arg is optional) | OptIntSuffix (Maybe Int -> EwM m ()) -- -f or -f=n; pass n to fn | IntSuffix (Int -> EwM m ()) -- -f or -f=n; pass n to fn + | FloatSuffix (Float -> EwM m ()) -- -f or -f=n; pass n to fn | PassFlag (String -> EwM m ()) -- -f; pass "-f" fn | AnySuffix (String -> EwM m ()) -- -f or -farg; pass entire "-farg" to fn | PrefixPred (String -> Bool) (String -> EwM m ()) @@ -188,6 +189,9 @@ processOneArg opt_kind rest arg args IntSuffix f | Just n <- parseInt rest_no_eq -> Right (f n, args) | otherwise -> Left ("malformed integer argument in " ++ dash_arg) + FloatSuffix f | Just n <- parseFloat rest_no_eq -> Right (f n, args) + | otherwise -> Left ("malformed float argument in " ++ dash_arg) + OptPrefix f -> Right (f rest_no_eq, args) AnySuffix f -> Right (f dash_arg, args) AnySuffixPred _ f -> Right (f dash_arg, args) @@ -213,6 +217,7 @@ arg_ok (Prefix _) rest _ = notNull rest arg_ok (PrefixPred p _) rest _ = notNull rest && p (dropEq rest) arg_ok (OptIntSuffix _) _ _ = True arg_ok (IntSuffix _) _ _ = True +arg_ok (FloatSuffix _) _ _ = True arg_ok (OptPrefix _) _ _ = True arg_ok (PassFlag _) rest _ = null rest arg_ok (AnySuffix _) _ _ = True @@ -228,6 +233,11 @@ parseInt s = case reads s of ((n,""):_) -> Just n _ -> Nothing +parseFloat :: String -> Maybe Float +parseFloat s = case reads s of + ((n,""):_) -> Just n + _ -> Nothing + -- | Discards a leading equals sign dropEq :: String -> String dropEq ('=' : s) = s |