- }
-
-decls_part :: { (LocalTyDefsMap, LocalValDefsMap) }
-decls_part : DECLARATIONS_PART topdecls { $2 }
- | { (emptyFM, emptyFM) }
-
-topdecls :: { (LocalTyDefsMap, LocalValDefsMap) }
-topdecls : topdecl { $1 }
- | topdecls topdecl { case $1 of { (ts1, vs1) ->
- case $2 of { (ts2, vs2) ->
- (plusFM ts1 ts2, plusFM vs1 vs2)}}
- }
-
-topdecl :: { (LocalTyDefsMap, LocalValDefsMap) }
-topdecl : typed SEMI { ($1, emptyFM) }
- | datad SEMI { $1 }
- | newtd SEMI { $1 }
- | classd SEMI { $1 }
- | decl { case $1 of { (n, Sig qn ty _ loc) ->
- (emptyFM, unitFM n (ValSig qn loc ty)) }
- }
-
-typed :: { LocalTyDefsMap }
-typed : TYPE simple EQUAL type { mk_type $2 $4 }
-
-datad :: { (LocalTyDefsMap, LocalValDefsMap) }
-datad : DATA simple EQUAL constrs { mk_data [] $2 $4 }
- | DATA context DARROW simple EQUAL constrs { mk_data $2 $4 $6 }
-
-newtd :: { (LocalTyDefsMap, LocalValDefsMap) }
-newtd : NEWTYPE simple EQUAL constr1 { mk_new [] $2 $4 }
- | NEWTYPE context DARROW simple EQUAL constr1 { mk_new $2 $4 $6 }
-
-classd :: { (LocalTyDefsMap, LocalValDefsMap) }
-classd : CLASS class cbody { mk_class [] $2 $3 }
- | CLASS context DARROW class cbody { mk_class $2 $4 $5 }
-
-cbody :: { [(FAST_STRING, RdrNameSig)] }
-cbody : WHERE OCURLY decls CCURLY { $3 }
- | { [] }
-
-decls :: { [(FAST_STRING, RdrNameSig)] }
-decls : decl { [$1] }
- | decls decl { $1 ++ [$2] }
-
-decl :: { (FAST_STRING, RdrNameSig) }
-decl : var DCOLON ctype SEMI { (de_qual $1, Sig $1 $3 noGenPragmas mkIfaceSrcLoc) }
+ }
+
+decls_part :: { [(Version, RdrNameHsDecl)] }
+decls_part : { [] }
+ | DECLARATIONS_PART topdecls { $2 }
+
+topdecls :: { [(Version, RdrNameHsDecl)] }
+topdecls : { [] }
+ | version topdecl topdecls { ($1,$2) : $3 }
+
+version :: { Version }
+version : INTEGER { fromInteger $1 }
+
+topdecl :: { RdrNameHsDecl }
+topdecl : TYPE tc_name tv_bndrs EQUAL type SEMI
+ { TyD (TySynonym $2 $3 $5 mkIfaceSrcLoc) }
+ | DATA decl_context tc_name tv_bndrs constrs deriving SEMI
+ { TyD (TyData $2 $3 $4 $5 $6 noDataPragmas mkIfaceSrcLoc) }
+ | NEWTYPE decl_context tc_name tv_bndrs EQUAL constr1 deriving SEMI
+ { TyD (TyNew $2 $3 $4 $6 $7 noDataPragmas mkIfaceSrcLoc) }
+ | CLASS decl_context tc_name tv_bndr csigs SEMI
+ { ClD (ClassDecl $2 $3 $4 $5 EmptyMonoBinds noClassPragmas mkIfaceSrcLoc) }
+ | var_name TYPE_PART id_info
+ {
+ let
+ (Succeeded tp) = parseType $2
+ in
+ SigD (IfaceSig $1 tp $3 mkIfaceSrcLoc) }
+
+id_info :: { [HsIdInfo RdrName] }
+id_info : { [] }
+ | IDINFO_PART { let { (Succeeded id_info) = parseUnfolding $1 } in id_info}
+
+decl_context :: { RdrNameContext }
+decl_context : { [] }
+ | OCURLY context_list1 CCURLY DARROW { $2 }
+
+
+csigs :: { [RdrNameSig] }
+csigs : { [] }
+ | WHERE OCURLY csigs1 CCURLY { $3 }
+
+csigs1 :: { [RdrNameSig] }
+csigs1 : csig { [$1] }
+ | csig SEMI csigs1 { $1 : $3 }
+
+csig :: { RdrNameSig }
+csig : var_name DCOLON type { ClassOpSig $1 $1 $3 mkIfaceSrcLoc
+----------------------------------------------------------------
+ }
+
+constrs :: { [RdrNameConDecl] }
+ : { [] }
+ | EQUAL constrs1 { $2 }
+
+constrs1 :: { [RdrNameConDecl] }
+constrs1 : constr { [$1] }
+ | constr VBAR constrs1 { $1 : $3 }
+
+constr :: { RdrNameConDecl }
+constr : data_name batypes { ConDecl $1 $2 mkIfaceSrcLoc }
+ | data_name OCURLY fields1 CCURLY { RecConDecl $1 $3 mkIfaceSrcLoc }
+
+constr1 :: { RdrNameConDecl {- For a newtype -} }
+constr1 : data_name atype { NewConDecl $1 $2 mkIfaceSrcLoc }
+
+deriving :: { Maybe [RdrName] }
+ : { Nothing }
+ | DERIVING OPAREN qtc_names1 CPAREN { Just $3 }
+
+batypes :: { [RdrNameBangType] }
+batypes : { [] }
+ | batype batypes { $1 : $2 }
+
+batype :: { RdrNameBangType }
+batype : atype { Unbanged $1 }
+ | BANG atype { Banged $2 }
+
+fields1 :: { [([RdrName], RdrNameBangType)] }
+fields1 : field { [$1] }
+ | field COMMA fields1 { $1 : $3 }
+
+field :: { ([RdrName], RdrNameBangType) }
+field : var_names1 DCOLON type { ($1, Unbanged $3) }
+ | var_names1 DCOLON BANG type { ($1, Banged $4)
+--------------------------------------------------------------------------
+ }
+
+forall :: { [HsTyVar RdrName] }
+forall : OBRACK tv_bndrs CBRACK { $2 }