From: Matthijs Kooijman Date: Thu, 2 Apr 2009 15:33:16 +0000 (+0200) Subject: Delete unused Parser.hs. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;ds=sidebyside;h=9fa8c2f1cf2991b720f43182b0fb4f0d59931c6e;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Delete unused Parser.hs. --- diff --git a/Parser.hs b/Parser.hs deleted file mode 100644 index 44b77eb..0000000 --- a/Parser.hs +++ /dev/null @@ -1,75 +0,0 @@ -module Main (main) where -import Language.Haskell.Syntax -import Language.Haskell.Pretty -import Language.Haskell.Parser -import GHC - -main = - do - let filename = "adder.hs" - -- Read the file - file <- readFile filename - -- Parse the file - let mode = ParseMode {parseFilename = filename} - ParseOk mod = parseModuleWithMode mode file - -- Print funky stuff - --putStr $ foldl (\s d -> s ++ (show d) ++ "\n\n") "" (decls mod) - putList (findfunc "exp_adder" (decls mod)) - -decls (HsModule _ _ _ _ decls) = - decls - -name (HsModule _ n _ _ _) = - n - -findfunc :: - String -- Function name to find - -> [HsDecl] -- Decls to search - -> [HsMatch] - -findfunc name decls = foldl (findmatches name) [] decls - --- Look at a HsDecl and add all HsMatches in it with the sought name to res -findmatches name res (HsFunBind matches) = res ++ filter (filtermatch name) matches -findmatches name res _ = res - --- Look at a single match and see if it has the sought name -filtermatch name (HsMatch _ (HsIdent n) _ _ _) = - n == name - --- Print a list of showable things, separated by newlines instead of , --- Also pretty prints them -putList :: (Show a, Pretty a) => [a] -> IO () -putList (x:xs) = - do - indent 0 (show x) - putStr "\n" - putStr $ prettyPrint x - putStr "\n\n" - putList xs - -putList [] = - do return () - --- Add indentations to the given string -indent :: Int -> String -> IO () -indent n (x:xs) = do - if x `elem` "[(" - then do - putChar x - putStr "\n" - putStr (replicate (n + 1) ' ') - indent (n + 1) xs - else if x `elem` "])" - then do - putStr "\n" - putStr (replicate (n - 1) ' ') - putChar x - indent (n - 1) xs - else do - putChar x - indent n xs - -indent n [] = do return () - --- vim: set ts=8 sw=2 sts=2 expandtab: