summaryrefslogtreecommitdiff
path: root/compiler/parser
diff options
context:
space:
mode:
authorAlan Zimmerman <alan.zimm@gmail.com>2016-11-08 21:37:48 +0200
committerAlan Zimmerman <alan.zimm@gmail.com>2016-12-07 21:31:13 +0200
commit499e43824bda967546ebf95ee33ec1f84a114a7c (patch)
tree58b313d734cfba014395ea5876db48e8400296a8 /compiler/parser
parent83d69dca896c7df1f2a36268d5b45c9283985ebf (diff)
downloadhaskell-499e43824bda967546ebf95ee33ec1f84a114a7c.tar.gz
Add HsSyn prettyprinter tests
Summary: Add prettyprinter tests, which take a file, parse it, pretty print it, re-parse the pretty printed version and then compare the original and new ASTs (ignoring locations) Updates haddock submodule to match the AST changes. There are three issues outstanding 1. Extra parens around a context are not reproduced. This will require an AST change and will be done in a separate patch. 2. Currently if an `HsTickPragma` is found, this is not pretty-printed, to prevent noise in the output. I am not sure what the desired behaviour in this case is, so have left it as before. Test Ppr047 is marked as expected fail for this. 3. Apart from in a context, the ParsedSource AST keeps all the parens from the original source. Something is happening in the renamer to remove the parens around visible type application, causing T12530 to fail, as the dumped splice decl is after the renamer. This needs to be fixed by keeping the parens, but I do not know where they are being removed. I have amended the test to pass, by removing the parens in the expected output. Test Plan: ./validate Reviewers: goldfire, mpickering, simonpj, bgamari, austin Reviewed By: simonpj, bgamari Subscribers: simonpj, goldfire, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D2752 GHC Trac Issues: #3384
Diffstat (limited to 'compiler/parser')
-rw-r--r--compiler/parser/Lexer.x103
-rw-r--r--compiler/parser/Parser.y56
-rw-r--r--compiler/parser/RdrHsSyn.hs30
3 files changed, 102 insertions, 87 deletions
diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x
index 6800fab57e..14a7cb2ffa 100644
--- a/compiler/parser/Lexer.x
+++ b/compiler/parser/Lexer.x
@@ -114,7 +114,7 @@ import DynFlags
import SrcLoc
import Module
import BasicTypes ( InlineSpec(..), RuleMatchInfo(..), FractionalLit(..),
- SourceText )
+ SourceText(..) )
-- compiler/parser
import Ctype
@@ -1126,7 +1126,7 @@ rulePrag :: Action
rulePrag span buf len = do
setExts (.|. xbit InRulePragBit)
let !src = lexemeToString buf len
- return (L span (ITrules_prag src))
+ return (L span (ITrules_prag (SourceText src)))
endPrag :: Action
endPrag span _buf _len = do
@@ -1260,13 +1260,13 @@ sym con span buf len =
!fs = lexemeToFastString buf len
-- Variations on the integral numeric literal.
-tok_integral :: (String -> Integer -> Token)
+tok_integral :: (SourceText -> Integer -> Token)
-> (Integer -> Integer)
-> Int -> Int
-> (Integer, (Char -> Int))
-> Action
tok_integral itint transint transbuf translen (radix,char_to_int) span buf len
- = return $ L span $ itint (lexemeToString buf len)
+ = return $ L span $ itint (SourceText $ lexemeToString buf len)
$! transint $ parseUnsignedInteger
(offsetBytes transbuf buf) (subtract translen len) radix char_to_int
@@ -1452,8 +1452,8 @@ lex_string_tok span buf _len = do
(AI end bufEnd) <- getInput
let
tok' = case tok of
- ITprimstring _ bs -> ITprimstring src bs
- ITstring _ s -> ITstring src s
+ ITprimstring _ bs -> ITprimstring (SourceText src) bs
+ ITstring _ s -> ITstring (SourceText src) s
_ -> panic "lex_string_tok"
src = lexemeToString buf (cur bufEnd - cur buf)
return (L (mkRealSrcSpan (realSrcSpanStart span) end) tok')
@@ -1476,11 +1476,13 @@ lex_string s = do
if any (> '\xFF') s
then failMsgP "primitive string literal must contain only characters <= \'\\xFF\'"
else let bs = unsafeMkByteString (reverse s)
- in return (ITprimstring "" bs)
+ in return (ITprimstring (SourceText (reverse s)) bs)
_other ->
- return (ITstring "" (mkFastString (reverse s)))
+ return (ITstring (SourceText (reverse s))
+ (mkFastString (reverse s)))
else
- return (ITstring "" (mkFastString (reverse s)))
+ return (ITstring (SourceText (reverse s))
+ (mkFastString (reverse s)))
Just ('\\',i)
| Just ('&',i) <- next -> do
@@ -1555,14 +1557,16 @@ finish_char_tok buf loc ch -- We've already seen the closing quote
i@(AI end bufEnd) <- getInput
let src = lexemeToString buf (cur bufEnd - cur buf)
if magicHash then do
- case alexGetChar' i of
- Just ('#',i@(AI end _)) -> do
- setInput i
- return (L (mkRealSrcSpan loc end) (ITprimchar src ch))
- _other ->
- return (L (mkRealSrcSpan loc end) (ITchar src ch))
+ case alexGetChar' i of
+ Just ('#',i@(AI end _)) -> do
+ setInput i
+ return (L (mkRealSrcSpan loc end)
+ (ITprimchar (SourceText src) ch))
+ _other ->
+ return (L (mkRealSrcSpan loc end)
+ (ITchar (SourceText src) ch))
else do
- return (L (mkRealSrcSpan loc end) (ITchar src ch))
+ return (L (mkRealSrcSpan loc end) (ITchar (SourceText src) ch))
isAny :: Char -> Bool
isAny c | c > '\x7f' = isPrint c
@@ -2713,37 +2717,46 @@ ignoredPrags = Map.fromList (map ignored pragmas)
pragmas = options_pragmas ++ ["cfiles", "contract"]
oneWordPrags = Map.fromList([
- ("rules", rulePrag),
- ("inline", strtoken (\s -> (ITinline_prag s Inline FunLike))),
- ("inlinable", strtoken (\s -> (ITinline_prag s Inlinable FunLike))),
- ("inlineable", strtoken (\s -> (ITinline_prag s Inlinable FunLike))),
- -- Spelling variant
- ("notinline", strtoken (\s -> (ITinline_prag s NoInline FunLike))),
- ("specialize", strtoken (\s -> ITspec_prag s)),
- ("source", strtoken (\s -> ITsource_prag s)),
- ("warning", strtoken (\s -> ITwarning_prag s)),
- ("deprecated", strtoken (\s -> ITdeprecated_prag s)),
- ("scc", strtoken (\s -> ITscc_prag s)),
- ("generated", strtoken (\s -> ITgenerated_prag s)),
- ("core", strtoken (\s -> ITcore_prag s)),
- ("unpack", strtoken (\s -> ITunpack_prag s)),
- ("nounpack", strtoken (\s -> ITnounpack_prag s)),
- ("ann", strtoken (\s -> ITann_prag s)),
- ("vectorize", strtoken (\s -> ITvect_prag s)),
- ("novectorize", strtoken (\s -> ITnovect_prag s)),
- ("minimal", strtoken (\s -> ITminimal_prag s)),
- ("overlaps", strtoken (\s -> IToverlaps_prag s)),
- ("overlappable", strtoken (\s -> IToverlappable_prag s)),
- ("overlapping", strtoken (\s -> IToverlapping_prag s)),
- ("incoherent", strtoken (\s -> ITincoherent_prag s)),
- ("ctype", strtoken (\s -> ITctype s))])
+ ("rules", rulePrag),
+ ("inline",
+ strtoken (\s -> (ITinline_prag (SourceText s) Inline FunLike))),
+ ("inlinable",
+ strtoken (\s -> (ITinline_prag (SourceText s) Inlinable FunLike))),
+ ("inlineable",
+ strtoken (\s -> (ITinline_prag (SourceText s) Inlinable FunLike))),
+ -- Spelling variant
+ ("notinline",
+ strtoken (\s -> (ITinline_prag (SourceText s) NoInline FunLike))),
+ ("specialize", strtoken (\s -> ITspec_prag (SourceText s))),
+ ("source", strtoken (\s -> ITsource_prag (SourceText s))),
+ ("warning", strtoken (\s -> ITwarning_prag (SourceText s))),
+ ("deprecated", strtoken (\s -> ITdeprecated_prag (SourceText s))),
+ ("scc", strtoken (\s -> ITscc_prag (SourceText s))),
+ ("generated", strtoken (\s -> ITgenerated_prag (SourceText s))),
+ ("core", strtoken (\s -> ITcore_prag (SourceText s))),
+ ("unpack", strtoken (\s -> ITunpack_prag (SourceText s))),
+ ("nounpack", strtoken (\s -> ITnounpack_prag (SourceText s))),
+ ("ann", strtoken (\s -> ITann_prag (SourceText s))),
+ ("vectorize", strtoken (\s -> ITvect_prag (SourceText s))),
+ ("novectorize", strtoken (\s -> ITnovect_prag (SourceText s))),
+ ("minimal", strtoken (\s -> ITminimal_prag (SourceText s))),
+ ("overlaps", strtoken (\s -> IToverlaps_prag (SourceText s))),
+ ("overlappable", strtoken (\s -> IToverlappable_prag (SourceText s))),
+ ("overlapping", strtoken (\s -> IToverlapping_prag (SourceText s))),
+ ("incoherent", strtoken (\s -> ITincoherent_prag (SourceText s))),
+ ("ctype", strtoken (\s -> ITctype (SourceText s)))])
twoWordPrags = Map.fromList([
- ("inline conlike", strtoken (\s -> (ITinline_prag s Inline ConLike))),
- ("notinline conlike", strtoken (\s -> (ITinline_prag s NoInline ConLike))),
- ("specialize inline", strtoken (\s -> (ITspec_inline_prag s True))),
- ("specialize notinline", strtoken (\s -> (ITspec_inline_prag s False))),
- ("vectorize scalar", strtoken (\s -> ITvect_scalar_prag s))])
+ ("inline conlike",
+ strtoken (\s -> (ITinline_prag (SourceText s) Inline ConLike))),
+ ("notinline conlike",
+ strtoken (\s -> (ITinline_prag (SourceText s) NoInline ConLike))),
+ ("specialize inline",
+ strtoken (\s -> (ITspec_inline_prag (SourceText s) True))),
+ ("specialize notinline",
+ strtoken (\s -> (ITspec_inline_prag (SourceText s) False))),
+ ("vectorize scalar",
+ strtoken (\s -> ITvect_scalar_prag (SourceText s)))])
dispatch_pragmas :: Map String Action -> Action
dispatch_pragmas prags span buf len = case Map.lookup (clean_pragma (lexemeToString buf len)) prags of
diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y
index 2c90086c56..b31ca79729 100644
--- a/compiler/parser/Parser.y
+++ b/compiler/parser/Parser.y
@@ -824,10 +824,10 @@ importdecl :: { LImportDecl RdrName }
((mj AnnImport $1 : (fst $ fst $2) ++ fst $3 ++ fst $4
++ fst $5 ++ fst $7)) }
-maybe_src :: { (([AddAnn],Maybe SourceText),IsBootInterface) }
- : '{-# SOURCE' '#-}' { (([mo $1,mc $2],Just (getSOURCE_PRAGs $1))
+maybe_src :: { (([AddAnn],SourceText),IsBootInterface) }
+ : '{-# SOURCE' '#-}' { (([mo $1,mc $2],getSOURCE_PRAGs $1)
,True) }
- | {- empty -} { (([],Nothing),False) }
+ | {- empty -} { (([],NoSourceText),False) }
maybe_safe :: { ([AddAnn],Bool) }
: 'safe' { ([mj AnnSafe $1],True) }
@@ -871,7 +871,7 @@ impspec :: { Located (Bool, Located [LIE RdrName]) }
-- Fixity Declarations
prec :: { Located (SourceText,Int) }
- : {- empty -} { noLoc ("",9) }
+ : {- empty -} { noLoc (NoSourceText,9) }
| INTEGER
{% checkPrecP (sL1 $1 (getINTEGERs $1,fromInteger (getINTEGER $1))) }
@@ -1444,11 +1444,11 @@ binds :: { Located ([AddAnn],Located (HsLocalBinds RdrName)) }
,sL1 $1 $ HsValBinds val_binds)) } }
| '{' dbinds '}' { sLL $1 $> ([moc $1,mcc $3]
- ,sL1 $2 $ HsIPBinds (IPBinds (unLoc $2)
+ ,sL1 $2 $ HsIPBinds (IPBinds (reverse $ unLoc $2)
emptyTcEvBinds)) }
| vocurly dbinds close { L (getLoc $2) ([]
- ,sL1 $2 $ HsIPBinds (IPBinds (unLoc $2)
+ ,sL1 $2 $ HsIPBinds (IPBinds (reverse $ unLoc $2)
emptyTcEvBinds)) }
@@ -1521,7 +1521,7 @@ warnings :: { OrdList (LWarnDecl RdrName) }
-- SUP: TEMPORARY HACK, not checking for `module Foo'
warning :: { OrdList (LWarnDecl RdrName) }
: namelist strings
- {% amsu (sLL $1 $> (Warning (unLoc $1) (WarningTxt (noLoc "") $ snd $ unLoc $2)))
+ {% amsu (sLL $1 $> (Warning (unLoc $1) (WarningTxt (noLoc NoSourceText) $ snd $ unLoc $2)))
(fst $ unLoc $2) }
deprecations :: { OrdList (LWarnDecl RdrName) }
@@ -1536,7 +1536,7 @@ deprecations :: { OrdList (LWarnDecl RdrName) }
-- SUP: TEMPORARY HACK, not checking for `module Foo'
deprecation :: { OrdList (LWarnDecl RdrName) }
: namelist strings
- {% amsu (sLL $1 $> $ (Warning (unLoc $1) (DeprecatedTxt (noLoc "") $ snd $ unLoc $2)))
+ {% amsu (sLL $1 $> $ (Warning (unLoc $1) (DeprecatedTxt (noLoc NoSourceText) $ snd $ unLoc $2)))
(fst $ unLoc $2) }
strings :: { Located ([AddAnn],[Located StringLiteral]) }
@@ -1601,7 +1601,7 @@ fspec :: { Located ([AddAnn]
,(L (getLoc $1)
(getStringLiteral $1), $2, mkLHsSigType $4)) }
| var '::' sigtypedoc { sLL $1 $> ([mu AnnDcolon $2]
- ,(noLoc (StringLiteral "" nilFS), $1, mkLHsSigType $3)) }
+ ,(noLoc (StringLiteral NoSourceText nilFS), $1, mkLHsSigType $3)) }
-- if the entity string is missing, it defaults to the empty string;
-- the meaning of an empty entity string depends on the calling
-- convention
@@ -1639,7 +1639,7 @@ sigtypes1 :: { (OrdList (LHsSigType RdrName)) }
-- Types
strict_mark :: { Located ([AddAnn],HsSrcBang) }
- : strictness { sL1 $1 (let (a, str) = unLoc $1 in (a, HsSrcBang Nothing NoSrcUnpack str)) }
+ : strictness { sL1 $1 (let (a, str) = unLoc $1 in (a, HsSrcBang NoSourceText NoSrcUnpack str)) }
| unpackedness { sL1 $1 (let (a, prag, unpk) = unLoc $1 in (a, HsSrcBang prag unpk NoSrcStrict)) }
| unpackedness strictness { sLL $1 $> (let { (a, prag, unpk) = unLoc $1
; (a', str) = unLoc $2 }
@@ -1651,9 +1651,9 @@ strictness :: { Located ([AddAnn], SrcStrictness) }
: '!' { sL1 $1 ([mj AnnBang $1], SrcStrict) }
| '~' { sL1 $1 ([mj AnnTilde $1], SrcLazy) }
-unpackedness :: { Located ([AddAnn], Maybe SourceText, SrcUnpackedness) }
- : '{-# UNPACK' '#-}' { sLL $1 $> ([mo $1, mc $2], Just $ getUNPACK_PRAGs $1, SrcUnpack) }
- | '{-# NOUNPACK' '#-}' { sLL $1 $> ([mo $1, mc $2], Just $ getNOUNPACK_PRAGs $1, SrcNoUnpack) }
+unpackedness :: { Located ([AddAnn], SourceText, SrcUnpackedness) }
+ : '{-# UNPACK' '#-}' { sLL $1 $> ([mo $1, mc $2], getUNPACK_PRAGs $1, SrcUnpack) }
+ | '{-# NOUNPACK' '#-}' { sLL $1 $> ([mo $1, mc $2], getNOUNPACK_PRAGs $1, SrcNoUnpack) }
-- A ctype is a for-all type
ctype :: { LHsType RdrName }
@@ -1785,8 +1785,8 @@ tyapp :: { LHsAppType RdrName }
[mj AnnSimpleQuote $1] }
atype :: { LHsType RdrName }
- : ntgtycon { sL1 $1 (HsTyVar $1) } -- Not including unit tuples
- | tyvar { sL1 $1 (HsTyVar $1) } -- (See Note [Unit tuples])
+ : ntgtycon { sL1 $1 (HsTyVar NotPromoted $1) } -- Not including unit tuples
+ | tyvar { sL1 $1 (HsTyVar NotPromoted $1) } -- (See Note [Unit tuples])
| strict_mark atype {% ams (sLL $1 $> (HsBangTy (snd $ unLoc $1) $2))
(fst $ unLoc $1) } -- Constructor sigs only
| '{' fielddecls '}' {% amms (checkRecordSyntax
@@ -1813,21 +1813,21 @@ atype :: { LHsType RdrName }
| '(' ctype '::' kind ')' {% ams (sLL $1 $> $ HsKindSig $2 $4)
[mop $1,mu AnnDcolon $3,mcp $5] }
| quasiquote { sL1 $1 (HsSpliceTy (unLoc $1) placeHolderKind) }
- | '$(' exp ')' {% ams (sLL $1 $> $ mkHsSpliceTy $2)
+ | '$(' exp ')' {% ams (sLL $1 $> $ mkHsSpliceTy HasParens $2)
[mj AnnOpenPE $1,mj AnnCloseP $3] }
- | TH_ID_SPLICE {%ams (sLL $1 $> $ mkHsSpliceTy $ sL1 $1 $ HsVar $
+ | TH_ID_SPLICE {%ams (sLL $1 $> $ mkHsSpliceTy NoParens $ sL1 $1 $ HsVar $
(sL1 $1 (mkUnqual varName (getTH_ID_SPLICE $1))))
[mj AnnThIdSplice $1] }
-- see Note [Promotion] for the followings
- | SIMPLEQUOTE qcon_nowiredlist {% ams (sLL $1 $> $ HsTyVar $2) [mj AnnSimpleQuote $1,mj AnnName $2] }
+ | SIMPLEQUOTE qcon_nowiredlist {% ams (sLL $1 $> $ HsTyVar Promoted $2) [mj AnnSimpleQuote $1,mj AnnName $2] }
| SIMPLEQUOTE '(' ctype ',' comma_types1 ')'
{% addAnnotation (gl $3) AnnComma (gl $4) >>
ams (sLL $1 $> $ HsExplicitTupleTy [] ($3 : $5))
[mj AnnSimpleQuote $1,mop $2,mcp $6] }
- | SIMPLEQUOTE '[' comma_types0 ']' {% ams (sLL $1 $> $ HsExplicitListTy
+ | SIMPLEQUOTE '[' comma_types0 ']' {% ams (sLL $1 $> $ HsExplicitListTy Promoted
placeHolderKind $3)
[mj AnnSimpleQuote $1,mos $2,mcs $4] }
- | SIMPLEQUOTE var {% ams (sLL $1 $> $ HsTyVar $2)
+ | SIMPLEQUOTE var {% ams (sLL $1 $> $ HsTyVar Promoted $2)
[mj AnnSimpleQuote $1,mj AnnName $2] }
-- Two or more [ty, ty, ty] must be a promoted list type, just as
@@ -1836,7 +1836,7 @@ atype :: { LHsType RdrName }
-- so you have to quote those.)
| '[' ctype ',' comma_types1 ']' {% addAnnotation (gl $2) AnnComma
(gl $3) >>
- ams (sLL $1 $> $ HsExplicitListTy
+ ams (sLL $1 $> $ HsExplicitListTy NotPromoted
placeHolderKind ($2 : $4))
[mos $1,mcs $5] }
| INTEGER { sLL $1 $> $ HsTyLit $ HsNumTy (getINTEGERs $1)
@@ -2362,7 +2362,7 @@ scc_annot :: { Located (([AddAnn],SourceText),StringLiteral) }
,mc $3],getSCC_PRAGs $1),(StringLiteral (getSTRINGs $2) scc)) }
| '{-# SCC' VARID '#-}' { sLL $1 $> (([mo $1,mj AnnVal $2
,mc $3],getSCC_PRAGs $1)
- ,(StringLiteral (unpackFS $ getVARID $2) (getVARID $2))) }
+ ,(StringLiteral NoSourceText (getVARID $2))) }
hpc_annot :: { Located ( (([AddAnn],SourceText),(StringLiteral,(Int,Int),(Int,Int))),
((SourceText,SourceText),(SourceText,SourceText))
@@ -2471,17 +2471,17 @@ aexp2 :: { LHsExpr RdrName }
[mo $1,mc $4] }
splice_exp :: { LHsExpr RdrName }
- : TH_ID_SPLICE {% ams (sL1 $1 $ mkHsSpliceE
+ : TH_ID_SPLICE {% ams (sL1 $1 $ mkHsSpliceE NoParens
(sL1 $1 $ HsVar (sL1 $1 (mkUnqual varName
(getTH_ID_SPLICE $1)))))
[mj AnnThIdSplice $1] }
- | '$(' exp ')' {% ams (sLL $1 $> $ mkHsSpliceE $2)
+ | '$(' exp ')' {% ams (sLL $1 $> $ mkHsSpliceE HasParens $2)
[mj AnnOpenPE $1,mj AnnCloseP $3] }
- | TH_ID_TY_SPLICE {% ams (sL1 $1 $ mkHsSpliceTE
+ | TH_ID_TY_SPLICE {% ams (sL1 $1 $ mkHsSpliceTE NoParens
(sL1 $1 $ HsVar (sL1 $1 (mkUnqual varName
(getTH_ID_TY_SPLICE $1)))))
[mj AnnThIdTySplice $1] }
- | '$$(' exp ')' {% ams (sLL $1 $> $ mkHsSpliceTE $2)
+ | '$$(' exp ')' {% ams (sLL $1 $> $ mkHsSpliceTE HasParens $2)
[mj AnnOpenPTE $1,mj AnnCloseP $3] }
cmdargs :: { [LHsCmdTop RdrName] }
@@ -3046,8 +3046,8 @@ qtycon :: { Located RdrName } -- Qualified or unqualified
| tycon { $1 }
qtycondoc :: { LHsType RdrName } -- Qualified or unqualified
- : qtycon { sL1 $1 (HsTyVar $1) }
- | qtycon docprev { sLL $1 $> (HsDocTy (sL1 $1 (HsTyVar $1)) $2) }
+ : qtycon { sL1 $1 (HsTyVar NotPromoted $1) }
+ | qtycon docprev { sLL $1 $> (HsDocTy (sL1 $1 (HsTyVar NotPromoted $1)) $2) }
tycon :: { Located RdrName } -- Unqualified
: CONID { sL1 $1 $! mkUnqual tcClsName (getCONID $1) }
diff --git a/compiler/parser/RdrHsSyn.hs b/compiler/parser/RdrHsSyn.hs
index ab5708e51d..d964cc2469 100644
--- a/compiler/parser/RdrHsSyn.hs
+++ b/compiler/parser/RdrHsSyn.hs
@@ -281,7 +281,7 @@ mkSpliceDecl lexpr@(L loc expr)
= SpliceD (SpliceDecl (L loc splice) ExplicitSplice)
| otherwise
- = SpliceD (SpliceDecl (L loc (mkUntypedSplice lexpr)) ImplicitSplice)
+ = SpliceD (SpliceDecl (L loc (mkUntypedSplice NoParens lexpr)) ImplicitSplice)
mkRoleAnnotDecl :: SrcSpan
-> Located RdrName -- type being annotated
@@ -465,8 +465,8 @@ splitCon ty
where
-- This is used somewhere where HsAppsTy is not used
split (L _ (HsAppTy t u)) ts = split t (u : ts)
- split (L l (HsTyVar (L _ tc))) ts = do data_con <- tyConToDataCon l tc
- return (data_con, mk_rest ts)
+ split (L l (HsTyVar _ (L _ tc))) ts = do data_con <- tyConToDataCon l tc
+ return (data_con, mk_rest ts)
split (L l (HsTupleTy HsBoxedOrConstraintTuple ts)) []
= return (L l (getRdrName (tupleDataCon Boxed (length ts))), PrefixCon ts)
split (L l _) _ = parseErrorSDoc l (text "Cannot parse data constructor in a data/newtype declaration:" <+> ppr ty)
@@ -681,9 +681,9 @@ checkTyVars pp_what equals_or_where tc tparms
-- Check that the name space is correct!
chk (L l (HsKindSig
- (L _ (HsAppsTy [L _ (HsAppPrefix (L lv (HsTyVar (L _ tv))))])) k))
+ (L _ (HsAppsTy [L _ (HsAppPrefix (L lv (HsTyVar _ (L _ tv))))])) k))
| isRdrTyVar tv = return (L l (KindedTyVar (L lv tv) k))
- chk (L l (HsTyVar (L ltv tv)))
+ chk (L l (HsTyVar _ (L ltv tv)))
| isRdrTyVar tv = return (L l (UserTyVar (L ltv tv)))
chk t@(L loc _)
= Left (loc,
@@ -732,7 +732,7 @@ checkTyClHdr is_cls ty
where
goL (L l ty) acc ann = go l ty acc ann
- go l (HsTyVar (L _ tc)) acc ann
+ go l (HsTyVar _ (L _ tc)) acc ann
| isRdrTc tc = return (L l tc, acc, ann)
go _ (HsOpTy t1 ltc@(L _ tc) t2) acc ann
| isRdrTc tc = return (ltc, t1:t2:acc, ann)
@@ -1088,7 +1088,8 @@ isFunLhs e = go e [] []
splitTilde :: LHsType RdrName -> P (LHsType RdrName)
splitTilde t = go t
where go (L loc (HsAppTy t1 t2))
- | L lo (HsBangTy (HsSrcBang Nothing NoSrcUnpack SrcLazy) t2') <- t2
+ | L lo (HsBangTy (HsSrcBang NoSourceText NoSrcUnpack SrcLazy) t2')
+ <- t2
= do
moveAnnotations lo loc
t1' <- go t1
@@ -1116,7 +1117,7 @@ splitTildeApps (t : rest) = do
return (t : rest')
where go (L l (HsAppPrefix
(L loc (HsBangTy
- (HsSrcBang Nothing NoSrcUnpack SrcLazy)
+ (HsSrcBang NoSourceText NoSrcUnpack SrcLazy)
ty))))
= addAnnotation l AnnTilde tilde_loc >>
return
@@ -1160,7 +1161,7 @@ checkCmd :: SrcSpan -> HsExpr RdrName -> P (HsCmd RdrName)
checkCmd _ (HsArrApp e1 e2 ptt haat b) =
return $ HsCmdArrApp e1 e2 ptt haat b
checkCmd _ (HsArrForm e mf args) =
- return $ HsCmdArrForm e mf args
+ return $ HsCmdArrForm e Prefix mf args
checkCmd _ (HsApp e1 e2) =
checkCommand e1 >>= (\c -> return $ HsCmdApp c e2)
checkCmd _ (HsLam mg) =
@@ -1184,7 +1185,7 @@ checkCmd _ (OpApp eLeft op _fixity eRight) = do
c2 <- checkCommand eRight
let arg1 = L (getLoc c1) $ HsCmdTop c1 placeHolderType placeHolderType []
arg2 = L (getLoc c2) $ HsCmdTop c2 placeHolderType placeHolderType []
- return $ HsCmdArrForm op Nothing [arg1, arg2]
+ return $ HsCmdArrForm op Infix Nothing [arg1, arg2]
checkCmd l e = cmdFail l e
@@ -1274,7 +1275,7 @@ mk_rec_upd_field :: HsRecField RdrName (LHsExpr RdrName) -> HsRecUpdField RdrNam
mk_rec_upd_field (HsRecField (L loc (FieldOcc rdr _)) arg pun)
= HsRecField (L loc (Unambiguous rdr PlaceHolder)) arg pun
-mkInlinePragma :: String -> (InlineSpec, RuleMatchInfo) -> Maybe Activation
+mkInlinePragma :: SourceText -> (InlineSpec, RuleMatchInfo) -> Maybe Activation
-> InlinePragma
-- The (Maybe Activation) is because the user can omit
-- the activation spec (and usually does)
@@ -1357,7 +1358,8 @@ parseCImport cconv safety nm str sourceText =
((mk Nothing <$> cimp nm) +++
(do h <- munch1 hdr_char
skipSpaces
- mk (Just (Header h (mkFastString h))) <$> cimp nm))
+ mk (Just (Header (SourceText h) (mkFastString h)))
+ <$> cimp nm))
]
skipSpaces
return r
@@ -1386,7 +1388,7 @@ parseCImport cconv safety nm str sourceText =
return False)
_ -> return True
cid' <- cid
- return (CFunction (StaticTarget (unpackFS cid') cid'
+ return (CFunction (StaticTarget NoSourceText cid'
Nothing isFun)))
where
cid = return nm +++
@@ -1405,7 +1407,7 @@ mkExport (L lc cconv) (L le (StringLiteral esrc entity), v, ty)
ForeignExport { fd_name = v, fd_sig_ty = ty
, fd_co = noForeignExportCoercionYet
, fd_fe = CExport (L lc (CExportStatic esrc entity' cconv))
- (L le (unpackFS entity)) }
+ (L le esrc) }
where
entity' | nullFS entity = mkExtName (unLoc v)
| otherwise = entity