[commit: ghc] type-holes-branch: Fix the parser to support named holes (as "_a"). (44e1348)

Simon Peyton Jones <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.ghc
Message-ID <[email protected]>
Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : type-holes-branch

http://hackage.haskell.org/trac/ghc/changeset/44e134827d31987cf8b9e067d0de1288106f823e

>---------------------------------------------------------------

commit 44e134827d31987cf8b9e067d0de1288106f823e
Author: Thijs Alkemade <[email protected]>
Date:   Thu Feb 23 16:17:03 2012 +0100

    Fix the parser to support named holes (as "_a").
    My changes to the parser to support named holes were in the wrong file (Parser.y instead of Parser.y.pp), so they never got committed.

>---------------------------------------------------------------

 compiler/parser/Lexer.x     |    2 --
 compiler/parser/Parser.y.pp |    8 ++++++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x
index 219e5ac..2f22a3d 100644
--- a/compiler/parser/Lexer.x
+++ b/compiler/parser/Lexer.x
@@ -529,8 +529,6 @@ data Token
   | ITdoubleunderscore
   | ITbackquote
   | ITsimpleQuote               --  '
-  | IToparenunderscore
-  | ITcparenunderscore
 
   | ITvarid   FastString        -- identifiers
   | ITconid   FastString
diff --git a/compiler/parser/Parser.y.pp b/compiler/parser/Parser.y.pp
index 2ffce86..026adba 100644
--- a/compiler/parser/Parser.y.pp
+++ b/compiler/parser/Parser.y.pp
@@ -207,7 +207,6 @@ incorrect.
 
 %token
  '_'            { L _ ITunderscore }            -- Haskell keywords
- '__'           { L _ ITdoubleunderscore }
  'as'           { L _ ITas }
  'case'         { L _ ITcase }          
  'class'        { L _ ITclass } 
@@ -324,6 +323,7 @@ incorrect.
  PREFIXQCONSYM  { L _ (ITprefixqconsym  _) }
 
  IPDUPVARID     { L _ (ITdupipvarid   _) }              -- GHC extension
+ HOLEVARID      { L _ (IThole     _) }
 
  CHAR           { L _ (ITchar     _) }
  STRING         { L _ (ITstring   _) }
@@ -1428,6 +1428,7 @@ aexp1   :: { LHsExpr RdrName }
 
 aexp2   :: { LHsExpr RdrName }
         : ipvar                         { L1 (HsIPVar $! unLoc $1) }
+        | hole                          { sL (getLoc $1) (HsHole  $! unLoc $1) }
         | qcname                        { L1 (HsVar   $! unLoc $1) }
         | literal                       { L1 (HsLit   $! unLoc $1) }
 -- This will enable overloaded strings permanently.  Normally the renamer turns HsString
@@ -1449,7 +1450,6 @@ aexp2   :: { LHsExpr RdrName }
         | '[' list ']'                  { LL (unLoc $2) }
         | '[:' parr ':]'                { LL (unLoc $2) }
         | '_'                           { L1 EWildPat }
-        | '__'                          { L1 (HsHole $! unLoc $1) }
         
         -- Template Haskell Extension
         | TH_ID_SPLICE          { L1 $ HsSpliceE (mkHsSplice 
@@ -1743,6 +1743,9 @@ dbind   : ipvar '=' exp                 { LL (IPBind (unLoc $1) $3) }
 ipvar   :: { Located (IPName RdrName) }
         : IPDUPVARID            { L1 (IPName (mkUnqual varName (getIPDUPVARID $1))) }
 
+hole    :: { Located RdrName }
+        : HOLEVARID             { sL (getLoc $1) (mkUnqual varName $ getHOLEVARID $1) }
+
 -----------------------------------------------------------------------------
 -- Warnings and deprecations
 
@@ -2062,6 +2065,7 @@ getQCONSYM      (L _ (ITqconsym  x)) = x
 getPREFIXQVARSYM (L _ (ITprefixqvarsym  x)) = x
 getPREFIXQCONSYM (L _ (ITprefixqconsym  x)) = x
 getIPDUPVARID   (L _ (ITdupipvarid   x)) = x
+getHOLEVARID    (L _ (IThole     x)) = x
 getCHAR         (L _ (ITchar     x)) = x
 getSTRING       (L _ (ITstring   x)) = x
 getINTEGER      (L _ (ITinteger  x)) = x
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.