Template Haskell: allow type splices
[ghc-hetmet.git] / compiler / parser / Parser.y.pp
index 6493b06..f9976b4 100644 (file)
@@ -8,7 +8,7 @@
 -- ---------------------------------------------------------------------------
 
 {
-{-# OPTIONS -w #-}
+{-# OPTIONS -Wwarn -w #-}
 -- The above warning supression flag is a temporary kludge.
 -- While working on this module you are encouraged to remove it and fix
 -- any warnings in the module. See
@@ -1004,17 +1004,6 @@ strict_mark :: { Located HsBang }
        : '!'                           { L1 HsStrict }
        | '{-# UNPACK' '#-}' '!'        { LL HsUnbox }
 
-----------------------
--- Notes for 'ctype'
--- We should probably use 'gentype' rather than 'type' in the LHS of type declarations
--- That would leave the only use of 'type' in 'ctype'; and only one of its occurrences 
--- makes sense there too! So it might make sense to inline type there:
---    ctype : 'forall' tv_bndrs '.' ctype
---          | context '=>' ctype           
---          | ipvar '::' gentype
---          | gentype
--- Which in turn would let us rename gentype to type 
-
 -- A ctype is a for-all type
 ctype  :: { LHsType RdrName }
        : 'forall' tv_bndrs '.' ctype   { LL $ mkExplicitHsForAllTy $2 (noLoc []) $4 }
@@ -1023,10 +1012,6 @@ ctype    :: { LHsType RdrName }
        | ipvar '::' type               { LL (HsPredTy (HsIParam (unLoc $1) $3)) }
        | type                          { $1 }
 
-type :: { LHsType RdrName }
-       : ipvar '::' gentype            { LL (HsPredTy (HsIParam (unLoc $1) $3)) }
-       | gentype                       { $1 }
-
 ----------------------
 -- Notes for 'ctypedoc'
 -- It would have been nice to simplify the grammar by unifying `ctype` and 
@@ -1045,10 +1030,6 @@ ctypedoc :: { LHsType RdrName }
        | ipvar '::' type               { LL (HsPredTy (HsIParam (unLoc $1) $3)) }
        | typedoc                       { $1 }
 
-typedoc :: { LHsType RdrName }
-       : ipvar '::' gentype            { LL (HsPredTy (HsIParam (unLoc $1) $3)) }
-       | gentypedoc                    { $1 }
-
 ----------------------
 -- Notes for 'context'
 -- We parse a context as a btype so that we don't get reduce/reduce
@@ -1097,6 +1078,10 @@ atype :: { LHsType RdrName }
        | '[:' ctype ':]'               { LL $ HsPArrTy  $2 }
        | '(' ctype ')'                 { LL $ HsParTy   $2 }
        | '(' ctype '::' kind ')'       { LL $ HsKindSig $2 (unLoc $4) }
+       | '$(' exp ')'                  { LL $ HsSpliceTy (mkHsSplice $2 ) }
+       | TH_ID_SPLICE                  { LL $ HsSpliceTy (mkHsSplice 
+                                                (L1 $ HsVar (mkUnqual varName 
+                                                               (getTH_ID_SPLICE $1)))) } -- $x
 -- Generics
         | INTEGER                       { L1 (HsNumTy (getINTEGER $1)) }