summaryrefslogtreecommitdiff
path: root/compiler/parser
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2015-07-23 11:42:07 +0200
committerBen Gamari <ben@smart-cactus.org>2015-07-23 11:42:46 +0200
commit76e2341afdc050549067a18cac41373f64daf4c2 (patch)
tree6df84605bf2ca7ed2d629958c2a47b4bb4463fcd /compiler/parser
parentd2b4df157532adf014789ae9b2496f88369e43ea (diff)
downloadhaskell-76e2341afdc050549067a18cac41373f64daf4c2.tar.gz
Accept next-docstrings on GADT constructors.
Accept next docstrings (`-- | Docstring`) on GADT constructors. I have confirmed that this adds no shift/reduce conflicts. Test Plan: haddockA034 Reviewers: austin, simonpj, simonmar Reviewed By: simonmar Subscribers: Fuuzetsu, simonmar, thomie, mpickering, edsko Differential Revision: https://phabricator.haskell.org/D1086
Diffstat (limited to 'compiler/parser')
-rw-r--r--compiler/parser/Parser.y13
1 files changed, 10 insertions, 3 deletions
diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y
index d6972532d7..99abf162d1 100644
--- a/compiler/parser/Parser.y
+++ b/compiler/parser/Parser.y
@@ -1870,10 +1870,10 @@ gadt_constrlist :: { Located ([AddAnn]
| {- empty -} { noLoc ([],[]) }
gadt_constrs :: { Located [LConDecl RdrName] }
- : gadt_constr ';' gadt_constrs
+ : gadt_constr_with_doc ';' gadt_constrs
{% addAnnotation (gl $1) AnnSemi (gl $2)
>> return (L (comb2 $1 $3) ($1 : unLoc $3)) }
- | gadt_constr { L (gl $1) [$1] }
+ | gadt_constr_with_doc { L (gl $1) [$1] }
| {- empty -} { noLoc [] }
-- We allow the following forms:
@@ -1882,11 +1882,18 @@ gadt_constrs :: { Located [LConDecl RdrName] }
-- D { x,y :: a } :: T a
-- forall a. Eq a => D { x,y :: a } :: T a
+gadt_constr_with_doc :: { LConDecl RdrName }
+gadt_constr_with_doc
+ : maybe_docnext ';' gadt_constr
+ {% return $ addConDoc $3 $1 }
+ | gadt_constr
+ {% return $1 }
+
gadt_constr :: { LConDecl RdrName }
-- Returns a list because of: C,D :: ty
: con_list '::' sigtype
{% do { (anns,gadtDecl) <- mkGadtDecl (unLoc $1) $3
- ; ams (sLL $1 $> $ gadtDecl)
+ ; ams (sLL $1 $> gadtDecl)
(mj AnnDcolon $2:anns) } }
-- Deprecated syntax for GADT record declarations