Require a bang pattern when unlifted types are where/let bound; #3182
[ghc-hetmet.git] / compiler / main / ParsePkgConf.y
index 5472abc..1e24ab4 100644 (file)
@@ -1,25 +1,26 @@
 {
-{-# OPTIONS_GHC -w #-}
+{-# OPTIONS -fno-warn-unused-binds -fno-warn-unused-matches -fno-warn-missing-signatures -fno-warn-incomplete-patterns -Wwarn #-}
 -- The above warning supression flag is a temporary kludge.
 -- While working on this module you are encouraged to remove it and fix
 -- any warnings in the module. See
---     http://hackage.haskell.org/trac/ghc/wiki/WorkingConventions#Warnings
+--     http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
 -- for details
 
 module ParsePkgConf( loadPackageConfig ) where
 
 #include "HsVersions.h"
 
+import Distribution.Package hiding ( depends )
 import PackageConfig
 import Lexer
+import Module
 import DynFlags
 import FastString
 import StringBuffer
 import ErrUtils  ( mkLocMessage )
 import SrcLoc
 import Outputable
-import Panic     ( GhcException(..) )
-import Control.Exception ( throwDyn )
+import Panic
 
 }
 
@@ -60,7 +61,7 @@ field :: { PackageConfig -> PackageConfig }
        : VARID '=' pkgid
                {% case unpackFS $1 of
                        "package"     -> return (\p -> p{package = $3})
-                       _other        -> happyError
+                       _             -> happyError
                }
 
        | VARID '=' STRING              { id }
@@ -82,42 +83,49 @@ field       :: { PackageConfig -> PackageConfig }
                -- another case of license
 
        | VARID '=' strlist             
-               {\p -> case unpackFS $1 of
-                       "exposedModules"    -> p{exposedModules    = $3}
-                       "hiddenModules"     -> p{hiddenModules     = $3}
-                       "importDirs"        -> p{importDirs        = $3}
-                       "libraryDirs"       -> p{libraryDirs       = $3}
-                       "hsLibraries"       -> p{hsLibraries       = $3}
-                       "extraLibraries"    -> p{extraLibraries    = $3}
-                       "extraGHCiLibraries"-> p{extraGHCiLibraries= $3}
-                       "includeDirs"       -> p{includeDirs       = $3}
-                       "includes"          -> p{includes          = $3}
-                       "hugsOptions"       -> p{hugsOptions       = $3}
-                       "ccOptions"         -> p{ccOptions         = $3}
-                       "ldOptions"         -> p{ldOptions         = $3}
-                       "frameworkDirs"     -> p{frameworkDirs     = $3}
-                       "frameworks"        -> p{frameworks        = $3}
-                       "haddockInterfaces" -> p{haddockInterfaces = $3}
-                       "haddockHTMLs"      -> p{haddockHTMLs      = $3}
-                       "depends"           -> p{depends = []}
-                               -- empty list only, non-empty handled below
-                       other -> p
-               }
+       {\p -> case unpackFS $1 of
+               "exposedModules"    -> p{exposedModules    = map mkModuleNameFS $3}
+               "hiddenModules"     -> p{hiddenModules     = map mkModuleNameFS $3}
+               "importDirs"        -> p{importDirs        = map unpackFS $3}
+               "libraryDirs"       -> p{libraryDirs       = map unpackFS $3}
+               "hsLibraries"       -> p{hsLibraries       = map unpackFS $3}
+               "extraLibraries"    -> p{extraLibraries    = map unpackFS $3}
+               "extraGHCiLibraries"-> p{extraGHCiLibraries= map unpackFS $3}
+               "includeDirs"       -> p{includeDirs       = map unpackFS $3}
+               "includes"          -> p{includes          = map unpackFS $3}
+               "hugsOptions"       -> p{hugsOptions       = map unpackFS $3}
+               "ccOptions"         -> p{ccOptions         = map unpackFS $3}
+               "ldOptions"         -> p{ldOptions         = map unpackFS $3}
+               "frameworkDirs"     -> p{frameworkDirs     = map unpackFS $3}
+               "frameworks"        -> p{frameworks        = map unpackFS $3}
+               "haddockInterfaces" -> p{haddockInterfaces = map unpackFS $3}
+               "haddockHTMLs"      -> p{haddockHTMLs      = map unpackFS $3}
+               "depends"           -> p{depends = []}
+                       -- empty list only, non-empty handled below
+               _ -> p
+       }
 
        | VARID '=' pkgidlist
                {% case unpackFS $1 of
                        "depends"     -> return (\p -> p{depends = $3})
-                       _other        -> happyError
+                       _             -> happyError
                }
 
 pkgid  :: { PackageIdentifier }
-       : CONID '{' VARID '=' STRING ',' VARID '=' version '}'
-                       { PackageIdentifier{ pkgName = unpackFS $5, 
-                                            pkgVersion = $9 } }
+       : CONID '{' VARID '=' CONID STRING ',' VARID '=' version '}'
+            {% case unpackFS $5 of
+               "PackageName" ->
+                   return $ PackageIdentifier {
+                                pkgName = PackageName (unpackFS $6),
+                                pkgVersion = $10
+                            }
+               _ -> happyError
+            }
 
 version :: { Version }
        : CONID '{' VARID '=' intlist ',' VARID '=' strlist '}'
-                       { Version{ versionBranch=$5, versionTags=$9 } }
+                       { Version{ versionBranch=$5, 
+                                   versionTags=map unpackFS $9 } }
 
 pkgidlist :: { [PackageIdentifier] }
        : '[' pkgids ']'                { $2 }
@@ -135,25 +143,25 @@ ints      :: { [Int] }
        : INT                           { [ fromIntegral $1 ] }
        | INT ',' ints                  { fromIntegral $1 : $3 }
 
-strlist :: { [String] }
+strlist :: { [FastString] }
         : '[' ']'                      { [] }
        | '[' strs ']'                  { $2 }
 
-strs   :: { [String] }
-       : STRING                        { [ unpackFS $1 ] }
-       | STRING ',' strs               { unpackFS $1 : $3 }
+strs   :: { [FastString] }
+       : STRING                        { [ $1 ] }
+       | STRING ',' strs               { $1 : $3 }
 
 {
 happyError :: P a
 happyError = srcParseFail
 
-loadPackageConfig :: FilePath -> IO [PackageConfig]
-loadPackageConfig conf_filename = do
+loadPackageConfig :: DynFlags -> FilePath -> IO [PackageConfig]
+loadPackageConfig dflags conf_filename = do
    buf <- hGetStringBuffer conf_filename
    let loc  = mkSrcLoc (mkFastString conf_filename) 1 0
-   case unP parse (mkPState buf loc defaultDynFlags) of
+   case unP parse (mkPState buf loc dflags) of
        PFailed span err -> 
-           throwDyn (InstallationError (showSDoc (mkLocMessage span err)))
+           ghcError (InstallationError (showSDoc (mkLocMessage span err)))
 
        POk _ pkg_details -> do
            return pkg_details