[Git][ghc/ghc][wip/az/epa-hslet-tokens] EPA: Use NoExtField in XApp

Alan Zimmerman (@alanz) gitlab at gitlab.haskell.org
Wed Jan 17 23:21:05 UTC 2024



Alan Zimmerman pushed to branch wip/az/epa-hslet-tokens at Glasgow Haskell Compiler / GHC


Commits:
2a32b624 by Vladislav Zavialov at 2024-01-17T20:24:35+00:00
EPA: Use NoExtField in XApp

Metric Decrease:
    parsing001

- - - - -


2 changed files:

- compiler/GHC/Parser.y
- compiler/GHC/Parser/PostProcess.hs


Changes:

=====================================
compiler/GHC/Parser.y
=====================================
@@ -2825,7 +2825,8 @@ fexp    :: { ECP }
                                           superFunArg $
                                           unECP $1 >>= \ $1 ->
                                           unECP $2 >>= \ $2 ->
-                                          mkHsAppPV (noAnnSrcSpan $ comb2 $1 $>) $1 $2 }
+                                          spanWithComments (comb2 $1 $>) >>= \l ->
+                                          mkHsAppPV l $1 $2 }
 
         -- See Note [Whitespace-sensitive operator parsing] in GHC.Parser.Lexer
         | fexp PREFIX_AT atype       { ECP $
@@ -4425,6 +4426,11 @@ parseSignature = parseSignatureNoHaddock >>= addHaddockToModule
 commentsA :: (NoAnn ann) => SrcSpan -> EpAnnComments -> EpAnn ann
 commentsA loc cs = EpAnn (EpaSpan loc) noAnn cs
 
+spanWithComments :: (NoAnn ann, MonadP m) => SrcSpan -> m (EpAnn ann)
+spanWithComments l = do
+  cs <- getCommentsFor l
+  return (commentsA l cs)
+
 -- | Instead of getting the *enclosed* comments, this includes the
 -- *preceding* ones.  It is used at the top level to get comments
 -- between top level declarations.


=====================================
compiler/GHC/Parser/PostProcess.hs
=====================================
@@ -1783,11 +1783,10 @@ instance DisambECP (HsExpr GhcPs) where
     return $ L (EpAnn (spanAsAnchor l) noAnn cs) (HsLam anns lam_variant mg)
   type FunArg (HsExpr GhcPs) = HsExpr GhcPs
   superFunArg m = m
-  mkHsAppPV l@(EpAnn anc an csIn) e1 e2 = do
-    !cs <- getCommentsFor (locA l)
+  mkHsAppPV l e1 e2 = do
     checkExpBlockArguments e1
     checkExpBlockArguments e2
-    return $ L (EpAnn anc an (csIn Semi.<> cs)) (HsApp noExtField e1 e2)
+    return $ L l (HsApp noExtField e1 e2)
   mkHsAppTypePV l e at t = do
     checkExpBlockArguments e
     return $ L l (HsAppType at e (mkHsWildCardBndrs t))



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2a32b624552a1a5c034bb5c0c5db716f8de708ed

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2a32b624552a1a5c034bb5c0c5db716f8de708ed
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/20240117/145c93f4/attachment-0001.html>


More information about the ghc-commits mailing list