Commit bdeab901 authored by Alan Zimmerman's avatar Alan Zimmerman Committed by Austin Seipp

Minor tweaks to API Annotation

Summary:
Add missing Outputable instance for AnnotationComment

Update documentation

Adjust parser to capture annotations correctly

Test Plan: ./validate

Reviewers: austin

Reviewed By: austin

Subscribers: thomie, carter

Differential Revision: https://phabricator.haskell.org/D520
parent 1617a10a
......@@ -39,16 +39,16 @@ type LImportDecl name = Located (ImportDecl name)
data ImportDecl name
= ImportDecl {
ideclName :: Located ModuleName, -- ^ Module name.
ideclPkgQual :: Maybe FastString, -- ^ Package qualifier.
ideclSource :: Bool, -- ^ True <=> {-# SOURCE #-} import
ideclPkgQual :: Maybe FastString, -- ^ Package qualifier.
ideclSource :: Bool, -- ^ True <=> {-\# SOURCE \#-} import
ideclSafe :: Bool, -- ^ True => safe import
ideclQualified :: Bool, -- ^ True => qualified
ideclImplicit :: Bool, -- ^ True => implicit import (of Prelude)
ideclAs :: Maybe ModuleName, -- ^ as Module
ideclHiding :: Maybe (Bool, Located [LIE name])
}
-- ^ (True => hiding, names)
--
}
-- ^
-- 'ApiAnnotation.AnnKeywordId's
--
-- - 'ApiAnnotation.AnnImport'
......@@ -57,6 +57,7 @@ data ImportDecl name
--
-- - 'ApiAnnotation.AnnSafe','ApiAnnotation.AnnQualified',
-- 'ApiAnnotation.AnnPackageName','ApiAnnotation.AnnAs',
-- 'ApiAnnotation.AnnVal'
--
-- - 'ApiAnnotation.AnnHiding','ApiAnnotation.AnnOpen',
-- 'ApiAnnotation.AnnClose' attached
......@@ -130,10 +131,10 @@ type LIE name = Located (IE name)
data IE name
= IEVar (Located name)
-- ^ - 'ApiAnnotation.AnnKeywordId's : 'ApiAnnotation.AnnPattern',
-- 'ApiAnnotation.AnnType'
-- 'ApiAnnotation.AnnType'
| IEThingAbs name -- ^ Class/Type (can't tell)
-- - 'ApiAnnotation.AnnKeywordId's : 'ApiAnnotation.AnnPattern',
-- 'ApiAnnotation.AnnType'
-- 'ApiAnnotation.AnnType','ApiAnnotation.AnnVal'
| IEThingAll (Located name) -- ^ Class/Type plus all methods/constructors
--
-- - 'ApiAnnotation.AnnKeywordId's : 'ApiAnnotation.AnnOpen',
......
......@@ -229,6 +229,8 @@ data AnnotationComment =
-- Note: these are based on the Token versions, but the Token type is
-- defined in Lexer.x and bringing it in here would create a loop
instance Outputable AnnotationComment where
ppr x = text (show x)
-- | - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnOpen',
-- 'ApiAnnotation.AnnClose','ApiAnnotation.AnnComma',
......
......@@ -544,7 +544,7 @@ exp_doc :: { OrdList (LIE RdrName) }
-- They are built in syntax, always available
export :: { OrdList (LIE RdrName) }
: qcname_ext export_subspec {% amsu (sLL $1 $> (mkModuleImpExp $1
(snd $ unLoc $2)))
(snd $ unLoc $2)))
(fst $ unLoc $2) }
| 'module' modid {% amsu (sLL $1 $> (IEModuleContents $2))
[mj AnnModule $1] }
......@@ -565,9 +565,9 @@ qcnames :: { [Located RdrName] } -- A reversed list
qcname_ext :: { Located RdrName } -- Variable or data constructor
-- or tagged type constructor
: qcname { $1 }
| 'type' qcname {% am (mkTypeImpExp (sLL $1 $> (unLoc $2)))
(AnnType, $1) }
: qcname {% ams $1 [mj AnnVal $1] }
| 'type' qcname {% amms (mkTypeImpExp (sLL $1 $> (unLoc $2)))
[mj AnnType $1,mj AnnVal $2] }
-- Cannot pull into qcname_ext, as qcname is also used in expression.
qcname :: { Located RdrName } -- Variable or data constructor
......@@ -598,7 +598,7 @@ importdecl :: { LImportDecl RdrName }
, ideclAs = unLoc (snd $7)
, ideclHiding = unLoc $8 })
((mj AnnImport $1 : fst $2 ++ fst $3 ++ fst $4
++ fst $7) ++ (fst $5)) }
++ fst $5 ++ fst $7)) }
maybe_src :: { ([AddAnn],IsBootInterface) }
: '{-# SOURCE' '#-}' { ([mo $1,mc $2],True) }
......@@ -618,9 +618,9 @@ optqualified :: { ([AddAnn],Bool) }
| {- empty -} { ([],False) }
maybeas :: { ([AddAnn],Located (Maybe ModuleName)) }
: 'as' modid { ([mj AnnAs $1]
,sLL $1 $> (Just (unLoc $2))) }
| {- empty -} { ([],noLoc Nothing) }
: 'as' modid { ([mj AnnAs $1,mj AnnVal $2]
,sLL $1 $> (Just (unLoc $2))) }
| {- empty -} { ([],noLoc Nothing) }
maybeimpspec :: { Located (Maybe (Bool, Located [LIE RdrName])) }
: impspec { L (gl $1) (Just (unLoc $1)) }
......
......@@ -13,12 +13,16 @@
(AK AnnotationLet.hs:1:22-26 AnnOpen = [AnnotationLet.hs:1:22])
(AK AnnotationLet.hs:1:23-25 AnnVal = [AnnotationLet.hs:1:23-25])
(AK AnnotationLet.hs:4:1-32 AnnAs = [AnnotationLet.hs:4:28-29])
(AK AnnotationLet.hs:4:1-32 AnnImport = [AnnotationLet.hs:4:1-6])
(AK AnnotationLet.hs:4:1-32 AnnQualified = [AnnotationLet.hs:4:8-16])
(AK AnnotationLet.hs:4:1-32 AnnVal = [AnnotationLet.hs:4:31-32])
(AK AnnotationLet.hs:(6,1)-(10,12) AnnEqual = [AnnotationLet.hs:6:5])
(AK AnnotationLet.hs:(6,1)-(10,12) AnnFunId = [AnnotationLet.hs:6:1-3])
......
......@@ -25,12 +25,16 @@
(AK AnnotationTuple.hs:2:24-28 AnnOpen = [AnnotationTuple.hs:2:24])
(AK AnnotationTuple.hs:2:25-27 AnnVal = [AnnotationTuple.hs:2:25-27])
(AK AnnotationTuple.hs:5:1-32 AnnAs = [AnnotationTuple.hs:5:28-29])
(AK AnnotationTuple.hs:5:1-32 AnnImport = [AnnotationTuple.hs:5:1-6])
(AK AnnotationTuple.hs:5:1-32 AnnQualified = [AnnotationTuple.hs:5:8-16])
(AK AnnotationTuple.hs:5:1-32 AnnVal = [AnnotationTuple.hs:5:31-32])
(AK AnnotationTuple.hs:(7,1)-(10,14) AnnEqual = [AnnotationTuple.hs:7:5])
(AK AnnotationTuple.hs:(7,1)-(10,14) AnnFunId = [AnnotationTuple.hs:7:1-3])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment