summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorVladislav Zavialov <vlad.z.4096@gmail.com>2022-04-08 13:16:42 +0300
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-04-09 13:04:50 -0400
commit20eca489df8c3dae80a584dede8fea40728bde3b (patch)
tree80f3d786b40ea06fe058ae3420a821b8f06dcb05 /compiler
parent5f8d6e65f3d8268c70d6a8434ba9df03087a22eb (diff)
downloadhaskell-20eca489df8c3dae80a584dede8fea40728bde3b.tar.gz
Refactor: simplify lexing of the dot
Before this patch, the lexer did a truly roundabout thing with the dot: 1. look up the varsym in reservedSymsFM and turn it into ITdot 2. under OverloadedRecordDot, turn it into ITvarsym 3. in varsym_(prefix|suffix|...) turn it into ITvarsym, ITdot, or ITproj, depending on extensions and whitespace Turns out, the last step is sufficient to handle the dot correctly. This patch removes the first two steps.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/GHC/Parser/Lexer.x12
1 files changed, 2 insertions, 10 deletions
diff --git a/compiler/GHC/Parser/Lexer.x b/compiler/GHC/Parser/Lexer.x
index 82a5b9bb38..cb8a1023a3 100644
--- a/compiler/GHC/Parser/Lexer.x
+++ b/compiler/GHC/Parser/Lexer.x
@@ -1057,9 +1057,6 @@ reservedSymsFM = listToUFM $
,("*", ITstar NormalSyntax, NormalSyntax, xbit StarIsTypeBit)
- -- For 'forall a . t'
- ,(".", ITdot, NormalSyntax, 0 )
-
,("-<", ITlarrowtail NormalSyntax, NormalSyntax, xbit ArrowsBit)
,(">-", ITrarrowtail NormalSyntax, NormalSyntax, xbit ArrowsBit)
,("-<<", ITLarrowtail NormalSyntax, NormalSyntax, xbit ArrowsBit)
@@ -1726,13 +1723,8 @@ consym = sym (\_span _exts s -> return $ ITconsym s)
sym :: (PsSpan -> ExtsBitmap -> FastString -> P Token) -> Action
sym con span buf len =
case lookupUFM reservedSymsFM fs of
- Just (keyword, NormalSyntax, 0) -> do
- exts <- getExts
- if fs == fsLit "." &&
- exts .&. (xbit OverloadedRecordDotBit) /= 0 &&
- xtest OverloadedRecordDotBit exts
- then L span <$!> con span exts fs -- Process by varsym_*.
- else return $ L span keyword
+ Just (keyword, NormalSyntax, 0) ->
+ return $ L span keyword
Just (keyword, NormalSyntax, i) -> do
exts <- getExts
if exts .&. i /= 0