+csig : src_loc qvar_name '::' type { mkClassOpSig NoDefMeth $2 $4 $1 }
+ | src_loc qvar_name '=' '::' type { mkClassOpSig (DefMeth (error "DefMeth") )
+ $2 $5 $1 }
+ | src_loc qvar_name ';' '::' type { mkClassOpSig GenDefMeth $2 $5 $1 }
+
+--------------------------------------------------------------------------
+
+instance_decl_part :: { [RdrNameInstDecl] }
+instance_decl_part : {- empty -} { [] }
+ | instance_decl_part inst_decl { $2 : $1 }
+
+inst_decl :: { RdrNameInstDecl }
+inst_decl : src_loc 'instance' type '=' qvar_name ';'
+ { InstDecl $3
+ EmptyMonoBinds {- No bindings -}
+ [] {- No user pragmas -}
+ (Just $5) {- Dfun id -}
+ $1
+ }
+
+--------------------------------------------------------------------------
+
+decls_part :: { [(Version, RdrNameTyClDecl)] }
+decls_part
+ : {- empty -} { [] }
+ | opt_version decl ';' decls_part { ($1,$2):$4 }
+
+decl :: { RdrNameTyClDecl }
+decl : src_loc qvar_name '::' type maybe_idinfo
+ { IfaceSig $2 $4 ($5 $2) $1 }
+ | src_loc 'type' qtc_name tv_bndrs '=' type
+ { TySynonym $3 $4 $6 $1 }
+ | src_loc 'data' opt_decl_context qtc_name tv_bndrs constrs
+ { mkTyData DataType $3 $4 $5 $6 (length $6) Nothing $1 }
+ | src_loc 'newtype' opt_decl_context qtc_name tv_bndrs newtype_constr
+ { mkTyData NewType $3 $4 $5 $6 1 Nothing $1 }
+ | src_loc 'class' opt_decl_context qtc_name tv_bndrs fds csigs
+ { mkClassDecl $3 $4 $5 $6 $7 EmptyMonoBinds $1 }
+
+maybe_idinfo :: { RdrName -> [HsIdInfo RdrName] }
+maybe_idinfo : {- empty -} { \_ -> [] }
+ | pragma { \x -> if opt_IgnoreIfacePragmas then []
+ else case $1 of
+ POk _ (PIdInfo id_info) -> id_info
+ PFailed err -> pprPanic "IdInfo parse failed"
+ (vcat [ppr x, err])
+ }
+ {-
+ If a signature decl is being loaded, and opt_IgnoreIfacePragmas is on,
+ we toss away unfolding information.
+
+ Also, if the signature is loaded from a module we're importing from source,
+ we do the same. This is to avoid situations when compiling a pair of mutually
+ recursive modules, peering at unfolding info in the interface file of the other,
+ e.g., you compile A, it looks at B's interface file and may as a result change
+ its interface file. Hence, B is recompiled, maybe changing its interface file,
+ which will the unfolding info used in A to become invalid. Simple way out is to
+ just ignore unfolding info.
+
+ [Jan 99: I junked the second test above. If we're importing from an hi-boot
+ file there isn't going to *be* any pragma info. The above comment
+ dates from a time where we picked up a .hi file first if it existed.]
+ -}
+
+pragma :: { ParseResult IfaceStuff }
+pragma : src_loc PRAGMA { parseIface $2 PState{ bol = 0#, atbol = 1#,
+ context = [],
+ glasgow_exts = 1#,
+ loc = $1 }
+ }
+
+-----------------------------------------------------------------------------
+
+rules_and_deprecs_part :: { ([RdrNameRuleDecl], IfaceDeprecs) }
+rules_and_deprecs_part : {- empty -} { ([], Nothing) }
+ | pragma { case $1 of
+ POk _ (PRulesAndDeprecs rds) -> rds
+ PFailed err -> pprPanic "Rules/Deprecations parse failed" err
+ }
+
+rules_and_deprecs :: { ([RdrNameRuleDecl], IfaceDeprecs) }
+rules_and_deprecs : rule_prag deprec_prag { ($1, $2) }
+
+
+-----------------------------------------------------------------------------
+
+rule_prag :: { [RdrNameRuleDecl] }
+rule_prag : {- empty -} { [] }
+ | '__R' rules { $2 }
+
+rules :: { [RdrNameRuleDecl] }
+ : {- empty -} { [] }
+ | rule ';' rules { $1:$3 }
+
+rule :: { RdrNameRuleDecl }
+rule : src_loc STRING rule_forall qvar_name
+ core_args '=' core_expr { IfaceRule $2 $3 $4 $5 $7 $1 }
+
+rule_forall :: { [UfBinder RdrName] }
+rule_forall : '__forall' '{' core_bndrs '}' { $3 }
+
+-----------------------------------------------------------------------------