module UHC.Light.Compiler.Base.Parser2
( pModEntRel
, parsePkgKey, parsePkgKeys )
where
import UHC.Light.Compiler.Base.HsName.Builtin
import UHC.Light.Compiler.Base.Common
import UHC.Light.Compiler.Scanner.Common
import UHC.Light.Compiler.Scanner.Scanner
import UHC.Light.Compiler.Base.ParseUtils
import UHC.Light.Compiler.Base.Parser
import UU.Parsing
import UHC.Util.ParseUtils
import UHC.Util.ScanUtils
import UHC.Light.Compiler.Base.FileSearchLocation
import UHC.Light.Compiler.Module.ImportExport
import qualified Data.Set as Set
import qualified UHC.Util.Rel as Rel
import Data.Version
pPkgKey :: P PkgKey
pPkgKey = (concat <$> pList1_ng (pVarid <|> pConid <|> ("-" <$ pMINUS))) <+> pMb (pMINUS *> pVersion)
pVersion :: P Version
pVersion = (\v -> Version (map read v) []) <$> pList1Sep pDOT pInteger10
scanOptsPkgKey = defaultScanOpts {scoSpecChars = Set.fromList ".-", scoAllowFloat = False}
parsePkgKey :: String -> Maybe PkgKey
parsePkgKey = parseString scanOptsPkgKey pPkgKey
parsePkgKeys :: String -> Maybe [PkgKey]
parsePkgKeys = parseString scanOptsPkgKey (pList pPkgKey)
pModEnt :: P ModEnt
pModEnt
= (\kind occ owns -> ModEnt kind occ owns emptyRange)
<$ pOCURLY <*> pIdOccKind <* pCOMMA <*> pIdOcc
<*> pMaybe Set.empty id (Set.fromList <$ pCOMMA <* pOCURLY <*> pListSep pCOMMA pModEnt <* pCCURLY)
<* pCCURLY
pModEntRel :: P ModEntRel
pModEntRel
= Rel.fromList <$> pAssocL pDollNm pModEnt