summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorTim Chevalier <chevalier@alum.wellesley.edu>2008-09-18 09:03:49 +0000
committerTim Chevalier <chevalier@alum.wellesley.edu>2008-09-18 09:03:49 +0000
commit925f8dad0be07440b996c89dad2cc32e76ce8070 (patch)
tree55e1448daeef606f3ae283c12e1505605588e096 /utils
parent7bca8c45ee7efbdef91210fa5673570413539a45 (diff)
downloadhaskell-925f8dad0be07440b996c89dad2cc32e76ce8070.tar.gz
ext-core library: Parser fixes; make it build with the HEAD
In the ext-core parser I guess I never tested: * existential type variable bindings in case alts * empty data declarations That'll learn me!
Diffstat (limited to 'utils')
-rw-r--r--utils/ext-core/Language/Core/ParsecParser.hs17
-rw-r--r--utils/ext-core/Language/Core/Printer.hs2
-rw-r--r--utils/ext-core/Setup.lhs8
-rw-r--r--utils/ext-core/extcore.cabal4
-rw-r--r--utils/ext-core/lib/GHC_ExtCore/Makefile2
5 files changed, 21 insertions, 12 deletions
diff --git a/utils/ext-core/Language/Core/ParsecParser.hs b/utils/ext-core/Language/Core/ParsecParser.hs
index 40609e3421..ff2333c6ba 100644
--- a/utils/ext-core/Language/Core/ParsecParser.hs
+++ b/utils/ext-core/Language/Core/ParsecParser.hs
@@ -132,7 +132,7 @@ coreTbindGen sep = (parens (do
(sep >> identifier >>= (return . (\ tv -> (tv,Klifted))))
coreCdefs :: Parser [Cdef]
-coreCdefs = sepBy1 coreCdef (symbol ";")
+coreCdefs = sepBy coreCdef (symbol ";")
coreCdef :: Parser Cdef
coreCdef = do
@@ -472,14 +472,23 @@ coreAlt = conAlt <|> litAlt <|> defaultAlt
conAlt :: Parser Alt
conAlt = do
conName <- coreQualifiedCon
- tBinds <- many (parens coreAtTbind)
- whiteSpace -- necessary b/c otherwise we parse the next list as empty
- vBinds <- many (parens lambdaBind)
whiteSpace
+ (tBinds, vBinds) <- caseVarBinds
try (symbol "->")
rhs <- try coreFullExp
return $ Acon conName tBinds vBinds rhs
+caseVarBinds :: Parser ([Tbind], [Vbind])
+caseVarBinds = do
+ maybeFirstTbind <- optionMaybe coreAtTbind
+ case maybeFirstTbind of
+ Just tb -> do
+ (tbs,vbs) <- caseVarBinds
+ return (tb:tbs, vbs)
+ Nothing -> do
+ vbs <- many (parens lambdaBind)
+ return ([], vbs)
+
litAlt :: Parser Alt
litAlt = do
l <- parens coreLiteral
diff --git a/utils/ext-core/Language/Core/Printer.hs b/utils/ext-core/Language/Core/Printer.hs
index bbd8e48c32..4fef8543fa 100644
--- a/utils/ext-core/Language/Core/Printer.hs
+++ b/utils/ext-core/Language/Core/Printer.hs
@@ -1,4 +1,4 @@
-{-# OPTIONS -Werror -Wall -fno-warn-missing-signatures #-}
+{-# OPTIONS -Wall -fno-warn-missing-signatures #-}
module Language.Core.Printer where
diff --git a/utils/ext-core/Setup.lhs b/utils/ext-core/Setup.lhs
index f7706b8a4c..12d5bc5e6b 100644
--- a/utils/ext-core/Setup.lhs
+++ b/utils/ext-core/Setup.lhs
@@ -2,8 +2,8 @@
\begin{code}
{-# OPTIONS -Wall #-}
+import Control.Exception
import Control.Monad
-import Data.List
import Distribution.PackageDescription
import Distribution.Simple
import Distribution.Simple.LocalBuildInfo
@@ -16,9 +16,9 @@ import Control.Exception (try)
main :: IO ()
main = do
- let hooks = defaultUserHooks {
+ let hooks = simpleUserHooks {
buildHook = build_primitive_sources
- $ buildHook defaultUserHooks
+ $ buildHook simpleUserHooks
}
defaultMainWithHooks hooks
\end{code}
@@ -58,7 +58,7 @@ maybeUpdateFile source target = do
r <- rawSystem "cmp" ["-s" {-quiet-}, source, target]
case r of
ExitSuccess -> removeFile source
- ExitFailure _ -> do try (removeFile target); renameFile source target
+ ExitFailure _ -> do (try :: IO () -> IO (Either IOException ())) (removeFile target); renameFile source target
\end{code} \ No newline at end of file
diff --git a/utils/ext-core/extcore.cabal b/utils/ext-core/extcore.cabal
index ea3b13282c..0b62cef488 100644
--- a/utils/ext-core/extcore.cabal
+++ b/utils/ext-core/extcore.cabal
@@ -8,10 +8,10 @@ license-file: LICENSE
author: Andrew Tolmach, Tim Chevalier, The GHC Team
maintainer: chevalier@alum.wellesley.edu
stability: alpha
-build-depends: base, containers, directory, filepath, mtl, parsec, pretty
+build-depends: base, containers, directory, filepath, mtl, parsec, pretty, syb
exposed-modules: Language.Core.Check, Language.Core.Dependencies, Language.Core.Core, Language.Core.Interp, Language.Core.Overrides, Language.Core.ParsecParser, Language.Core.Prep, Language.Core.Prims, Language.Core.Printer, Language.Core.Merge, Language.Core.ElimDeadCode, Language.Core.Encoding, Language.Core.Env
other-modules: Language.Core.PrimCoercions, Language.Core.PrimEnv, Language.Core.Utils, Language.Core.CoreUtils, Language.Core.Environments
-extensions: DeriveDataTypeable PatternGuards PatternSignatures
+extensions: DeriveDataTypeable PatternGuards RankNTypes ScopedTypeVariables
ghc-options: -Wall -O2
tested-with: GHC ==6.8.2
data-files: README
diff --git a/utils/ext-core/lib/GHC_ExtCore/Makefile b/utils/ext-core/lib/GHC_ExtCore/Makefile
index 5cf65c0566..93b95a79e5 100644
--- a/utils/ext-core/lib/GHC_ExtCore/Makefile
+++ b/utils/ext-core/lib/GHC_ExtCore/Makefile
@@ -1,5 +1,5 @@
all: Handle.hs IO.hs Unicode.hs
- ../../../../compiler/ghc-inplace -c -fext-core -package-name base-extcore Handle.hs IO.hs Unicode.hs -cpp -i../
+ ghc -c -fext-core -package-name base-extcore Handle.hs IO.hs Unicode.hs -cpp -i../
clean:
rm -f *.hcr *.hi *.o