[Git][ghc/ghc][wip/az/ghc-cpp] Expose some Lexer bitmap manipulation helpers

Alan Zimmerman pushed to branch wip/az/ghc-cpp at Glasgow Haskell Compiler / GHC Commits: c88a8a4b by Alan Zimmerman at 2025-04-23T18:18:57+01:00 Expose some Lexer bitmap manipulation helpers - - - - - 1 changed file: - compiler/GHC/Parser/Lexer.x Changes: ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -73,8 +73,8 @@ module GHC.Parser.Lexer ( ExtBits(..), xtest, xunset, xset, disableHaddock, - enableGhcCpp, - ghcCppEnabled, + enableGhcCpp, ghcCppEnabled, + enableExtBit, disableExtBit, extBitEnabled, lexTokenStream, mkParensEpToks, mkParensLocs, @@ -3152,12 +3152,23 @@ disableHaddock opts = upd_bitmap (xunset HaddockBit) upd_bitmap f = opts { pExtsBitmap = f (pExtsBitmap opts) } enableGhcCpp :: ParserOpts -> ParserOpts -enableGhcCpp opts = upd_bitmap (xset GhcCppBit) +enableGhcCpp = enableExtBit GhcCppBit + +ghcCppEnabled :: ParserOpts -> Bool +ghcCppEnabled = extBitEnabled GhcCppBit + +enableExtBit :: ExtBits -> ParserOpts -> ParserOpts +enableExtBit bit opts = upd_bitmap (xset bit) where upd_bitmap f = opts { pExtsBitmap = f (pExtsBitmap opts) } -ghcCppEnabled :: ParserOpts -> Bool -ghcCppEnabled opts = xtest GhcCppBit (pExtsBitmap opts) +disableExtBit :: ExtBits -> ParserOpts -> ParserOpts +disableExtBit bit opts = upd_bitmap (xunset bit) + where + upd_bitmap f = opts { pExtsBitmap = f (pExtsBitmap opts) } + +extBitEnabled :: ExtBits -> ParserOpts -> Bool +extBitEnabled bit opts = xtest bit (pExtsBitmap opts) -- | Set parser options for parsing OPTIONS pragmas initPragState :: p -> ParserOpts -> StringBuffer -> RealSrcLoc -> PState p View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c88a8a4bb158989f999278708c9ce7cf... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c88a8a4bb158989f999278708c9ce7cf... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Alan Zimmerman (@alanz)