[Git][ghc/ghc][wip/az/epa-remove-addepann-8] EPA: Remove AddEpAnn. Final removal
Alan Zimmerman (@alanz)
gitlab at gitlab.haskell.org
Sun Oct 27 11:21:55 UTC 2024
Alan Zimmerman pushed to branch wip/az/epa-remove-addepann-8 at Glasgow Haskell Compiler / GHC
Commits:
9c81da55 by Alan Zimmerman at 2024-10-27T11:20:22+00:00
EPA: Remove AddEpAnn. Final removal
There are now none left, except for in a large note/comment in
PostProcess, describing the historical transition to the
disambiguation infrastructure
- - - - -
6 changed files:
- compiler/GHC/Hs/Dump.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/Annotation.hs
- testsuite/tests/parser/should_compile/T15279.stderr
- utils/check-exact/ExactPrint.hs
- utils/check-exact/Utils.hs
Changes:
=====================================
compiler/GHC/Hs/Dump.hs
=====================================
@@ -73,7 +73,6 @@ showAstData bs ba a0 = blankLine $$ showAstData' a0
`extQ` annotationNoEpAnns
`extQ` annotationExprBracket
`extQ` annotationTypedBracket
- `extQ` addEpAnn
`extQ` epTokenOC
`extQ` epTokenCC
`extQ` epTokenInstance
@@ -270,13 +269,6 @@ showAstData bs ba a0 = blankLine $$ showAstData' a0
showAstData' d, showAstData' e]
- addEpAnn :: AddEpAnn -> SDoc
- addEpAnn (AddEpAnn a s) = case ba of
- BlankEpAnnotations -> parens
- $ text "blanked:" <+> text "AddEpAnn"
- NoBlankEpAnnotations ->
- parens $ text "AddEpAnn" <+> ppr a <+> epaLocation s
-
annotationExprBracket :: BracketAnn (EpUniToken "[|" "⟦") (EpToken "[e|") -> SDoc
annotationExprBracket = annotationBracket
=====================================
compiler/GHC/Parser.y
=====================================
@@ -2268,7 +2268,6 @@ type :: { LHsType GhcPs }
| btype '->.' ctype {% hintLinear (getLoc $2) >>
amsA' (sLL $1 $> $ HsFunTy noExtField (HsLinearArrow (EpLolly (epTok $2))) $1 $3) }
- -- [mu AnnLollyU $2] }
mult :: { Located (EpUniToken "->" "\8594" -> HsArrow GhcPs) }
: PREFIX_PERCENT atype { sLL $1 $> (mkMultTy (epTok $1) $2) }
@@ -2307,10 +2306,10 @@ tyop :: { (LocatedN RdrName, PromotionFlag) }
: qtyconop { ($1, NotPromoted) }
| tyvarop { ($1, NotPromoted) }
| SIMPLEQUOTE qconop {% do { op <- amsr (sLL $1 $> (unLoc $2))
- (NameAnnQuote (glR $1) (gl $2) [])
+ (NameAnnQuote (epTok $1) (gl $2) [])
; return (op, IsPromoted) } }
| SIMPLEQUOTE varop {% do { op <- amsr (sLL $1 $> (unLoc $2))
- (NameAnnQuote (glR $1) (gl $2) [])
+ (NameAnnQuote (epTok $1) (gl $2) [])
; return (op, IsPromoted) } }
atype :: { LHsType GhcPs }
@@ -4476,14 +4475,6 @@ in GHC.Parser.Annotation
-}
--- |Construct an AddEpAnn from the annotation keyword and the location
--- of the keyword itself
-mj :: AnnKeywordId -> Located e -> AddEpAnn
-mj !a !l = AddEpAnn a (srcSpan2e $ gl l)
-
-mjN :: AnnKeywordId -> LocatedN e -> AddEpAnn
-mjN !a !l = AddEpAnn a (srcSpan2e $ glA l)
-
msemi :: Located e -> [TrailingAnn]
msemi !l = if isZeroWidthSpan (gl l) then [] else [AddSemiAnn (srcSpan2e $ gl l)]
@@ -4493,12 +4484,6 @@ msemiA !l = if isZeroWidthSpan (gl l) then [] else [EpTok (srcSpan2e $ gl l)]
msemim :: Located e -> Maybe EpaLocation
msemim !l = if isZeroWidthSpan (gl l) then Nothing else Just (srcSpan2e $ gl l)
--- |Construct an AddEpAnn from the annotation keyword and the Located Token. If
--- the token has a unicode equivalent and this has been used, provide the
--- unicode variant of the annotation.
-mu :: AnnKeywordId -> Located Token -> AddEpAnn
-mu !a lt@(L l t) = AddEpAnn (toUnicodeAnn a lt) (srcSpan2e l)
-
-- | If the 'Token' is using its unicode variant return the unicode variant of
-- the annotation
toUnicodeAnn :: AnnKeywordId -> Located Token -> AnnKeywordId
@@ -4579,27 +4564,6 @@ amsr (L l a) an = do
!cs <- getCommentsFor l
return (L (EpAnn (spanAsAnchor l) an cs) a)
--- |Synonyms for AddEpAnn versions of AnnOpen and AnnClose
-mo,mc :: Located Token -> AddEpAnn
-mo !ll = mj AnnOpen ll
-mc !ll = mj AnnClose ll
-
-moc,mcc :: Located Token -> AddEpAnn
-moc !ll = mj AnnOpenC ll
-mcc !ll = mj AnnCloseC ll
-
-mop,mcp :: Located Token -> AddEpAnn
-mop !ll = mj AnnOpenP ll
-mcp !ll = mj AnnCloseP ll
-
-moh,mch :: Located Token -> AddEpAnn
-moh !ll = mj AnnOpenPH ll
-mch !ll = mj AnnClosePH ll
-
-mos,mcs :: Located Token -> AddEpAnn
-mos !ll = mj AnnOpenS ll
-mcs !ll = mj AnnCloseS ll
-
-- | Parse a Haskell module with Haddock comments. This is done in two steps:
--
-- * 'parseModuleNoHaddock' to build the AST
@@ -4643,10 +4607,6 @@ hsDoAnn :: EpToken "rec" -> LocatedAn t b -> AnnList (EpToken "rec")
hsDoAnn tok (L ll _)
= AnnList (Just $ spanAsAnchor (locA ll)) ListNone [] tok []
-listAsAnchor :: [LocatedAn t a] -> Located b -> EpaLocation
-listAsAnchor [] (L l _) = spanAsAnchor l
-listAsAnchor (h:_) s = spanAsAnchor (comb2 h s)
-
listAsAnchorM :: [LocatedAn t a] -> Maybe EpaLocation
listAsAnchorM [] = Nothing
listAsAnchorM (L l _:_) =
=====================================
compiler/GHC/Parser/Annotation.hs
=====================================
@@ -20,7 +20,6 @@ module GHC.Parser.Annotation (
HasE(..),
-- * In-tree Exact Print Annotations
- AddEpAnn(..),
EpaLocation, EpaLocation'(..), epaLocationRealSrcSpan,
TokenLocation(..),
DeltaPos(..), deltaPos, getDeltaLine,
@@ -477,17 +476,6 @@ instance Outputable EpaComment where
-- ---------------------------------------------------------------------
--- | Captures an annotation, storing the @'AnnKeywordId'@ and its
--- location. The parser only ever inserts @'EpaLocation'@ fields with a
--- RealSrcSpan being the original location of the annotation in the
--- source file.
--- The @'EpaLocation'@ can also store a delta position if the AST has been
--- modified and needs to be pretty printed again.
--- The usual way an 'AddEpAnn' is created is using the 'mj' ("make
--- jump") function, and then it can be inserted into the appropriate
--- annotation.
-data AddEpAnn = AddEpAnn AnnKeywordId EpaLocation deriving (Data,Eq)
-
type EpaLocation = EpaLocation' [LEpaComment]
epaToNoCommentsLocation :: EpaLocation -> NoCommentsLocation
@@ -514,9 +502,6 @@ epaLocationRealSrcSpan :: EpaLocation -> RealSrcSpan
epaLocationRealSrcSpan (EpaSpan (RealSrcSpan r _)) = r
epaLocationRealSrcSpan _ = panic "epaLocationRealSrcSpan"
-instance Outputable AddEpAnn where
- ppr (AddEpAnn kw ss) = text "AddEpAnn" <+> ppr kw <+> ppr ss
-
-- ---------------------------------------------------------------------
-- | The exact print annotations (EPAs) are kept in the HsSyn AST for
@@ -784,7 +769,7 @@ data NameAnn
-- | Used for an item with a leading @'@. The annotation for
-- unquoted item is stored in 'nann_quoted'.
| NameAnnQuote {
- nann_quote :: EpaLocation,
+ nann_quote :: EpToken "'",
nann_quoted :: SrcSpanAnnN,
nann_trailing :: [TrailingAnn]
}
@@ -1303,9 +1288,6 @@ instance NoAnn EpaLocation where
instance NoAnn AnnKeywordId where
noAnn = Annlarrowtail {- gotta pick one -}
-instance NoAnn AddEpAnn where
- noAnn = AddEpAnn noAnn noAnn
-
instance NoAnn [a] where
noAnn = []
=====================================
testsuite/tests/parser/should_compile/T15279.stderr
=====================================
@@ -8,8 +8,12 @@
(EpAnn
(EpaSpan { T15279.hs:1:1 })
(AnnsModule
- [(AddEpAnn AnnModule (EpaSpan { T15279.hs:3:1-6 }))
- ,(AddEpAnn AnnWhere (EpaSpan { T15279.hs:3:15-19 }))]
+ (NoEpTok)
+ (EpTok
+ (EpaSpan { T15279.hs:3:1-6 }))
+ (EpTok
+ (EpaSpan { T15279.hs:3:15-19 }))
+ []
[]
(Just
((,)
@@ -18,374 +22,354 @@
(EpaCommentsBalanced
[]
[]))
- (VirtualBraces
+ (EpVirtualBraces
(1))
(Nothing)
(Nothing))
(Just
(L
- (SrcSpanAnn (EpAnn
- (EpaSpan { T15279.hs:3:8-13 })
- (AnnListItem
- [])
- (EpaComments
- [])) { T15279.hs:3:8-13 })
+ (EpAnn
+ (EpaSpan { T15279.hs:3:8-13 })
+ (AnnListItem
+ [])
+ (EpaComments
+ []))
{ModuleName: T15279}))
(Nothing)
[]
[(L
- (SrcSpanAnn (EpAnn
- (EpaSpan { T15279.hs:5:1-19 })
- (AnnListItem
- [])
- (EpaComments
- [])) { T15279.hs:5:1-19 })
+ (EpAnn
+ (EpaSpan { T15279.hs:5:1-19 })
+ (AnnListItem
+ [])
+ (EpaComments
+ []))
(SigD
(NoExtField)
(TypeSig
- (EpAnn
- (EpaSpan { T15279.hs:5:1-19 })
- (AnnSig
- (AddEpAnn AnnDcolon (EpaSpan { T15279.hs:5:5-6 }))
- [])
- (EpaComments
- []))
+ (AnnSig
+ (EpUniTok
+ (EpaSpan { T15279.hs:5:5-6 })
+ (NormalSyntax))
+ (Nothing)
+ (Nothing))
[(L
- (SrcSpanAnn (EpAnn
- (EpaSpan { T15279.hs:5:1-3 })
- (NameAnnTrailing
- [])
- (EpaComments
- [])) { T15279.hs:5:1-3 })
+ (EpAnn
+ (EpaSpan { T15279.hs:5:1-3 })
+ (NameAnnTrailing
+ [])
+ (EpaComments
+ []))
(Unqual
{OccName: foo}))]
(HsWC
(NoExtField)
(L
- (SrcSpanAnn (EpAnn
- (EpaSpan { T15279.hs:5:8-19 })
- (AnnListItem
- [])
- (EpaComments
- [])) { T15279.hs:5:8-19 })
+ (EpAnn
+ (EpaSpan { T15279.hs:5:8-19 })
+ (AnnListItem
+ [])
+ (EpaComments
+ []))
(HsSig
(NoExtField)
(HsOuterImplicit
(NoExtField))
(L
- (SrcSpanAnn (EpAnn
- (EpaSpan { T15279.hs:5:8-19 })
- (AnnListItem
- [])
- (EpaComments
- [])) { T15279.hs:5:8-19 })
+ (EpAnn
+ (EpaSpan { T15279.hs:5:8-19 })
+ (AnnListItem
+ [])
+ (EpaComments
+ []))
(HsFunTy
- (EpAnn
- (EpaSpan { T15279.hs:5:8-19 })
- (NoEpAnns)
- (EpaComments
- []))
+ (NoExtField)
(HsUnrestrictedArrow
- (L
- (TokenLoc
- (EpaSpan { T15279.hs:5:13-14 }))
- (HsNormalTok)))
+ (EpUniTok
+ (EpaSpan { T15279.hs:5:13-14 })
+ (NormalSyntax)))
(L
- (SrcSpanAnn (EpAnn
- (EpaSpan { T15279.hs:5:8-11 })
- (AnnListItem
- [])
- (EpaComments
- [])) { T15279.hs:5:8-11 })
+ (EpAnn
+ (EpaSpan { T15279.hs:5:8-11 })
+ (AnnListItem
+ [])
+ (EpaComments
+ []))
(HsTyVar
- (EpAnn
- (EpaSpan { T15279.hs:5:8-11 })
- []
- (EpaComments
- []))
+ (NoEpTok)
(NotPromoted)
(L
- (SrcSpanAnn (EpAnn
- (EpaSpan { T15279.hs:5:8-11 })
- (NameAnnTrailing
- [])
- (EpaComments
- [])) { T15279.hs:5:8-11 })
+ (EpAnn
+ (EpaSpan { T15279.hs:5:8-11 })
+ (NameAnnTrailing
+ [])
+ (EpaComments
+ []))
(Unqual
{OccName: Char}))))
(L
- (SrcSpanAnn (EpAnn
- (EpaSpan { T15279.hs:5:16-19 })
- (AnnListItem
- [])
- (EpaComments
- [])) { T15279.hs:5:16-19 })
+ (EpAnn
+ (EpaSpan { T15279.hs:5:16-19 })
+ (AnnListItem
+ [])
+ (EpaComments
+ []))
(HsTyVar
- (EpAnn
- (EpaSpan { T15279.hs:5:16-19 })
- []
- (EpaComments
- []))
+ (NoEpTok)
(NotPromoted)
(L
- (SrcSpanAnn (EpAnn
- (EpaSpan { T15279.hs:5:16-19 })
- (NameAnnTrailing
- [])
- (EpaComments
- [])) { T15279.hs:5:16-19 })
+ (EpAnn
+ (EpaSpan { T15279.hs:5:16-19 })
+ (NameAnnTrailing
+ [])
+ (EpaComments
+ []))
(Unqual
{OccName: Char}))))))))))))
,(L
- (SrcSpanAnn (EpAnn
- (EpaSpan { foo:-1:-1 })
- (AnnListItem
- [])
- (EpaComments
- [])) { <combineSrcSpans: files differ> })
+ (EpAnn
+ (EpaSpan { <combineSrcSpans: files differ> })
+ (AnnListItem
+ [])
+ (EpaComments
+ []))
(ValD
(NoExtField)
(FunBind
(NoExtField)
(L
- (SrcSpanAnn (EpAnn
- (EpaSpan { T15279.hs-incl:1:1-3 })
- (NameAnnTrailing
- [])
- (EpaComments
- [])) { T15279.hs-incl:1:1-3 })
+ (EpAnn
+ (EpaSpan { T15279.hs-incl:1:1-3 })
+ (NameAnnTrailing
+ [])
+ (EpaComments
+ []))
(Unqual
{OccName: foo}))
(MG
(FromSource)
(L
- (SrcSpanAnn (EpAnn
- (EpaSpan { <combineSrcSpans: files differ> })
- (AnnList
- (Nothing)
- (Nothing)
- (Nothing)
- []
- [])
- (EpaComments
- [])) { <combineSrcSpans: files differ> })
+ (EpAnn
+ (EpaSpan { <combineSrcSpans: files differ> })
+ (AnnList
+ (Nothing)
+ (ListNone)
+ []
+ (NoEpTok)
+ [])
+ (EpaComments
+ []))
[(L
- (SrcSpanAnn (EpAnn
- (EpaSpan { T15279.hs-incl:1:1-13 })
- (AnnListItem
- [])
- (EpaComments
- [])) { T15279.hs-incl:1:1-13 })
+ (EpAnn
+ (EpaSpan { T15279.hs-incl:1:1-13 })
+ (AnnListItem
+ [])
+ (EpaComments
+ []))
(Match
- (EpAnn
- (EpaSpan { T15279.hs-incl:1:1-13 })
- []
- (EpaComments
- []))
+ (NoExtField)
(FunRhs
(L
- (SrcSpanAnn (EpAnn
- (EpaSpan { T15279.hs-incl:1:1-3 })
- (NameAnnTrailing
- [])
- (EpaComments
- [])) { T15279.hs-incl:1:1-3 })
+ (EpAnn
+ (EpaSpan { T15279.hs-incl:1:1-3 })
+ (NameAnnTrailing
+ [])
+ (EpaComments
+ []))
(Unqual
{OccName: foo}))
(Prefix)
- (NoSrcStrict))
- [(L
- (SrcSpanAnn (EpAnn
- (EpaSpan { T15279.hs-incl:1:5-7 })
- (AnnListItem
- [])
- (EpaComments
- [])) { T15279.hs-incl:1:5-7 })
- (LitPat
- (NoExtField)
- (HsChar
- (SourceText 'a')
- ('a'))))]
+ (NoSrcStrict)
+ (AnnFunRhs
+ (NoEpTok)
+ []
+ []))
+ (L
+ (EpaSpan { T15279.hs-incl:1:5-7 })
+ [(L
+ (EpAnn
+ (EpaSpan { T15279.hs-incl:1:5-7 })
+ (AnnListItem
+ [])
+ (EpaComments
+ []))
+ (LitPat
+ (NoExtField)
+ (HsChar
+ (SourceText 'a')
+ ('a'))))])
(GRHSs
(EpaComments
[])
[(L
- (SrcSpanAnn
- (EpAnn
- (EpaSpan { T15279.hs-incl:1:9-13 })
- (NoEpAnns)
- (EpaComments
- []))
- { T15279.hs-incl:1:9-13 })
+ (EpAnn
+ (EpaSpan { T15279.hs-incl:1:9-13 })
+ (NoEpAnns)
+ (EpaComments
+ []))
(GRHS
(EpAnn
(EpaSpan { T15279.hs-incl:1:9-13 })
(GrhsAnn
(Nothing)
- (AddEpAnn AnnEqual (EpaSpan { T15279.hs-incl:1:9 })))
+ (Left
+ (EpTok
+ (EpaSpan { T15279.hs-incl:1:9 }))))
(EpaComments
[]))
[]
(L
- (SrcSpanAnn (EpAnn
- (EpaSpan { T15279.hs-incl:1:11-13 })
- (AnnListItem
- [])
- (EpaComments
- [])) { T15279.hs-incl:1:11-13 })
+ (EpAnn
+ (EpaSpan { T15279.hs-incl:1:11-13 })
+ (AnnListItem
+ [])
+ (EpaComments
+ []))
(HsLit
- (EpAnn
- (EpaSpan { T15279.hs-incl:1:11-13 })
- (NoEpAnns)
- (EpaComments
- []))
+ (NoExtField)
(HsChar
(SourceText 'b')
('b'))))))]
(EmptyLocalBinds
(NoExtField)))))
,(L
- (SrcSpanAnn (EpAnn
- (EpaSpan { T15279.hs-incl:2:1-13 })
- (AnnListItem
- [])
- (EpaComments
- [])) { T15279.hs-incl:2:1-13 })
+ (EpAnn
+ (EpaSpan { T15279.hs-incl:2:1-13 })
+ (AnnListItem
+ [])
+ (EpaComments
+ []))
(Match
- (EpAnn
- (EpaSpan { T15279.hs-incl:2:1-13 })
- []
- (EpaComments
- []))
+ (NoExtField)
(FunRhs
(L
- (SrcSpanAnn (EpAnn
- (EpaSpan { T15279.hs-incl:2:1-3 })
- (NameAnnTrailing
- [])
- (EpaComments
- [])) { T15279.hs-incl:2:1-3 })
+ (EpAnn
+ (EpaSpan { T15279.hs-incl:2:1-3 })
+ (NameAnnTrailing
+ [])
+ (EpaComments
+ []))
(Unqual
{OccName: foo}))
(Prefix)
- (NoSrcStrict))
- [(L
- (SrcSpanAnn (EpAnn
- (EpaSpan { T15279.hs-incl:2:5-7 })
- (AnnListItem
- [])
- (EpaComments
- [])) { T15279.hs-incl:2:5-7 })
- (LitPat
- (NoExtField)
- (HsChar
- (SourceText 'b')
- ('b'))))]
+ (NoSrcStrict)
+ (AnnFunRhs
+ (NoEpTok)
+ []
+ []))
+ (L
+ (EpaSpan { T15279.hs-incl:2:5-7 })
+ [(L
+ (EpAnn
+ (EpaSpan { T15279.hs-incl:2:5-7 })
+ (AnnListItem
+ [])
+ (EpaComments
+ []))
+ (LitPat
+ (NoExtField)
+ (HsChar
+ (SourceText 'b')
+ ('b'))))])
(GRHSs
(EpaComments
[])
[(L
- (SrcSpanAnn
- (EpAnn
- (EpaSpan { T15279.hs-incl:2:9-13 })
- (NoEpAnns)
- (EpaComments
- []))
- { T15279.hs-incl:2:9-13 })
+ (EpAnn
+ (EpaSpan { T15279.hs-incl:2:9-13 })
+ (NoEpAnns)
+ (EpaComments
+ []))
(GRHS
(EpAnn
(EpaSpan { T15279.hs-incl:2:9-13 })
(GrhsAnn
(Nothing)
- (AddEpAnn AnnEqual (EpaSpan { T15279.hs-incl:2:9 })))
+ (Left
+ (EpTok
+ (EpaSpan { T15279.hs-incl:2:9 }))))
(EpaComments
[]))
[]
(L
- (SrcSpanAnn (EpAnn
- (EpaSpan { T15279.hs-incl:2:11-13 })
- (AnnListItem
- [])
- (EpaComments
- [])) { T15279.hs-incl:2:11-13 })
+ (EpAnn
+ (EpaSpan { T15279.hs-incl:2:11-13 })
+ (AnnListItem
+ [])
+ (EpaComments
+ []))
(HsLit
- (EpAnn
- (EpaSpan { T15279.hs-incl:2:11-13 })
- (NoEpAnns)
- (EpaComments
- []))
+ (NoExtField)
(HsChar
(SourceText 'c')
('c'))))))]
(EmptyLocalBinds
(NoExtField)))))
,(L
- (SrcSpanAnn (EpAnn
- (EpaSpan { T15279.hs:7:1-11 })
- (AnnListItem
- [])
- (EpaComments
- [])) { T15279.hs:7:1-11 })
+ (EpAnn
+ (EpaSpan { T15279.hs:7:1-11 })
+ (AnnListItem
+ [])
+ (EpaComments
+ []))
(Match
- (EpAnn
- (EpaSpan { T15279.hs:7:1-11 })
- []
- (EpaComments
- []))
+ (NoExtField)
(FunRhs
(L
- (SrcSpanAnn (EpAnn
- (EpaSpan { T15279.hs:7:1-3 })
- (NameAnnTrailing
- [])
- (EpaComments
- [])) { T15279.hs:7:1-3 })
+ (EpAnn
+ (EpaSpan { T15279.hs:7:1-3 })
+ (NameAnnTrailing
+ [])
+ (EpaComments
+ []))
(Unqual
{OccName: foo}))
(Prefix)
- (NoSrcStrict))
- [(L
- (SrcSpanAnn (EpAnn
- (EpaSpan { T15279.hs:7:5 })
- (AnnListItem
- [])
- (EpaComments
- [])) { T15279.hs:7:5 })
- (WildPat
- (NoExtField)))]
+ (NoSrcStrict)
+ (AnnFunRhs
+ (NoEpTok)
+ []
+ []))
+ (L
+ (EpaSpan { T15279.hs:7:5 })
+ [(L
+ (EpAnn
+ (EpaSpan { T15279.hs:7:5 })
+ (AnnListItem
+ [])
+ (EpaComments
+ []))
+ (WildPat
+ (NoExtField)))])
(GRHSs
(EpaComments
[])
[(L
- (SrcSpanAnn
- (EpAnn
- (EpaSpan { T15279.hs:7:7-11 })
- (NoEpAnns)
- (EpaComments
- []))
- { T15279.hs:7:7-11 })
+ (EpAnn
+ (EpaSpan { T15279.hs:7:7-11 })
+ (NoEpAnns)
+ (EpaComments
+ []))
(GRHS
(EpAnn
(EpaSpan { T15279.hs:7:7-11 })
(GrhsAnn
(Nothing)
- (AddEpAnn AnnEqual (EpaSpan { T15279.hs:7:7 })))
+ (Left
+ (EpTok
+ (EpaSpan { T15279.hs:7:7 }))))
(EpaComments
[]))
[]
(L
- (SrcSpanAnn (EpAnn
- (EpaSpan { T15279.hs:7:9-11 })
- (AnnListItem
- [])
- (EpaComments
- [])) { T15279.hs:7:9-11 })
+ (EpAnn
+ (EpaSpan { T15279.hs:7:9-11 })
+ (AnnListItem
+ [])
+ (EpaComments
+ []))
(HsLit
- (EpAnn
- (EpaSpan { T15279.hs:7:9-11 })
- (NoEpAnns)
- (EpaComments
- []))
+ (NoExtField)
(HsChar
(SourceText 'a')
('a'))))))]
=====================================
utils/check-exact/ExactPrint.hs
=====================================
@@ -264,14 +264,6 @@ instance HasTrailing EpaLocation where
trailing _ = []
setTrailing a _ = a
-instance HasTrailing AddEpAnn where
- trailing _ = []
- setTrailing a _ = a
-
-instance HasTrailing (AddEpAnn, AddEpAnn) where
- trailing _ = []
- setTrailing a _ = a
-
instance HasTrailing EpAnnSumPat where
trailing _ = []
setTrailing a _ = a
@@ -1336,11 +1328,6 @@ markEpaLocationAll :: (Monad m, Monoid w)
=> [EpaLocation] -> String -> EP w m [EpaLocation]
markEpaLocationAll locs str = mapM (\l -> printStringAtAA l str) locs
-markKwC :: (Monad m, Monoid w) => CaptureComments -> AddEpAnn -> EP w m AddEpAnn
-markKwC capture (AddEpAnn kw ss) = do
- ss' <- markKwAC capture kw ss
- return (AddEpAnn kw ss')
-
-- | This should be the main driver of the process, managing printing keywords.
-- It returns the 'EpaDelta' variant of the passed in 'EpaLocation'
markKwA :: (Monad m, Monoid w) => AnnKeywordId -> EpaLocation -> EP w m EpaLocation
@@ -3638,7 +3625,7 @@ instance ExactPrint (TyClDecl GhcPs) where
epTokensToComments AnnCloseP cps
t' <- markEpToken t
- (_anx, ltycon', tyvars',_,_) <- exactVanillaDeclHead ltycon tyvars fixity Nothing
+ (_,ltycon', tyvars',_,_) <- exactVanillaDeclHead ltycon tyvars fixity Nothing
eq' <- markEpToken eq
rhs' <- markAnnotated rhs
return (SynDecl { tcdSExt = AnnSynDecl [] [] t' eq'
@@ -3647,7 +3634,7 @@ instance ExactPrint (TyClDecl GhcPs) where
exact (DataDecl { tcdDExt = x, tcdLName = ltycon, tcdTyVars = tyvars
, tcdFixity = fixity, tcdDataDefn = defn }) = do
- (_, ltycon', tyvars', _, defn') <-
+ (_,ltycon', tyvars', _, defn') <-
exactDataDefn (exactVanillaDeclHead ltycon tyvars fixity) defn
return (DataDecl { tcdDExt = x, tcdLName = ltycon', tcdTyVars = tyvars'
, tcdFixity = fixity, tcdDataDefn = defn' })
@@ -3705,7 +3692,7 @@ instance ExactPrint (TyClDecl GhcPs) where
epTokensToComments AnnOpenP ops
epTokensToComments AnnCloseP cps
c' <- markEpToken c
- (_, lclas', tyvars',_,context') <- exactVanillaDeclHead lclas tyvars fixity context
+ (_,lclas', tyvars',_,context') <- exactVanillaDeclHead lclas tyvars fixity context
(vb', fds') <- if (null fds)
then return (vb, fds)
else do
@@ -3747,7 +3734,7 @@ instance ExactPrint (FamilyDecl GhcPs) where
epTokensToComments AnnOpenP ops
epTokensToComments AnnCloseP cps
- (_, ltycon', tyvars',_,_) <- exactVanillaDeclHead ltycon tyvars fixity Nothing
+ (_,ltycon', tyvars',_,_) <- exactVanillaDeclHead ltycon tyvars fixity Nothing
(dc', eq', result') <- exact_kind (dc, eq)
(vb', mb_inj') <-
case mb_inj of
@@ -3876,7 +3863,7 @@ exactVanillaDeclHead :: (Monad m, Monoid w)
-> LHsQTyVars GhcPs
-> LexicalFixity
-> Maybe (LHsContext GhcPs)
- -> EP w m ( [AddEpAnn]
+ -> EP w m ( () -- TO allow use in exactDataDefn
, LocatedN RdrName
, LHsQTyVars GhcPs
, (), Maybe (LHsContext GhcPs))
@@ -3904,7 +3891,7 @@ exactVanillaDeclHead thing tvs@(HsQTvs { hsq_explicit = tyvars }) fixity context
return (thing', [])
context' <- mapM markAnnotated context
(thing', tyvars') <- exact_tyvars tyvars
- return (noAnn, thing', tvs { hsq_explicit = tyvars' }, (), context')
+ return ((), thing', tvs { hsq_explicit = tyvars' }, (), context')
-- ---------------------------------------------------------------------
@@ -4222,12 +4209,12 @@ instance ExactPrint (LocatedN RdrName) where
_ -> error "ExactPrint (LocatedN RdrName)"
NameAnnCommas a commas t -> do
a0 <- markNameAdornmentO a
- commas' <- forM commas (\loc -> locFromAdd <$> markKwC NoCaptureComments (AddEpAnn AnnComma loc))
+ commas' <- forM commas (\loc -> printStringAtAAC NoCaptureComments loc ",")
a1 <- markNameAdornmentC a0
return (NameAnnCommas a1 commas' t)
NameAnnBars (o,c) bars t -> do
o' <- markEpToken o
- bars' <- forM bars (\loc -> locFromAdd <$> markKwC NoCaptureComments (AddEpAnn AnnVbar loc))
+ bars' <- forM bars (\loc -> printStringAtAAC NoCaptureComments loc "|")
c' <- markEpToken c
return (NameAnnBars (o',c') bars' t)
NameAnnOnly a t -> do
@@ -4240,7 +4227,7 @@ instance ExactPrint (LocatedN RdrName) where
return (NameAnnRArrow o' nl' c' t)
NameAnnQuote q name t -> do
debugM $ "NameAnnQuote"
- (AddEpAnn _ q') <- markKwC NoCaptureComments (AddEpAnn AnnSimpleQuote q)
+ q' <- markEpToken q
(L name' _) <- markAnnotated (L name n)
return (NameAnnQuote q' name' t)
NameAnnTrailing t -> do
@@ -4279,9 +4266,6 @@ markNameAdornmentC (NameSquare o c) = do
return (NameSquare o c')
markNameAdornmentC NameNoAdornment = return NameNoAdornment
-locFromAdd :: AddEpAnn -> EpaLocation
-locFromAdd (AddEpAnn _ loc) = loc
-
printUnicode :: (Monad m, Monoid w) => EpaLocation -> RdrName -> EP w m EpaLocation
printUnicode anc n = do
let str = case (showPprUnsafe n) of
=====================================
utils/check-exact/Utils.hs
=====================================
@@ -34,7 +34,6 @@ import GHC.Types.Name.Reader
import GHC.Types.SrcLoc
import GHC.Driver.Ppr
import GHC.Data.FastString
-import qualified GHC.Data.Strict as Strict
import GHC.Base (NonEmpty(..))
import GHC.Parser.Lexer (allocateComments)
@@ -140,13 +139,6 @@ undelta (l,_) (DifferentLine dl dc) (LayoutStartCol co) = (fl,fc)
fl = l + dl
fc = co + dc
-undeltaSpan :: RealSrcSpan -> AnnKeywordId -> DeltaPos -> AddEpAnn
-undeltaSpan anc kw dp = AddEpAnn kw (EpaSpan (RealSrcSpan sp Strict.Nothing))
- where
- (l,c) = undelta (ss2pos anc) dp (LayoutStartCol 0)
- len = length (keywordToString kw)
- sp = range2rs ((l,c),(l,c+len))
-
-- ---------------------------------------------------------------------
adjustDeltaForOffset :: LayoutStartCol -> DeltaPos -> DeltaPos
@@ -594,9 +586,6 @@ setTrailingAnnLoc (AddVbarAnn _) ss = (AddVbarAnn ss)
setTrailingAnnLoc (AddDarrowAnn _) ss = (AddDarrowAnn ss)
setTrailingAnnLoc (AddDarrowUAnn _) ss = (AddDarrowUAnn ss)
-addEpAnnLoc :: AddEpAnn -> EpaLocation
-addEpAnnLoc (AddEpAnn _ l) = l
-
-- ---------------------------------------------------------------------
type DeclsByTag a = Map.Map DeclTag [(RealSrcSpan, a)]
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9c81da559be4b6f0ccd0f6c8872fbe665b2432da
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9c81da559be4b6f0ccd0f6c8872fbe665b2432da
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20241027/f7a80bd0/attachment-0001.html>
More information about the ghc-commits
mailing list