From e4f1b73ad9f292a6bbeb21fee44b0ba1a7f3c33b Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Tue, 4 Aug 2020 23:34:37 +0100 Subject: ApiAnnotations; tweaks for ghc-exactprint update Remove unused ApiAnns, add one for linear arrow. Include API Annotations for trailing comma in export list. --- compiler/GHC.hs | 4 ++-- compiler/GHC/Parser.y | 22 +++++++++++----------- compiler/GHC/Parser/Annotation.hs | 5 +++-- 3 files changed, 16 insertions(+), 15 deletions(-) (limited to 'compiler') diff --git a/compiler/GHC.hs b/compiler/GHC.hs index 22ce5fac18..834748a2b0 100644 --- a/compiler/GHC.hs +++ b/compiler/GHC.hs @@ -248,7 +248,7 @@ module GHC ( srcSpanStartCol, srcSpanEndCol, -- ** Located - GenLocated(..), Located, + GenLocated(..), Located, RealLocated, -- *** Constructing Located noLoc, mkGeneralLocated, @@ -274,7 +274,7 @@ module GHC ( parser, -- * API Annotations - ApiAnns(..),AnnKeywordId(..),AnnotationComment(..), + ApiAnns(..),AnnKeywordId(..),AnnotationComment(..), ApiAnnKey, getAnnotation, getAndRemoveAnnotation, getAnnotationComments, getAndRemoveAnnotationComments, unicodeAnn, diff --git a/compiler/GHC/Parser.y b/compiler/GHC/Parser.y index aa26c655b4..94b45489e7 100644 --- a/compiler/GHC/Parser.y +++ b/compiler/GHC/Parser.y @@ -863,17 +863,17 @@ header_top_importdecls :: { [LImportDecl GhcPs] } -- The Export List maybeexports :: { (Maybe (Located [LIE GhcPs])) } - : '(' exportlist ')' {% amsL (comb2 $1 $>) [mop $1,mcp $3] >> - return (Just (sLL $1 $> (fromOL $2))) } + : '(' exportlist ')' {% amsL (comb2 $1 $>) ([mop $1,mcp $3] ++ (fst $2)) >> + return (Just (sLL $1 $> (fromOL $ snd $2))) } | {- empty -} { Nothing } -exportlist :: { OrdList (LIE GhcPs) } - : exportlist1 { $1 } - | {- empty -} { nilOL } +exportlist :: { ([AddAnn], OrdList (LIE GhcPs)) } + : exportlist1 { ([], $1) } + | {- empty -} { ([], nilOL) } -- trailing comma: - | exportlist1 ',' { $1 } - | ',' { nilOL } + | exportlist1 ',' { ([mj AnnComma $2], $1) } + | ',' { ([mj AnnComma $1], nilOL) } exportlist1 :: { OrdList (LIE GhcPs) } : exportlist1 ',' export @@ -1019,11 +1019,11 @@ maybeimpspec :: { Located (Maybe (Bool, Located [LIE GhcPs])) } impspec :: { Located (Bool, Located [LIE GhcPs]) } : '(' exportlist ')' {% ams (sLL $1 $> (False, - sLL $1 $> $ fromOL $2)) - [mop $1,mcp $3] } + sLL $1 $> $ fromOL (snd $2))) + ([mop $1,mcp $3] ++ (fst $2)) } | 'hiding' '(' exportlist ')' {% ams (sLL $1 $> (True, - sLL $1 $> $ fromOL $3)) - [mj AnnHiding $1,mop $2,mcp $4] } + sLL $1 $> $ fromOL (snd $3))) + ([mj AnnHiding $1,mop $2,mcp $4] ++ (fst $3)) } ----------------------------------------------------------------------------- -- Fixity Declarations diff --git a/compiler/GHC/Parser/Annotation.hs b/compiler/GHC/Parser/Annotation.hs index 63cb42845d..0db029ba02 100644 --- a/compiler/GHC/Parser/Annotation.hs +++ b/compiler/GHC/Parser/Annotation.hs @@ -259,6 +259,8 @@ data AnnKeywordId | AnnLarrow -- ^ '<-' | AnnLarrowU -- ^ '<-', unicode variant | AnnLet + | AnnLolly -- ^ '#->' + | AnnLollyU -- ^ '#->', unicode variant | AnnMdo | AnnMinus -- ^ '-' | AnnModule @@ -291,8 +293,6 @@ data AnnKeywordId | AnnStatic -- ^ 'static' | AnnStock | AnnThen - | AnnThIdSplice -- ^ '$' - | AnnThIdTySplice -- ^ '$$' | AnnThTyQuote -- ^ double ''' | AnnTilde -- ^ '~' | AnnType @@ -364,6 +364,7 @@ unicodeAnn AnnOpenB = AnnOpenBU unicodeAnn AnnCloseB = AnnCloseBU unicodeAnn AnnOpenEQ = AnnOpenEQU unicodeAnn AnnCloseQ = AnnCloseQU +unicodeAnn AnnLolly = AnnLollyU unicodeAnn ann = ann -- cgit v1.2.1