[project @ 2000-09-14 13:46:39 by simonpj]
[ghc-hetmet.git] / ghc / compiler / parser / Parser.y
index 9279e44..544b922 100644 (file)
@@ -1,6 +1,6 @@
 {-
 -----------------------------------------------------------------------------
-$Id: Parser.y,v 1.32 2000/06/01 08:51:46 simonmar Exp $
+$Id: Parser.y,v 1.35 2000/09/14 13:46:40 simonpj Exp $
 
 Haskell grammar.
 
@@ -127,6 +127,7 @@ Conflicts: 14 shift/reduce
  '__float'     { ITfloat_lit }
  '__rational'  { ITrational_lit }
  '__addr'      { ITaddr_lit }
+ '__label'     { ITlabel_lit }
  '__litlit'    { ITlit_lit }
  '__string'    { ITstring_lit }
  '__ccall'     { ITccall $$ }
@@ -228,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] }
@@ -344,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 
@@ -356,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)) }
@@ -526,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
@@ -596,9 +588,9 @@ constr_stuff :: { (RdrName, RdrNameConDetails) }
        | con '{' fielddecls '}'        { ($1, RecCon (reverse $3)) }
 
 newconstr :: { RdrNameConDecl }
-       : srcloc conid atype    { mkConDecl $2 [] [] (NewCon $3 Nothing) $1 }
+       : srcloc conid atype    { mkConDecl $2 [] [] (VanillaCon [Unbanged $3]) $1 }
        | srcloc conid '{' var '::' type '}'
-                               { mkConDecl $2 [] [] (NewCon $6 (Just $4)) $1 }
+                               { mkConDecl $2 [] [] (RecCon [([$4], Unbanged $6)]) $1 }
 
 scontype :: { (RdrName, [RdrNameBangType]) }
        : btype                         {% splitForConApp $1 [] }
@@ -749,10 +741,6 @@ aexp1      :: { RdrNameHsExpr }
        | '_'                           { EWildPat }
        | '~' aexp1                     { ELazyPat $2 }
 
-commas :: { Int }
-       : commas ','                    { $1 + 1 }
-       | ','                           { 2 }
-
 texps :: { [RdrNameHsExpr] }
        : texps ',' exp                 { $3 : $1 }
        | exp                           { [$1] }
@@ -880,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 }
@@ -1080,6 +1075,10 @@ tyvar    :: { RdrName }
        | 'ccall'               { ccall_tyvar_RDR }
        -- NOTE: no 'forall'
 
+commas :: { Int }
+       : commas ','                    { $1 + 1 }
+       | ','                           { 2 }
+
 -----------------------------------------------------------------------------
 
 {