From 273aeead4ef67b4b1cf70f7f83af74c659eb1ebf Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Fri, 21 Mar 2008 14:46:28 +0000 Subject: [PATCH] Added the code to guess the frontend based on the file extension (.occ/.rain) --- Main.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Main.hs b/Main.hs index 69d65a0..91137d2 100644 --- a/Main.hs +++ b/Main.hs @@ -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