summaryrefslogtreecommitdiff
path: root/compiler/GHC.hs
diff options
context:
space:
mode:
authorAlfredo Di Napoli <alfredo@well-typed.com>2021-04-19 14:29:18 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-05-26 16:03:15 -0400
commitcdbce8fc22448837e53515946f16e9571e06f412 (patch)
treea07372a960e55eaeff036ed717272b47f821711b /compiler/GHC.hs
parent2023b344a7567492881745609c494a9427dc8c30 (diff)
downloadhaskell-cdbce8fc22448837e53515946f16e9571e06f412.tar.gz
Support new parser types in GHC
This commit converts the lexers and all the parser machinery to use the new parser types and diagnostics infrastructure. Furthermore, it cleans up the way the parser code was emitting hints. As a result of this systematic approach, the test output of the `InfixAppPatErr` and `T984` tests have been changed. Previously they would emit a `SuggestMissingDo` hint, but this was not at all helpful in resolving the error, and it was even confusing by just looking at the original program that triggered the errors. Update haddock submodule
Diffstat (limited to 'compiler/GHC.hs')
-rw-r--r--compiler/GHC.hs10
1 files changed, 4 insertions, 6 deletions
diff --git a/compiler/GHC.hs b/compiler/GHC.hs
index 0d515a61f6..f71caa6f15 100644
--- a/compiler/GHC.hs
+++ b/compiler/GHC.hs
@@ -330,7 +330,6 @@ import GHCi.RemoteTypes
import qualified GHC.Parser as Parser
import GHC.Parser.Lexer
import GHC.Parser.Annotation
-import GHC.Parser.Errors.Ppr
import GHC.Parser.Utils
import GHC.Iface.Load ( loadSysInterface )
@@ -1609,7 +1608,7 @@ getTokenStream mod = do
let startLoc = mkRealSrcLoc (mkFastString sourceFile) 1 1
case lexTokenStream (initParserOpts dflags) source startLoc of
POk _ ts -> return ts
- PFailed pst -> throwErrors (foldPsMessages mkParserErr (getErrorMessages pst))
+ PFailed pst -> throwErrors (GhcPsMessage <$> getErrorMessages pst)
-- | Give even more information on the source than 'getTokenStream'
-- This function allows reconstructing the source completely with
@@ -1620,7 +1619,7 @@ getRichTokenStream mod = do
let startLoc = mkRealSrcLoc (mkFastString sourceFile) 1 1
case lexTokenStream (initParserOpts dflags) source startLoc of
POk _ ts -> return $ addSourceToTokens startLoc source ts
- PFailed pst -> throwErrors (foldPsMessages mkParserErr (getErrorMessages pst))
+ PFailed pst -> throwErrors (GhcPsMessage <$> getErrorMessages pst)
-- | Given a source location and a StringBuffer corresponding to this
-- location, return a rich token stream with the source associated to the
@@ -1800,12 +1799,11 @@ parser str dflags filename =
PFailed pst ->
let (warns,errs) = getMessages pst in
- (foldPsMessages (mkParserWarn dflags) warns
- , Left (foldPsMessages mkParserErr errs))
+ (GhcPsMessage <$> warns, Left $ GhcPsMessage <$> errs)
POk pst rdr_module ->
let (warns,_) = getMessages pst in
- (foldPsMessages (mkParserWarn dflags) warns, Right rdr_module)
+ (GhcPsMessage <$> warns, Right rdr_module)
-- -----------------------------------------------------------------------------
-- | Find the package environment (if one exists)