diff options
author | Vladislav Zavialov <vlad.z.4096@gmail.com> | 2019-11-12 09:22:39 +0300 |
---|---|---|
committer | Vladislav Zavialov <vlad.z.4096@gmail.com> | 2019-11-28 15:47:53 +0300 |
commit | 6985e0fc4f6fb30c1effd356d87c1a0629aa9cd0 (patch) | |
tree | 00eb27d79c8730339e39215c7306caa3ff5fd14e /testsuite/tests/ghc-api | |
parent | 6c59cc71dc20f26d5a6650b16a82faeae72f2065 (diff) | |
download | haskell-6985e0fc4f6fb30c1effd356d87c1a0629aa9cd0.tar.gz |
Factor out HsSCC/HsCoreAnn/HsTickPragma into HsPragEwip/hs-prag
This is a refactoring with no user-visible changes (except for GHC API
users). Consider the HsExpr constructors that correspond to user-written
pragmas:
HsSCC representing {-# SCC ... #-}
HsCoreAnn representing {-# CORE ... #-}
HsTickPragma representing {-# GENERATED ... #-}
We can factor them out into a separate datatype, HsPragE. It makes the
code a bit tidier, especially in the parser.
Before this patch:
hpc_annot :: { Located ( (([AddAnn],SourceText),(StringLiteral,(Int,Int),(Int,Int))),
((SourceText,SourceText),(SourceText,SourceText))
) }
After this patch:
prag_hpc :: { Located ([AddAnn], HsPragE GhcPs) }
Diffstat (limited to 'testsuite/tests/ghc-api')
-rw-r--r-- | testsuite/tests/ghc-api/annotations/stringSource.hs | 10 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/annotations/t11430.hs | 2 |
2 files changed, 8 insertions, 4 deletions
diff --git a/testsuite/tests/ghc-api/annotations/stringSource.hs b/testsuite/tests/ghc-api/annotations/stringSource.hs index 8bae838672..3d053a3d7c 100644 --- a/testsuite/tests/ghc-api/annotations/stringSource.hs +++ b/testsuite/tests/ghc-api/annotations/stringSource.hs @@ -80,11 +80,15 @@ testOneFile libdir fileName = do doCCallTarget (StaticTarget s f _ _) = [("st",[(noLoc (s,f))])] doHsExpr :: HsExpr GhcPs -> [(String,[Located (SourceText,FastString)])] - doHsExpr (HsCoreAnn _ src ss _) = [("co",[conv (noLoc ss)])] - doHsExpr (HsSCC _ src ss _) = [("sc",[conv (noLoc ss)])] - doHsExpr (HsTickPragma _ src (ss,_,_) _ss2 _) = [("tp",[conv (noLoc ss)])] + doHsExpr (HsPragE _ prag _) = doPragE prag doHsExpr _ = [] + doPragE :: HsPragE GhcPs -> [(String,[Located (SourceText,FastString)])] + doPragE (HsPragCore _ src ss) = [("co",[conv (noLoc ss)])] + doPragE (HsPragSCC _ src ss) = [("sc",[conv (noLoc ss)])] + doPragE (HsPragTick _ src (ss,_,_) _ss2) = [("tp",[conv (noLoc ss)])] + doPragE (XHsPragE x) = noExtCon x + conv (GHC.L l (StringLiteral st fs)) = GHC.L l (st,fs) showAnns anns = "[\n" ++ (intercalate "\n" diff --git a/testsuite/tests/ghc-api/annotations/t11430.hs b/testsuite/tests/ghc-api/annotations/t11430.hs index f161e601ce..4b60097a69 100644 --- a/testsuite/tests/ghc-api/annotations/t11430.hs +++ b/testsuite/tests/ghc-api/annotations/t11430.hs @@ -67,7 +67,7 @@ testOneFile libdir fileName = do doRuleDecl (HsRule _ _ _ _ _ _ _) = [] doHsExpr :: HsExpr GhcPs -> [(String,[String])] - doHsExpr (HsTickPragma _ src (_,_,_) ss _) = [("tp",[show ss])] + doHsExpr (HsPragE _ (HsPragTick _ src (_,_,_) ss) _) = [("tp",[show ss])] doHsExpr _ = [] doInline (InlinePragma _ _ _ (ActiveBefore (SourceText ss) _) _) |