Added the code to guess the frontend based on the file extension (.occ/.rain)

This commit is contained in:
Neil Brown 2008-03-21 14:46:28 +00:00
parent edf1060c9b
commit 273aeead4e

11
Main.hs
View File

@ -136,7 +136,16 @@ main = do
[fn] -> fn
_ -> error "Must specify a single input file"
initState <- foldl (>>=) (return emptyState) opts
-- Try to guess the filename from the extension. Since this function is
-- applied before the options are applied, it will be overriden by the
-- --frontend=x command-line option
let frontendGuess = if ".occ" `isSuffixOf` fn
then \ps -> ps {csFrontend = FrontendOccam}
else if ".rain" `isSuffixOf` fn
then \ps -> ps {csFrontend = FrontendRain}
else id
initState <- foldl (>>=) (return $ frontendGuess emptyState) opts
let operation
= case csMode initState of