ghc-lib-parser-ex 9.12.0.0 → 9.14.2.0
raw patch · 6 files changed
Files
- ChangeLog.md +3/−0
- cbits/ghclib_api.h +7/−2
- ghc-lib-parser-ex.cabal +6/−6
- src/Language/Haskell/GhclibParserEx/GHC/Driver/Session.hs +13/−1
- src/Language/Haskell/GhclibParserEx/GHC/Hs/Expr.hs +26/−19
- src/Language/Haskell/GhclibParserEx/GHC/Hs/Pat.hs +12/−2
ChangeLog.md view
@@ -1,5 +1,8 @@ # Changelog for ghc-lib-parser-ex +# Unreleased+- Add support for ghc-9.14 series: `GHCLIB_API_914`+ # 9.12.0.0 released - Add support for ghc-9.12 series: `GHCLIB_API_912`
cbits/ghclib_api.h view
@@ -6,7 +6,8 @@ #if !defined(GHCLIB_API_H) # define GHCLIB_API_H -# if !(defined (GHC_9_14) \+# if !(defined (GHC_9_16) \+ || defined (GHC_9_14) \ || defined (GHC_9_12) \ || defined (GHC_9_10) \ || defined (GHC_9_8) \@@ -18,6 +19,8 @@ || defined (GHC_8_8)) # if defined (MIN_VERSION_ghc_lib_parser) # if !MIN_VERSION_ghc_lib_parser ( 1, 0, 0)+# define GHC_9_16+# elif MIN_VERSION_ghc_lib_parser (9, 14, 0) # define GHC_9_14 # elif MIN_VERSION_ghc_lib_parser (9, 12, 0) # define GHC_9_12@@ -41,7 +44,9 @@ # error Unsupported GHC API version # endif # else-# if __GLASGOW_HASKELL__ == 914+# if __GLASGOW_HASKELL__ == 916+# define GHC_9_16+# elif __GLASGOW_HASKELL__ == 914 # define GHC_9_14 # elif __GLASGOW_HASKELL__ == 912 # define GHC_9_12
ghc-lib-parser-ex.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.4 name: ghc-lib-parser-ex-version: 9.12.0.0+version: 9.14.2.0 description: Please see the README on GitHub at <https://github.com/shayne-fletcher/ghc-lib-parser-ex#readme> homepage: https://github.com/shayne-fletcher/ghc-lib-parser-ex#readme bug-reports: https://github.com/shayne-fletcher/ghc-lib-parser-ex/issues@@ -40,24 +40,24 @@ common ghc_libs include-dirs: cbits default-extensions: CPP- if flag(auto) && impl(ghc >= 9.12.0) && impl(ghc < 9.13.0)+ if flag(auto) && impl(ghc >= 9.14.0) && impl(ghc < 9.15.0) build-depends:- ghc == 9.12.*,+ ghc == 9.14.*, ghc-boot-th, ghc-boot else if flag(auto) build-depends:- ghc-lib-parser == 9.12.*+ ghc-lib-parser == 9.14.* else if flag(no-ghc-lib) build-depends:- ghc == 9.12.*,+ ghc == 9.14.*, ghc-boot-th, ghc-boot else build-depends:- ghc-lib-parser == 9.12.*+ ghc-lib-parser == 9.14.* common lib import: base, ghc_libs
src/Language/Haskell/GhclibParserEx/GHC/Driver/Session.hs view
@@ -46,6 +46,11 @@ import Data.Maybe import qualified Data.Map as Map +#if defined (GHC_9_12) || defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8)+#else+import GHC.Utils.Logger+#endif+ -- Landed in https://gitlab.haskell.org/ghc/ghc/merge_requests/2707. #if defined (GHC_8_8) || defined (GHC_8_10) import Data.Function -- For `compareOn`.@@ -194,14 +199,21 @@ let opts = getOptions flags (stringToStringBuffer str) file #elif (defined (GHC_9_12) || defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4)) let (_, opts) = getOptions (initParserOpts flags) (stringToStringBuffer str) file-#else+#elif (defined (GHC_9_14)) let (_, opts) = getOptions (initParserOpts flags) (supportedLanguagePragmas flags) (stringToStringBuffer str) file+#else+ let (_, opts) = getOptions (initParserOpts flags) (initSourceErrorContext flags) (supportedLanguagePragmas flags) (stringToStringBuffer str) file #endif -- Important : apply enables, disables *before* parsing dynamic -- file pragmas. let flags' = foldl' xopt_set flags enable let flags'' = foldl' xopt_unset flags' disable+#if defined (GHC_9_12) || defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) (flags, _, _) <- parseDynamicFilePragma flags'' opts+#else+ logger <- initLogger+ (flags, _, _) <- parseDynamicFilePragma logger flags'' opts+#endif return $ Right (flags `gopt_set` Opt_KeepRawTokenStream) where catchErrors :: IO (Either String DynFlags) -> IO (Either String DynFlags)
src/Language/Haskell/GhclibParserEx/GHC/Hs/Expr.hs view
@@ -129,7 +129,7 @@ | occNameString (rdrNameOcc x) `elem` ["Just", "Left", "Right"] -> True _ -> False #if ! ( defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )-isLCase = \case (L _ (HsLam _ LamCase _)) -> True; _ -> False+isLCase = \case (L _ (HsLam _ LamCase _)) -> True; (L _ (HsLam _ LamCases _)) -> True; _ -> False #else isLCase = \case (L _ HsLamCase{}) -> True; _ -> False #endif@@ -263,34 +263,41 @@ isTransStmt = \case TransStmt{} -> True; _ -> False -- Field has a '_' as in '{foo=_} or is punned e.g. '{foo}'.-#if ! ( defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )+#if defined (GHC_8_8) || defined (GHC_8_10) || defined (GHC_9_0) || defined (GHC_9_2)+isFieldWildcard :: LHsRecField GhcPs (LHsExpr GhcPs) -> Bool+#else -- ghc api >= 9.4.1 isFieldWildcard :: LHsFieldBind GhcPs (LFieldOcc GhcPs) (LHsExpr GhcPs) -> Bool-#else-isFieldWildcard :: LHsRecField GhcPs (LHsExpr GhcPs) -> Bool #endif isFieldWildcard = \case--#if ! ( defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )+#if defined (GHC_8_8)+ (L _ HsRecField {hsRecFieldArg=(L _ (EWildPat _))}) -> True+ (L _ HsRecField {hsRecPun=True}) -> True+ (L _ HsRecField {}) -> False+#elif defined (GHC_8_10)+ (L _ HsRecField {hsRecFieldArg=(L _ (HsUnboundVar _ _))}) -> True+ (L _ HsRecField {hsRecPun=True}) -> True+ (L _ HsRecField {}) -> False+#elif defined (GHC_9_2) || defined (GHC_9_0)+ (L _ HsRecField {hsRecFieldArg=(L _ (HsUnboundVar _ s))}) -> occNameString s == "_"+ (L _ HsRecField {hsRecPun=True}) -> True+ (L _ HsRecField {}) -> False+#elif defined (GHC_9_4)+ (L _ HsFieldBind {hfbRHS=(L _ (HsUnboundVar _ s))}) -> occNameString s == "_"+ (L _ HsFieldBind {hfbPun=True}) -> True+ (L _ HsFieldBind {}) -> False+#elif defined(GHC_9_12) || defined(GHC_9_10) || defined (GHC_9_8) || defined(GHC_9_6) -- ghc api >= ghc-9.6.1 -- Use `Language.Haskell.GhcLibParserEx.GHC.Types.Name.Reader`s `occNameStr` since `HsUnboundVar` now contains a `RdrName` not an `OccName`. (L _ HsFieldBind {hfbRHS=(L _ (HsUnboundVar _ s))}) -> occNameStr s == "_"-#elif defined (GHC_9_4)- (L _ HsFieldBind {hfbRHS=(L _ (HsUnboundVar _ s))}) -> occNameString s == "_"-#elif defined (GHC_9_2) || defined (GHC_9_0)- (L _ HsRecField {hsRecFieldArg=(L _ (HsUnboundVar _ s))}) -> occNameString s == "_"-#elif defined (GHC_8_10)- (L _ HsRecField {hsRecFieldArg=(L _ (HsUnboundVar _ _))}) -> True-#else- (L _ HsRecField {hsRecFieldArg=(L _ (EWildPat _))}) -> True-#endif-#if ! (defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )--- ghc api >= 9.4.1 (L _ HsFieldBind {hfbPun=True}) -> True (L _ HsFieldBind {}) -> False #else- (L _ HsRecField {hsRecPun=True}) -> True- (L _ HsRecField {}) -> False+-- ghc api > ghc-9.12+-- Use `Language.Haskell.GhcLibParserEx.GHC.Types.Name.Reader`s `occNameStr`. `HsHoleVar` has a `RdrName` not an `OccName`.+ (L _ HsFieldBind {hfbRHS=(L _ (HsHole(HoleVar(L _ s))))}) -> occNameStr s == "_"+ (L _ HsFieldBind {hfbPun=True}) -> True+ (L _ HsFieldBind {}) -> False #endif isUnboxed :: Boxity -> Bool
src/Language/Haskell/GhclibParserEx/GHC/Hs/Pat.hs view
@@ -57,11 +57,16 @@ patToStr (L _ (ConPat _ (L _ x) (PrefixCon []))) | occNameString (rdrNameOcc x) == "False" = "False" patToStr (L _ (ConPat _ (L _ x) (PrefixCon []))) | occNameString (rdrNameOcc x) == "[]" = "[]" patToStr _ = ""-#else+#elif defined (GHC_9_2) || defined (GHC_9_4) || defined (GHC_9_6) || defined (GHC_9_8) || defined (GHC_9_10) || defined (GHC_9_12) patToStr (L _ (ConPat _ (L _ x) (PrefixCon [] []))) | occNameString (rdrNameOcc x) == "True" = "True" patToStr (L _ (ConPat _ (L _ x) (PrefixCon [] []))) | occNameString (rdrNameOcc x) == "False" = "False" patToStr (L _ (ConPat _ (L _ x) (PrefixCon [] []))) | occNameString (rdrNameOcc x) == "[]" = "[]" patToStr _ = ""+#else+patToStr (L _ (ConPat _ (L _ x) (PrefixCon []))) | occNameString (rdrNameOcc x) == "True" = "True"+patToStr (L _ (ConPat _ (L _ x) (PrefixCon []))) | occNameString (rdrNameOcc x) == "False" = "False"+patToStr (L _ (ConPat _ (L _ x) (PrefixCon []))) | occNameString (rdrNameOcc x) == "[]" = "[]"+patToStr _ = "" #endif strToPat :: String -> LPat GhcPs@@ -82,10 +87,15 @@ | z == "False" = noLoc $ ConPat noExtField (noLoc false_RDR) (PrefixCon []) | z == "[]" = noLoc $ ConPat noExtField (noLoc $ nameRdrName nilDataConName) (PrefixCon []) | otherwise = noLoc $ VarPat noExtField (noLoc $ mkVarUnqual (fsLit z))-#else+#elif defined (GHC_9_2) || defined (GHC_9_4) || defined (GHC_9_6) || defined (GHC_9_8) || defined (GHC_9_10) || defined (GHC_9_12) | z == "True" = noLocA $ ConPat noAnn (noLocA true_RDR) (PrefixCon [] []) | z == "False" = noLocA $ ConPat noAnn (noLocA false_RDR) (PrefixCon [] []) | z == "[]" = noLocA $ ConPat noAnn (noLocA $ nameRdrName nilDataConName) (PrefixCon [] [])+ | otherwise = noLocA $ VarPat noExtField (noLocA $ mkVarUnqual (fsLit z))+#else+ | z == "True" = noLocA $ ConPat noAnn (noLocA true_RDR) (PrefixCon [])+ | z == "False" = noLocA $ ConPat noAnn (noLocA false_RDR) (PrefixCon [])+ | z == "[]" = noLocA $ ConPat noAnn (noLocA $ nameRdrName nilDataConName) (PrefixCon []) | otherwise = noLocA $ VarPat noExtField (noLocA $ mkVarUnqual (fsLit z)) #endif