summaryrefslogtreecommitdiff
path: root/compiler/GHC/Parser
diff options
context:
space:
mode:
authorAlan Zimmerman <alan.zimm@gmail.com>2020-10-07 20:38:36 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-10-27 14:04:26 -0400
commite3fdd4197cd9def4af40acb3753843e3e9a74d7e (patch)
treeed6c9ee717a318809be5c3a8997814f92522c0b1 /compiler/GHC/Parser
parent78b52c888a1cc68750261382e3a62fff65242016 (diff)
downloadhaskell-e3fdd4197cd9def4af40acb3753843e3e9a74d7e.tar.gz
Api Annotations: Introduce AnnPercent for HsExplicitMult
For the case foo :: a %p -> b The location of the '%' is captured, separate from the 'p'
Diffstat (limited to 'compiler/GHC/Parser')
-rw-r--r--compiler/GHC/Parser/Annotation.hs3
-rw-r--r--compiler/GHC/Parser/PostProcess.hs7
2 files changed, 6 insertions, 4 deletions
diff --git a/compiler/GHC/Parser/Annotation.hs b/compiler/GHC/Parser/Annotation.hs
index a3cbc92308..9381d591d4 100644
--- a/compiler/GHC/Parser/Annotation.hs
+++ b/compiler/GHC/Parser/Annotation.hs
@@ -301,7 +301,7 @@ data AnnKeywordId
| AnnMdo
| AnnMinus -- ^ '-'
| AnnModule
- | AnnMult -- ^ '%1'
+ | AnnPercentOne -- ^ '%1' -- for HsLinearArrow
| AnnNewtype
| AnnName -- ^ where a name loses its location in the AST, this carries it
| AnnOf
@@ -318,6 +318,7 @@ data AnnKeywordId
| AnnDollarDollar -- ^ prefix '$$' -- TemplateHaskell
| AnnPackageName
| AnnPattern
+ | AnnPercent -- ^ '%' -- for HsExplicitMult
| AnnProc
| AnnQualified
| AnnRarrow -- ^ '->'
diff --git a/compiler/GHC/Parser/PostProcess.hs b/compiler/GHC/Parser/PostProcess.hs
index 4812486d19..a4ac42d382 100644
--- a/compiler/GHC/Parser/PostProcess.hs
+++ b/compiler/GHC/Parser/PostProcess.hs
@@ -2617,9 +2617,10 @@ mkLHsOpTy x op y =
let loc = getLoc x `combineSrcSpans` getLoc op `combineSrcSpans` getLoc y
in L loc (mkHsOpTy x op y)
-mkMultTy :: IsUnicodeSyntax -> LHsType GhcPs -> HsArrow GhcPs
-mkMultTy u (L _ (HsTyLit _ (HsNumTy _ 1))) = HsLinearArrow u
-mkMultTy u t = HsExplicitMult u t
+mkMultTy :: IsUnicodeSyntax -> Located Token -> LHsType GhcPs -> (HsArrow GhcPs, AddAnn)
+mkMultTy u tok t@(L _ (HsTyLit _ (HsNumTy _ 1)))
+ = (HsLinearArrow u, AddAnn AnnPercentOne (combineLocs tok t))
+mkMultTy u tok t = (HsExplicitMult u t, AddAnn AnnPercent (getLoc tok))
-----------------------------------------------------------------------------
-- Token symbols