[project @ 2000-08-01 09:08:25 by simonpj]
[ghc-hetmet.git] / ghc / compiler / parser / Parser.y
index d8aef16..095f828 100644 (file)
@@ -1,6 +1,6 @@
 {-
 -----------------------------------------------------------------------------
-$Id: Parser.y,v 1.33 2000/07/06 14:08:31 simonmar Exp $
+$Id: Parser.y,v 1.34 2000/08/01 09:08:27 simonpj Exp $
 
 Haskell grammar.
 
@@ -229,8 +229,8 @@ body        :: { ([RdrNameImportDecl], [RdrNameHsDecl]) }
        |      layout_on  top close             { $2 }
 
 top    :: { ([RdrNameImportDecl], [RdrNameHsDecl]) }
-       : importdecls ';' cvtopdecls            { (reverse $1,$3) }
-       | importdecls                           { (reverse $1,[]) }
+       : importdecls                           { (reverse $1,[]) }
+       | importdecls ';' cvtopdecls            { (reverse $1,$3) }
        | cvtopdecls                            { ([],$1) }
 
 cvtopdecls :: { [RdrNameHsDecl] }
@@ -345,9 +345,8 @@ topdecl :: { RdrBinding }
 
        | srcloc 'class' ctype fds where
                {% checkDataHeader $3 `thenP` \(cs,c,ts) ->
-                  let (binds,sigs) 
-                          = cvMonoBindsAndSigs cvClassOpSig 
-                               (groupBindings $5) 
+                  let 
+                       (binds,sigs) = cvMonoBindsAndSigs cvClassOpSig (groupBindings $5) 
                   in
                   returnP (RdrHsDecl (TyClD
                      (mkClassDecl cs c ts $4 sigs binds 
@@ -357,8 +356,7 @@ topdecl :: { RdrBinding }
                { let (binds,sigs) 
                        = cvMonoBindsAndSigs cvInstDeclSig 
                                (groupBindings $4)
-                 in RdrHsDecl (InstD
-                               (InstDecl $3 binds sigs dummyRdrVarName $1)) }
+                 in RdrHsDecl (InstD (InstDecl $3 binds sigs Nothing $1)) }
 
        | srcloc 'default' '(' types0 ')'
                { RdrHsDecl (DefD (DefaultDecl $4 $1)) }
@@ -527,13 +525,6 @@ atype :: { RdrNameHsType }
        | '[' type ']'                  { HsListTy $2 }
        | '(' ctype ')'                 { $2 }
 
-gtycon         :: { RdrName }
-       : qtycon                        { $1 }
-       | '(' ')'                       { unitTyCon_RDR }
-       | '(' '->' ')'                  { funTyCon_RDR }
-       | '[' ']'                       { listTyCon_RDR }
-       | '(' commas ')'                { tupleTyCon_RDR $2 }
-
 -- An inst_type is what occurs in the head of an instance decl
 --     e.g.  (Foo a, Gaz b) => Wibble a b
 -- It's kept as a single type, with a MonoDictTy at the right
@@ -750,10 +741,6 @@ aexp1      :: { RdrNameHsExpr }
        | '_'                           { EWildPat }
        | '~' aexp1                     { ELazyPat $2 }
 
-commas :: { Int }
-       : commas ','                    { $1 + 1 }
-       | ','                           { 2 }
-
 texps :: { [RdrNameHsExpr] }
        : texps ',' exp                 { $3 : $1 }
        | exp                           { [$1] }
@@ -881,6 +868,13 @@ dbind      : ipvar '=' exp                 { ($1, $3) }
 -----------------------------------------------------------------------------
 -- Variables, Constructors and Operators.
 
+gtycon         :: { RdrName }
+       : qtycon                        { $1 }
+       | '(' ')'                       { unitTyCon_RDR }
+       | '(' '->' ')'                  { funTyCon_RDR }
+       | '[' ']'                       { listTyCon_RDR }
+       | '(' commas ')'                { tupleTyCon_RDR $2 }
+
 gcon   :: { RdrName }
        : '(' ')'               { unitCon_RDR }
        | '[' ']'               { nilCon_RDR }
@@ -1081,6 +1075,10 @@ tyvar    :: { RdrName }
        | 'ccall'               { ccall_tyvar_RDR }
        -- NOTE: no 'forall'
 
+commas :: { Int }
+       : commas ','                    { $1 + 1 }
+       | ','                           { 2 }
+
 -----------------------------------------------------------------------------
 
 {