diff options
author | Alfredo Di Napoli <alfredo@well-typed.com> | 2021-04-19 14:29:18 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-05-26 16:03:15 -0400 |
commit | cdbce8fc22448837e53515946f16e9571e06f412 (patch) | |
tree | a07372a960e55eaeff036ed717272b47f821711b /utils | |
parent | 2023b344a7567492881745609c494a9427dc8c30 (diff) | |
download | haskell-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 'utils')
-rw-r--r-- | utils/check-exact/Parsers.hs | 9 | ||||
-rw-r--r-- | utils/check-exact/Preprocess.hs | 4 | ||||
m--------- | utils/haddock | 0 |
3 files changed, 5 insertions, 8 deletions
diff --git a/utils/check-exact/Parsers.hs b/utils/check-exact/Parsers.hs index 11005a05cb..4620ae3fa1 100644 --- a/utils/check-exact/Parsers.hs +++ b/utils/check-exact/Parsers.hs @@ -60,7 +60,6 @@ import qualified GHC.Parser as GHC import qualified GHC.Parser.Header as GHC import qualified GHC.Parser.Lexer as GHC import qualified GHC.Parser.PostProcess as GHC -import qualified GHC.Parser.Errors.Ppr as GHC import qualified GHC.Types.SrcLoc as GHC import qualified GHC.LanguageExtensions as LangExt @@ -77,7 +76,7 @@ parseWith :: GHC.DynFlags parseWith dflags fileName parser s = case runParser parser dflags fileName s of GHC.PFailed pst - -> Left (GHC.foldPsMessages GHC.mkParserErr (GHC.getErrorMessages pst)) + -> Left (GHC.GhcPsMessage <$> GHC.getErrorMessages pst) GHC.POk _ pmod -> Right pmod @@ -91,7 +90,7 @@ parseWithECP :: (GHC.DisambECP w) parseWithECP dflags fileName parser s = case runParser (parser >>= \p -> GHC.runPV $ GHC.unECP p) dflags fileName s of GHC.PFailed pst - -> Left (GHC.foldPsMessages GHC.mkParserErr (GHC.getErrorMessages pst)) + -> Left (GHC.GhcPsMessage <$> GHC.getErrorMessages pst) GHC.POk _ pmod -> Right pmod @@ -184,7 +183,7 @@ parseModuleFromStringInternal dflags fileName str = let (str1, lp) = stripLinePragmas str res = case runParser GHC.parseModule dflags fileName str1 of GHC.PFailed pst - -> Left (GHC.foldPsMessages GHC.mkParserErr (GHC.getErrorMessages pst)) + -> Left (GHC.GhcPsMessage <$> GHC.getErrorMessages pst) GHC.POk _ pmod -> Right (lp, dflags, pmod) in postParseTransform res @@ -257,7 +256,7 @@ parseModuleEpAnnsWithCppInternal cppOptions dflags file = do return $ case parseFile dflags' file fileContents of GHC.PFailed pst - -> Left (GHC.foldPsMessages GHC.mkParserErr (GHC.getErrorMessages pst)) + -> Left (GHC.GhcPsMessage <$> GHC.getErrorMessages pst) GHC.POk _ pmod -> Right $ (injectedComments, dflags', pmod) diff --git a/utils/check-exact/Preprocess.hs b/utils/check-exact/Preprocess.hs index 17ec766b20..245305a677 100644 --- a/utils/check-exact/Preprocess.hs +++ b/utils/check-exact/Preprocess.hs @@ -24,7 +24,6 @@ import qualified GHC.Driver.Errors.Types as GHC import qualified GHC.Driver.Phases as GHC import qualified GHC.Driver.Pipeline as GHC import qualified GHC.Fingerprint.Type as GHC -import qualified GHC.Parser.Errors.Ppr as GHC import qualified GHC.Parser.Lexer as GHC hiding (getMessages) import qualified GHC.Settings as GHC import qualified GHC.Types.Error as GHC (getMessages) @@ -280,8 +279,7 @@ parseError pst = do let -- (warns,errs) = GHC.getMessages pst dflags -- throw $ GHC.mkSrcErr (GHC.unitBag $ GHC.mkPlainErrMsg dflags sspan err) - GHC.throwErrors $ - (GHC.foldPsMessages GHC.mkParserErr (GHC.getErrorMessages pst)) + GHC.throwErrors $ (GHC.GhcPsMessage <$> GHC.getErrorMessages pst) -- --------------------------------------------------------------------- diff --git a/utils/haddock b/utils/haddock -Subproject 804254a541d800ef983df7c98426014ff94430d +Subproject 4f9088e4b04e52ca510b55a78048c9230537e44 |