[project @ 1999-07-27 09:25:49 by simonmar]
[ghc-hetmet.git] / ghc / compiler / parser / Parser.y
index ef83b5e..0a44b94 100644 (file)
@@ -1,6 +1,10 @@
 {-
 -----------------------------------------------------------------------------
-$Id: Parser.y,v 1.10 1999/06/30 11:29:53 simonmar Exp $
+<<<<<<< Parser.y
+$Id: Parser.y,v 1.13 1999/07/27 09:25:49 simonmar Exp $
+=======
+$Id: Parser.y,v 1.13 1999/07/27 09:25:49 simonmar Exp $
+>>>>>>> 1.10
 
 Haskell grammar.
 
@@ -403,9 +407,7 @@ signdecl :: { RdrBinding }
                                              [ RdrSig (Sig n $4 $2) | n <- $1 ] }
 
 sigtype :: { RdrNameHsType }
-       : ctype                 { case $1 of
-                                   HsForAllTy _ _ _ -> $1
-                                   other            -> HsForAllTy Nothing [] $1 }
+       : ctype                 { mkHsForAllTy Nothing [] $1 }
 
 {-
   ATTENTION: Dirty Hackery Ahead! If the second alternative of vars is var
@@ -502,9 +504,10 @@ inst_type :: { RdrNameHsType }
 
 ctype  :: { RdrNameHsType }
        : 'forall' tyvars '.' context type
-                                       { HsForAllTy (Just $2) $4 $5 }
-       | 'forall' tyvars '.' type      { HsForAllTy (Just $2) [] $4 }
-       | context type                  { HsForAllTy Nothing   $1 $2 }
+                                       { mkHsForAllTy (Just $2) $4 $5 }
+       | 'forall' tyvars '.' type      { mkHsForAllTy (Just $2) [] $4 }
+       | context type                  { mkHsForAllTy Nothing   $1 $2 }
+               -- A type of form (context => type) is an *implicit* HsForAllTy
        | type                          { $1 }
 
 types0  :: { [RdrNameHsType] }
@@ -763,6 +766,10 @@ stmtlist :: { [RdrNameStmt] }
        : '{'                   stmts '}'       { reverse $2 }
        |     layout_on_for_do  stmts close     { reverse $2 }
 
+-- Stmt list should really end in an expression, but it's not
+-- convenient to enforce this here, so we throw out erroneous
+-- statement sequences in the renamer instead.
+
 stmts :: { [RdrNameStmt] }
        : ';' stmts1                    { $2 }
        | stmts1                        { $1 }