+id_info :: { [HsIdInfo RdrName] }
+ : { [] }
+ | id_info_item id_info { $1 : $2 }
+
+id_info_item :: { HsIdInfo RdrName }
+ : '__A' INTEGER { HsArity (exactArity (fromInteger $2)) }
+ | '__U' inline_prag core_expr { HsUnfold $2 $3 }
+ | '__M' { HsCprInfo $1 }
+ | '__S' { HsStrictness (HsStrictnessInfo $1) }
+ | '__C' { HsNoCafRefs }
+ | '__P' qvar_name { HsWorker $2 }
+
+inline_prag :: { InlinePragInfo }
+ : {- empty -} { NoInlinePragInfo }
+ | '[' INTEGER ']' { IMustNotBeINLINEd True (Just (fromInteger $2)) } -- INLINE n
+ | '[' '!' INTEGER ']' { IMustNotBeINLINEd False (Just (fromInteger $3)) } -- NOINLINE n
+
+-------------------------------------------------------
+core_expr :: { UfExpr RdrName }
+core_expr : '\\' core_bndrs '->' core_expr { foldr UfLam $4 $2 }
+ | 'case' core_expr 'of' var_name
+ '{' core_alts '}' { UfCase $2 $4 $6 }
+
+ | 'let' '{' core_val_bndr '=' core_expr
+ '}' 'in' core_expr { UfLet (UfNonRec $3 $5) $8 }
+ | '__letrec' '{' rec_binds '}'
+ 'in' core_expr { UfLet (UfRec $3) $6 }
+
+ | con_or_primop '{' core_args '}' { UfCon $1 $3 }
+ | '__litlit' STRING atype { UfCon (UfLitLitCon $2 $3) [] }
+
+ | '__inline_me' core_expr { UfNote UfInlineMe $2 }
+ | '__inline_call' core_expr { UfNote UfInlineCall $2 }
+ | '__coerce' atype core_expr { UfNote (UfCoerce $2) $3 }
+ | scc core_expr { UfNote (UfSCC $1) $2 }
+ | fexpr { $1 }
+
+fexpr :: { UfExpr RdrName }
+fexpr : fexpr core_arg { UfApp $1 $2 }
+ | core_aexpr { $1 }
+
+core_arg :: { UfExpr RdrName }
+ : '@' atype { UfType $2 }
+ | core_aexpr { $1 }
+
+core_args :: { [UfExpr RdrName] }
+ : { [] }
+ | core_arg core_args { $1 : $2 }
+
+core_aexpr :: { UfExpr RdrName } -- Atomic expressions
+core_aexpr : qvar_name { UfVar $1 }
+
+ | qdata_name { UfVar $1 }
+ -- This one means that e.g. "True" will parse as
+ -- (UfVar True_Id) rather than (UfCon True_Con []).
+ -- No big deal; it'll be inlined in a jiffy. I tried
+ -- parsing it to (Con con []) directly, but got bitten
+ -- when a real constructor Id showed up in an interface
+ -- file. As usual, a hack bites you in the end.
+ -- If you want to get a UfCon, then use the
+ -- curly-bracket notation (True {}).
+
+ | core_lit { UfCon (UfLitCon $1) [] }
+ | '(' core_expr ')' { $2 }
+ | '(' comma_exprs2 ')' { UfTuple (mkTupConRdrName (length $2)) $2 }
+ | '(#' comma_exprs0 '#)' { UfTuple (mkUbxTupConRdrName (length $2)) $2 }
+
+-- This one is dealt with by qdata_name: see above comments
+-- | '(' ')' { UfTuple (mkTupConRdrName 0) [] }
+
+comma_exprs0 :: { [UfExpr RdrName] } -- Zero or more
+comma_exprs0 : {- empty -} { [ ] }
+ | core_expr { [ $1 ] }
+ | comma_exprs2 { $1 }
+
+comma_exprs2 :: { [UfExpr RdrName] } -- Two or more
+comma_exprs2 : core_expr ',' core_expr { [$1,$3] }
+ | core_expr ',' comma_exprs2 { $1 : $3 }
+
+con_or_primop :: { UfCon RdrName }
+con_or_primop : qdata_name { UfDataCon $1 }
+ | qvar_name { UfPrimOp $1 }
+ | '__ccall' ccall_string { let
+ (is_dyn, is_casm, may_gc) = $1
+ in
+ UfCCallOp $2 is_dyn is_casm may_gc
+ }
+
+rec_binds :: { [(UfBinder RdrName, UfExpr RdrName)] }
+ : { [] }
+ | core_val_bndr '=' core_expr ';' rec_binds { ($1,$3) : $5 }
+
+core_alts :: { [UfAlt RdrName] }
+ : core_alt { [$1] }
+ | core_alt ';' core_alts { $1 : $3 }
+
+core_alt :: { UfAlt RdrName }
+core_alt : core_pat '->' core_expr { (fst $1, snd $1, $3) }
+
+core_pat :: { (UfCon RdrName, [RdrName]) }
+core_pat : core_lit { (UfLitCon $1, []) }
+ | '__litlit' STRING atype { (UfLitLitCon $2 $3, []) }
+ | qdata_name core_pat_names { (UfDataCon $1, $2) }
+ | '(' comma_var_names1 ')' { (UfDataCon (mkTupConRdrName (length $2)), $2) }
+ | '(#' comma_var_names1 '#)' { (UfDataCon (mkUbxTupConRdrName (length $2)), $2) }
+ | '__DEFAULT' { (UfDefault, []) }
+ | '(' core_pat ')' { $2 }
+
+core_pat_names :: { [RdrName] }
+core_pat_names : { [] }
+ | core_pat_name core_pat_names { $1 : $2 }
+
+-- Tyvar names and variable names live in different name spaces
+-- so they need to be signalled separately. But we don't record
+-- types or kinds in a pattern; we work that out from the type
+-- of the case scrutinee
+core_pat_name :: { RdrName }
+core_pat_name : var_name { $1 }
+ | '@' tv_name { $2 }
+
+comma_var_names1 :: { [RdrName] } -- One or more
+comma_var_names1 : var_name { [$1] }
+ | var_name ',' comma_var_names1 { $1 : $3 }
+
+core_lit :: { Literal }
+core_lit : integer { mkMachInt_safe $1 }
+ | CHAR { MachChar $1 }
+ | STRING { MachStr $1 }
+ | '__string' STRING { NoRepStr $2 (panic "NoRepStr type") }
+ | rational { MachDouble $1 }
+ | '__float' rational { MachFloat $2 }
+
+ | '__integer' integer { NoRepInteger $2 (panic "NoRepInteger type")
+ -- The type checker will add the types
+ }
+
+ | '__rational' integer integer { NoRepRational ($2 % $3)
+ (panic "NoRepRational type")
+ -- The type checker will add the type
+ }
+
+ | '__addr' integer { MachAddr $2 }
+
+integer :: { Integer }
+ : INTEGER { $1 }
+ | '-' INTEGER { (-$2) }
+
+rational :: { Rational }
+ : RATIONAL { $1 }
+ | '-' RATIONAL { (-$2) }
+
+core_bndr :: { UfBinder RdrName }
+core_bndr : core_val_bndr { $1 }
+ | core_tv_bndr { $1 }
+
+core_bndrs :: { [UfBinder RdrName] }
+core_bndrs : { [] }
+ | core_bndr core_bndrs { $1 : $2 }
+
+core_val_bndr :: { UfBinder RdrName }
+core_val_bndr : var_name '::' atype { UfValBinder $1 $3 }
+
+core_tv_bndr :: { UfBinder RdrName }
+core_tv_bndr : '@' tv_name '::' akind { UfTyBinder $2 $4 }
+ | '@' tv_name { UfTyBinder $2 boxedTypeKind }
+
+ccall_string :: { FAST_STRING }
+ : STRING { $1 }
+ | CLITLIT { $1 }
+ | VARID { $1 }
+ | CONID { $1 }
+
+------------------------------------------------------------------------
+scc :: { CostCentre }
+ : '__sccC' '{' mod_name STRING '}' { AllCafsCC $3 $4 }
+ | '__scc' '{' cc_name mod_name STRING cc_dup cc_caf '}'
+ { NormalCC { cc_name = $3, cc_mod = $4, cc_grp = $5,
+ cc_is_dupd = $6, cc_is_caf = $7 } }
+
+cc_name :: { EncodedFS }
+ : CONID { $1 }
+ | var_fs { $1 }
+
+cc_dup :: { IsDupdCC }
+cc_dup : { OriginalCC }
+ | '!' { DupdCC }
+
+cc_caf :: { IsCafCC }
+ : { NotCafCC }
+ | '__C' { CafCC }
+
+-------------------------------------------------------------------
+
+src_loc :: { SrcLoc }
+src_loc : {% getSrcLocP }
+
+checkVersion :: { () }
+ : {-empty-} {% checkVersion Nothing }
+ | INTEGER {% checkVersion (Just (fromInteger $1)) }
+
+-------------------------------------------------------------------
+
+-- Haskell code