From 5418a43ee4cd394a0ed901a95c2aa4102c27a09b Mon Sep 17 00:00:00 2001 From: Phil de Joux Date: Sat, 6 Jan 2024 09:13:04 -0500 Subject: [PATCH] Add reUnknownExtension --- .../src/Distribution/Described/Extension.hs | 17 +++++++----- Cabal-syntax-docs/ghc/Main.hs | 8 +++--- doc/ghc-syntax.rst | 27 ++++++++++++------- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/Cabal-described/src/Distribution/Described/Extension.hs b/Cabal-described/src/Distribution/Described/Extension.hs index 4c5c81e46ae..7b10652244f 100644 --- a/Cabal-described/src/Distribution/Described/Extension.hs +++ b/Cabal-described/src/Distribution/Described/Extension.hs @@ -3,6 +3,7 @@ module Distribution.Described.Extension ( reEnableExtension , reKnownExtension + , reUnknownExtension , reDisableExtension , reXs -- * Extension groups @@ -38,15 +39,22 @@ import Language.Haskell.Extension instance Described Extension where describe _ = REUnion - [ RENamed "enable-extension" reKnownExtension - , RENamed "disable-extension" reDisableExtension + [ reEnableExtension + , reDisableExtension + , reUnknownExtension ] reXs :: [KnownExtension] -> GrammarRegex a reXs xs = REUnion (fromString . prettyShow <$> xs) reEnableExtension :: GrammarRegex a -reEnableExtension = "enable-extension" +reEnableExtension = RENamed "enable-known-extension" reKnownExtension + +reDisableExtension :: GrammarRegex a +reDisableExtension = REUnion ["No" <> reEnableExtension] + +reUnknownExtension :: GrammarRegex a +reUnknownExtension = RENamed "unknown-extension" RETodo reKnownExtension :: GrammarRegex a reKnownExtension = REUnion @@ -74,9 +82,6 @@ reKnownExtension = REUnion , RENamed "ungrouped-extension" $ reXs xUngrouped ] -reDisableExtension :: GrammarRegex a -reDisableExtension = REUnion ["No" <> RENamed "enable-extension" reKnownExtension] - -- The comments in the xGroup* lists are taken from the GHC User's Guide. Stop -- the formatter from rearranging them with: {- FOURMOLU_DISABLE -} diff --git a/Cabal-syntax-docs/ghc/Main.hs b/Cabal-syntax-docs/ghc/Main.hs index bc694fd3727..ae8bc71f945 100644 --- a/Cabal-syntax-docs/ghc/Main.hs +++ b/Cabal-syntax-docs/ghc/Main.hs @@ -24,10 +24,12 @@ main = do contents <- run $ Z { zGhcBuildInfoFields = biGhc , zProductions = - [ zproduction "disable-extension" reDisableExtension + [ zproduction "disable-known-extension" reDisableExtension "Disable a language extension by prepending the extension with \"No\"." - , zproduction "enable-extension" reKnownExtension - "All GHC language extensions known to cabal. There may be more and some of these may be on by default." + , zproduction "enable-known-extension" reKnownExtension + "All \"known\" language extensions. There may be more and some of these may be on by default." + , zproduction "unknown-extension" reUnknownExtension + "Any token for any unknown extension is acceptable." , zproduction "interactive-extension" (reXs xGroupInteractive) "Language Extensions related to GHC interactive." , zproduction "phase-extension" (reXs xGroupPhase) diff --git a/doc/ghc-syntax.rst b/doc/ghc-syntax.rst index 439e32303f9..22d3d547cb1 100644 --- a/doc/ghc-syntax.rst +++ b/doc/ghc-syntax.rst @@ -17,7 +17,7 @@ default-extensions .. math:: - \mathrm{optcommalist}\left\{ \mathop{\mathit{enable\text{-}extension}}\mid\mathop{\mathit{disable\text{-}extension}} \right\} + \mathrm{optcommalist}\left\{ \mathop{\mathit{enable\text{-}known\text{-}extension}}\mid\mathop{\mathord{``}\mathtt{No}\mathord{"}}\mathop{\mathit{enable\text{-}known\text{-}extension}}\mid\mathop{\mathit{unknown\text{-}extension}} \right\} .. _ghc-default-language: @@ -39,7 +39,7 @@ extensions .. math:: - \mathrm{optcommalist}\left\{ \mathop{\mathit{enable\text{-}extension}}\mid\mathop{\mathit{disable\text{-}extension}} \right\} + \mathrm{optcommalist}\left\{ \mathop{\mathit{enable\text{-}known\text{-}extension}}\mid\mathop{\mathord{``}\mathtt{No}\mathord{"}}\mathop{\mathit{enable\text{-}known\text{-}extension}}\mid\mathop{\mathit{unknown\text{-}extension}} \right\} .. _ghc-other-extensions: @@ -49,7 +49,7 @@ other-extensions .. math:: - \mathrm{optcommalist}\left\{ \mathop{\mathit{enable\text{-}extension}}\mid\mathop{\mathit{disable\text{-}extension}} \right\} + \mathrm{optcommalist}\left\{ \mathop{\mathit{enable\text{-}known\text{-}extension}}\mid\mathop{\mathord{``}\mathtt{No}\mathord{"}}\mathop{\mathit{enable\text{-}known\text{-}extension}}\mid\mathop{\mathit{unknown\text{-}extension}} \right\} .. _ghc-other-languages: @@ -77,24 +77,33 @@ users' guide on language extensions. of the ``.cabal`` file specification and shown here only as a convenience. The GHC users' guide is the place to look these up. -.. _ghc-disable-extension: +.. _ghc-disable-known-extension: -disable-extension +disable-known-extension Disable a language extension by prepending the extension with "No". .. math:: - \mathop{\mathord{``}\mathtt{No}\mathord{"}}\mathop{\mathit{enable\text{-}extension}} + \mathop{\mathord{``}\mathtt{No}\mathord{"}}\mathop{\mathit{enable\text{-}known\text{-}extension}} -.. _ghc-enable-extension: +.. _ghc-enable-known-extension: -enable-extension - All GHC language extensions known to cabal. There may be more and some of these may be on by default. +enable-known-extension + All "known" language extensions. There may be more and some of these may be on by default. .. math:: \left\{ \begin{gathered}\mathop{\mathit{interactive\text{-}extension}}\\\mathop{\mathit{phase\text{-}extension}}\\\mathop{\mathit{syntax\text{-}extension}}\\\mathop{\mathit{import\text{-}export\text{-}extension}}\\\mathop{\mathit{type\text{-}extension}}\\\mathop{\mathit{record\text{-}extension}}\\\mathop{\mathit{deriving\text{-}extension}}\\\mathop{\mathit{pattern\text{-}extension}}\\\mathop{\mathit{classes\text{-}instances\text{-}extension}}\\\mathop{\mathit{literals\text{-}extension}}\\\mathop{\mathit{constraint\text{-}extension}}\\\mathop{\mathit{type\text{-}signature\text{-}extension}}\\\mathop{\mathit{binding\text{-}generalisation\text{-}extension}}\\\mathop{\mathit{template\text{-}haskell\text{-}extension}}\\\mathop{\mathit{bang\text{-}strict\text{-}extension}}\\\mathop{\mathit{parallel\text{-}concurrent\text{-}extension}}\\\mathop{\mathit{unboxed\text{-}primitive\text{-}extension}}\\\mathop{\mathit{foreign\text{-}extension}}\\\mathop{\mathit{safe\text{-}extension}}\\\mathop{\mathit{miscellaneous\text{-}extension}}\\\mathop{\mathit{bugs\text{-}extension}}\\\mathop{\mathit{ungrouped\text{-}extension}}\end{gathered} \right\} +.. _ghc-unknown-extension: + +unknown-extension + Any token for any unknown extension is acceptable. + + .. math:: + + \mathsf{\color{red}{TODO}} + .. _ghc-interactive-extension: interactive-extension