diff options
author | Vladislav Zavialov <vlad.z.4096@gmail.com> | 2021-10-02 03:15:14 +0300 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-10-04 23:46:21 -0400 |
commit | a762933454f1dbecaa2048f810f6ab6bbfe3a93d (patch) | |
tree | 05d54919ee3e2ccddb1b4ddce580afee479b620d /compiler/GHC/Parser/Annotation.hs | |
parent | a0f44cebb217b3586d861750366301b973073dd1 (diff) | |
download | haskell-a762933454f1dbecaa2048f810f6ab6bbfe3a93d.tar.gz |
Bespoke TokenLocation data type
The EpaAnnCO we were using contained an Anchor instead of EpaLocation,
making it harder to work with.
At the same time, using EpaLocation by itself isn't possible either,
as we may have tokens without location information.
Hence the new data type:
data TokenLocation = NoTokenLoc
| TokenLoc !EpaLocation
Diffstat (limited to 'compiler/GHC/Parser/Annotation.hs')
-rw-r--r-- | compiler/GHC/Parser/Annotation.hs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/GHC/Parser/Annotation.hs b/compiler/GHC/Parser/Annotation.hs index a914a14b71..b414e70be5 100644 --- a/compiler/GHC/Parser/Annotation.hs +++ b/compiler/GHC/Parser/Annotation.hs @@ -14,6 +14,7 @@ module GHC.Parser.Annotation ( -- * In-tree Exact Print Annotations AddEpAnn(..), EpaLocation(..), epaLocationRealSrcSpan, epaLocationFromSrcAnn, + TokenLocation(..), DeltaPos(..), deltaPos, getDeltaLine, EpAnn(..), Anchor(..), AnchorOperation(..), @@ -405,6 +406,11 @@ data EpaLocation = EpaSpan RealSrcSpan | EpaDelta DeltaPos deriving (Data,Show,Eq,Ord) +-- | Tokens embedded in the AST have an EpaLocation, unless they come from +-- generated code (e.g. by TH). +data TokenLocation = NoTokenLoc | TokenLoc !EpaLocation + deriving (Data,Show,Eq,Ord) + -- | Spacing between output items when exact printing. It captures -- the spacing from the current print position on the page to the -- position required for the thing about to be printed. This is |