summaryrefslogtreecommitdiff
path: root/compiler/GHC/Parser/Errors/Types.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/GHC/Parser/Errors/Types.hs')
-rw-r--r--compiler/GHC/Parser/Errors/Types.hs24
1 files changed, 24 insertions, 0 deletions
diff --git a/compiler/GHC/Parser/Errors/Types.hs b/compiler/GHC/Parser/Errors/Types.hs
index 38c54b7149..88a287d69b 100644
--- a/compiler/GHC/Parser/Errors/Types.hs
+++ b/compiler/GHC/Parser/Errors/Types.hs
@@ -15,6 +15,7 @@ import GHC.Types.Name.Occurrence (OccName)
import GHC.Types.Name.Reader
import GHC.Unit.Module.Name
import GHC.Utils.Outputable
+import GHC.Platform.ArchOS
-- The type aliases below are useful to make some type signatures a bit more
-- descriptive, like 'handleWarningsThrowErrors' in 'GHC.Driver.Main'.
@@ -22,6 +23,24 @@ import GHC.Utils.Outputable
type PsWarning = PsMessage -- /INVARIANT/: The diagnosticReason is a Warning reason
type PsError = PsMessage -- /INVARIANT/: The diagnosticReason is ErrorWithoutFlag
+{-
+Note [Messages from GHC.Parser.Header
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+We group the messages from 'GHC.Parser.Header' because we need to
+be able to pattern match on them in the driver code. This is because
+in functions like 'GHC.Driver.Pipeline.preprocess' we want to handle
+only a specific subset of parser messages, during dependency analysis,
+and having a single constructor to handle them all is handy.
+
+-}
+
+data PsHeaderMessage
+ = PsErrParseLanguagePragma
+ | PsErrUnsupportedExt !String !ArchOS
+ | PsErrParseOptionsPragma !String
+
+
data PsMessage
=
{-| An \"unknown\" message from the parser. This type constructor allows
@@ -30,6 +49,11 @@ data PsMessage
-}
forall a. (Diagnostic a, Typeable a) => PsUnknownMessage a
+ {-| A group of parser messages emitted in 'GHC.Parser.Header'.
+ See Note [Messages from GHC.Parser.Header].
+ -}
+ | PsHeaderMessage !PsHeaderMessage
+
{-| PsWarnTab is a warning (controlled by the -Wwarn-tabs flag) that occurs
when tabulations (tabs) are found within a file.