summaryrefslogtreecommitdiff
path: root/compiler/parser/Parser.y.pp
diff options
context:
space:
mode:
authorDr. ERDI Gergo <gergo@erdi.hu>2014-07-06 17:33:00 +0800
committerDr. ERDI Gergo <gergo@erdi.hu>2014-07-29 11:34:41 +0200
commit12644c3c0216edfcff33266f4f250e0c52004352 (patch)
tree3a8f02e512ebec5987651e4b288bd4bcc3310d94 /compiler/parser/Parser.y.pp
parentb6d52294cd009ef620ad9d74ab88e0822e685919 (diff)
downloadhaskell-12644c3c0216edfcff33266f4f250e0c52004352.tar.gz
New parser for pattern synonym declarations:
Like splitCon for constructor definitions, the left-hand side of a pattern declaration is parsed as a single pattern which is then split into a ConName and argument variable names
Diffstat (limited to 'compiler/parser/Parser.y.pp')
-rw-r--r--compiler/parser/Parser.y.pp14
1 files changed, 8 insertions, 6 deletions
diff --git a/compiler/parser/Parser.y.pp b/compiler/parser/Parser.y.pp
index 3fff097d25..9321e03d87 100644
--- a/compiler/parser/Parser.y.pp
+++ b/compiler/parser/Parser.y.pp
@@ -848,17 +848,19 @@ role : VARID { L1 $ Just $ getVARID $1 }
-- Glasgow extension: pattern synonyms
pattern_synonym_decl :: { LHsDecl RdrName }
- : 'pattern' con vars0 patsyn_token pat { LL . ValD $ mkPatSynBind $2 (PrefixPatSyn $3) $5 $4 }
- | 'pattern' varid conop varid patsyn_token pat { LL . ValD $ mkPatSynBind $3 (InfixPatSyn $2 $4) $6 $5 }
+ : 'pattern' pat '=' pat
+ {% do { (name, args) <- splitPatSyn $2
+ ; return $ LL . ValD $ mkPatSynBind name args $4 ImplicitBidirectional
+ }}
+ | 'pattern' pat '<-' pat
+ {% do { (name, args) <- splitPatSyn $2
+ ; return $ LL . ValD $ mkPatSynBind name args $4 Unidirectional
+ }}
vars0 :: { [Located RdrName] }
: {- empty -} { [] }
| varid vars0 { $1 : $2 }
-patsyn_token :: { HsPatSynDir RdrName }
- : '<-' { Unidirectional }
- | '=' { ImplicitBidirectional }
-
-----------------------------------------------------------------------------
-- Nested declarations