diff options
author | Vladislav Zavialov <vlad.z.4096@gmail.com> | 2020-07-22 14:30:27 +0300 |
---|---|---|
committer | Vladislav Zavialov <vlad.z.4096@gmail.com> | 2020-07-26 07:35:23 -0400 |
commit | 6356fe4f2c591fd359c2134451fb753c3202b14d (patch) | |
tree | 0b1d8f19db117e23863db1790166f6a24f0c66fa /compiler/GHC/Parser.y | |
parent | fc0f6fbcd95f2dc69a8efabbee2d8a485c34cc47 (diff) | |
download | haskell-wip/parser-refactor-jul24.tar.gz |
Refactor the parser a littlewip/parser-refactor-jul24
* Create a dedicated production for type operators
* Create a dedicated type for the UNPACK pragma
* Remove an outdated part of Note [Parsing data constructors is hard]
Diffstat (limited to 'compiler/GHC/Parser.y')
-rw-r--r-- | compiler/GHC/Parser.y | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/compiler/GHC/Parser.y b/compiler/GHC/Parser.y index 3043ba92b1..f1ddd6b961 100644 --- a/compiler/GHC/Parser.y +++ b/compiler/GHC/Parser.y @@ -1884,9 +1884,9 @@ sigtypes1 :: { (OrdList (LHsSigType GhcPs)) } ----------------------------------------------------------------------------- -- Types -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) } +unpackedness :: { Located UnpackednessPragma } + : '{-# UNPACK' '#-}' { sLL $1 $> (UnpackednessPragma [mo $1, mc $2] (getUNPACK_PRAGs $1) SrcUnpack) } + | '{-# NOUNPACK' '#-}' { sLL $1 $> (UnpackednessPragma [mo $1, mc $2] (getNOUNPACK_PRAGs $1) SrcNoUnpack) } forall_telescope :: { Located ([AddAnn], HsForAllTelescope GhcPs) } : 'forall' tv_bndrs '.' {% do { hintExplicitForall $1 @@ -1980,13 +1980,16 @@ tyapp :: { Located TyEl } -- See Note [Whitespace-sensitive operator parsing] in GHC.Parser.Lexer | PREFIX_AT atype { sLL $1 $> $ (TyElKindApp (comb2 $1 $2) $2) } - | qtyconop { sL1 $1 $ TyElOpr (unLoc $1) } - | tyvarop { sL1 $1 $ TyElOpr (unLoc $1) } - | SIMPLEQUOTE qconop {% ams (sLL $1 $> $ TyElOpr (unLoc $2)) + | tyop { mapLoc TyElOpr $1 } + | unpackedness { sL1 $1 $ TyElUnpackedness (unLoc $1) } + +tyop :: { Located RdrName } + : qtyconop { $1 } + | tyvarop { $1 } + | SIMPLEQUOTE qconop {% ams (sLL $1 $> (unLoc $2)) [mj AnnSimpleQuote $1,mj AnnVal $2] } - | SIMPLEQUOTE varop {% ams (sLL $1 $> $ TyElOpr (unLoc $2)) + | SIMPLEQUOTE varop {% ams (sLL $1 $> (unLoc $2)) [mj AnnSimpleQuote $1,mj AnnVal $2] } - | unpackedness { sL1 $1 $ TyElUnpackedness (unLoc $1) } atype :: { LHsType GhcPs } : ntgtycon { sL1 $1 (HsTyVar noExtField NotPromoted $1) } -- Not including unit tuples |