X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Fparser%2FParserCoreUtils.hs;h=8f67d962396d602506804e8cf5e3a8637af9e6b8;hp=a590fb5c9338e2d54a98f33542812a4e26927b3b;hb=9176377bf7d989919fe7d27cad1f56bd9c4e7b6b;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1 diff --git a/compiler/parser/ParserCoreUtils.hs b/compiler/parser/ParserCoreUtils.hs index a590fb5..8f67d96 100644 --- a/compiler/parser/ParserCoreUtils.hs +++ b/compiler/parser/ParserCoreUtils.hs @@ -1,6 +1,7 @@ module ParserCoreUtils where -import IO +import Exception +import System.IO data ParseResult a = OkP a | FailP String type P a = String -> Int -> ParseResult a @@ -19,7 +20,7 @@ failP s s' _ = FailP (s ++ ":" ++ s') getCoreModuleName :: FilePath -> IO String getCoreModuleName fpath = - catch (do + catchIO (do h <- openFile fpath ReadMode ls <- hGetContents h let mo = findMod (words ls) @@ -30,6 +31,7 @@ getCoreModuleName fpath = (\ _ -> return "Main") where findMod [] = "Main" + -- TODO: this should just return the module name, without the package name findMod ("%module":m:_) = m findMod (_:xs) = findMod xs @@ -44,9 +46,10 @@ data Token = | TKin | TKcase | TKof - | TKcoerce + | TKcast | TKnote | TKexternal + | TKlocal | TKwild | TKoparen | TKcparen @@ -54,7 +57,9 @@ data Token = | TKcbrace | TKhash | TKeq + | TKcolon | TKcoloncolon + | TKcoloneqcolon | TKstar | TKrarrow | TKlambda