Repository : ssh://darcs.haskell.org//srv/darcs/ghc On branch : type-holes-branch
http://hackage.haskell.org/trac/ghc/changeset/2f3e9e05f93669eb082ef05e7faf26cbabfc21d7 >--------------------------------------------------------------- commit 2f3e9e05f93669eb082ef05e7faf26cbabfc21d7 Author: Thijs Alkemade <[email protected]> Date: Fri Dec 2 09:53:21 2011 +0100 Extended the parser to support "__", which will be used to denote a hole. >--------------------------------------------------------------- compiler/hsSyn/HsExpr.lhs | 3 +++ compiler/parser/Lexer.x | 2 ++ compiler/parser/Parser.y.pp | 2 ++ compiler/rename/RnExpr.lhs | 3 +++ compiler/typecheck/TcExpr.lhs | 2 ++ 5 files changed, 12 insertions(+), 0 deletions(-) diff --git a/compiler/hsSyn/HsExpr.lhs b/compiler/hsSyn/HsExpr.lhs index 1dd3c83..121687c 100644 --- a/compiler/hsSyn/HsExpr.lhs +++ b/compiler/hsSyn/HsExpr.lhs @@ -290,6 +290,7 @@ data HsExpr id | HsWrap HsWrapper -- TRANSLATION (HsExpr id) + | HsHole deriving (Data, Typeable) -- HsTupArg is used for tuple sections @@ -545,6 +546,8 @@ ppr_expr (HsArrForm (L _ (HsVar v)) (Just _) [arg1, arg2]) ppr_expr (HsArrForm op _ args) = hang (ptext (sLit "(|") <> ppr_lexpr op) 4 (sep (map (pprCmdArg.unLoc) args) <> ptext (sLit "|)")) +ppr_expr HsHole + = text "__" pprCmdArg :: OutputableBndr id => HsCmdTop id -> SDoc pprCmdArg (HsCmdTop cmd@(L _ (HsArrForm _ Nothing [])) _ _ _) diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x index 21984ec..2595fc7 100644 --- a/compiler/parser/Lexer.x +++ b/compiler/parser/Lexer.x @@ -524,6 +524,7 @@ data Token | ITsemi | ITcomma | ITunderscore + | ITdoubleunderscore | ITbackquote | ITsimpleQuote -- ' @@ -599,6 +600,7 @@ reservedWordsFM :: UniqFM (Token, Int) reservedWordsFM = listToUFM $ map (\(x, y, z) -> (mkFastString x, (y, z))) [( "_", ITunderscore, 0 ), + ( "__", ITdoubleunderscore, 0 ), ( "as", ITas, 0 ), ( "case", ITcase, 0 ), ( "class", ITclass, 0 ), diff --git a/compiler/parser/Parser.y.pp b/compiler/parser/Parser.y.pp index 8a41fa4..3b3bbd4 100644 --- a/compiler/parser/Parser.y.pp +++ b/compiler/parser/Parser.y.pp @@ -207,6 +207,7 @@ incorrect. %token '_' { L _ ITunderscore } -- Haskell keywords + '__' { L _ ITdoubleunderscore } 'as' { L _ ITas } 'case' { L _ ITcase } 'class' { L _ ITclass } @@ -1458,6 +1459,7 @@ aexp2 :: { LHsExpr RdrName } | '[' list ']' { LL (unLoc $2) } | '[:' parr ':]' { LL (unLoc $2) } | '_' { L1 EWildPat } + | '__' { L1 HsHole } -- Template Haskell Extension | TH_ID_SPLICE { L1 $ HsSpliceE (mkHsSplice diff --git a/compiler/rename/RnExpr.lhs b/compiler/rename/RnExpr.lhs index 0487733..6773ed4 100644 --- a/compiler/rename/RnExpr.lhs +++ b/compiler/rename/RnExpr.lhs @@ -293,6 +293,9 @@ rnExpr (ArithSeq _ seq) rnExpr (PArrSeq _ seq) = rnArithSeq seq `thenM` \ (new_seq, fvs) -> return (PArrSeq noPostTcExpr new_seq, fvs) + +rnExpr HsHole + = return (HsHole, emptyFVs) \end{code} These three are pattern syntax appearing in expressions. diff --git a/compiler/typecheck/TcExpr.lhs b/compiler/typecheck/TcExpr.lhs index 67f212f..b9153ab 100644 --- a/compiler/typecheck/TcExpr.lhs +++ b/compiler/typecheck/TcExpr.lhs @@ -215,6 +215,8 @@ tcExpr (HsType ty) _ -- so it's not enabled yet. -- Can't eliminate it altogether from the parser, because the -- same parser parses *patterns*. +tcExpr HsHole _ + = return HsHole \end{code} _______________________________________________ Cvs-ghc mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-ghc
