+id_info :: { [HsIdInfo RdrName] }
+ : id_info_item { [$1] }
+ | 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 }
+ | '__S' { HsStrictness (mkStrictnessInfo $1) }
+ | '__C' { HsNoCafRefs }
+ | '__P' qvar_name { HsWorker $2 }
+
+inline_prag :: { InlinePragInfo }
+ : {- empty -} { NoInlinePragInfo }
+ | '[' from_prag phase ']' { IMustNotBeINLINEd $2 $3 }
+
+from_prag :: { Bool }
+ : {- empty -} { True }
+ | '!' { False }
+
+phase :: { Maybe Int }
+ : {- empty -} { Nothing }
+ | INTEGER { Just (fromInteger $1) }
+
+-------------------------------------------------------
+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 }
+
+ | '__litlit' STRING atype { UfLitLit $2 $3 }
+
+ | fexpr { $1 }
+
+fexpr :: { UfExpr RdrName }
+fexpr : fexpr core_arg { UfApp $1 $2 }
+ | scc core_aexpr { UfNote (UfSCC $1) $2 }
+ | '__inline_me' core_aexpr { UfNote UfInlineMe $2 }
+ | '__inline_call' core_aexpr { UfNote UfInlineCall $2 }
+ | '__coerce' atype core_aexpr { UfNote (UfCoerce $2) $3 }
+ | 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 }
+
+ | core_lit { UfLit $1 }
+ | '(' core_expr ')' { $2 }
+
+ | '(' ')' { UfTuple (mkHsTupCon dataName Boxed []) [] }
+ | '(' comma_exprs2 ')' { UfTuple (mkHsTupCon dataName Boxed $2) $2 }
+ | '(#' comma_exprs0 '#)' { UfTuple (mkHsTupCon dataName Unboxed $2) $2 }
+
+ | '{' '__ccall' ccall_string type '}'
+ { let
+ (is_dyn, is_casm, may_gc) = $2
+
+ target | is_dyn = DynamicTarget (error "CCall dyn target bogus unique")
+ | otherwise = StaticTarget $3
+
+ ccall = CCall target is_casm may_gc cCallConv
+ in
+ UfCCall ccall $4
+ }
+
+
+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 }
+
+rec_binds :: { [(UfBinder RdrName, UfExpr RdrName)] }
+ : { [] }
+ | core_val_bndr '=' core_expr ';' rec_binds { ($1,$3) : $5 }
+
+core_alts :: { [UfAlt RdrName] }
+ : { [] }
+ | core_alt ';' core_alts { $1 : $3 }
+
+core_alt :: { UfAlt RdrName }
+core_alt : core_pat '->' core_expr { (fst $1, snd $1, $3) }
+
+core_pat :: { (UfConAlt RdrName, [RdrName]) }
+core_pat : core_lit { (UfLitAlt $1, []) }
+ | '__litlit' STRING atype { (UfLitLitAlt $2 $3, []) }
+ | qdata_name core_pat_names { (UfDataAlt $1, $2) }
+ | '(' ')' { (UfTupleAlt (mkHsTupCon dataName Boxed []), []) }
+ | '(' comma_var_names1 ')' { (UfTupleAlt (mkHsTupCon dataName Boxed $2), $2) }
+ | '(#' comma_var_names1 '#)' { (UfTupleAlt (mkHsTupCon dataName Unboxed $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 $1 }
+ | CHAR { MachChar $1 }
+ | STRING { MachStr $1 }
+ | rational { MachDouble $1 }
+ | '__word' integer { mkMachWord $2 }
+ | '__word64' integer { mkMachWord64 $2 }
+ | '__int64' integer { mkMachInt64 $2 }
+ | '__float' rational { MachFloat $2 }
+ | '__addr' integer { MachAddr $2 }
+ | '__label' STRING { MachLabel $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 '}' { AllCafsCC $3 }
+ | '__scc' '{' cc_name mod_name cc_dup cc_caf '}'
+ { NormalCC { cc_name = $3, cc_mod = $4,
+ cc_is_dupd = $5, cc_is_caf = $6 } }
+
+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 }
+
+-- Check the project version: this makes sure
+-- that the project version (e.g. 407) in the interface
+-- file is the same as that for the compiler that's reading it
+checkVersion :: { () }
+ : {-empty-} {% checkVersion Nothing }
+ | INTEGER {% checkVersion (Just (fromInteger $1)) }
+
+-------------------------------------------------------------------
+
+-- Haskell code
+{
+happyError :: P a
+happyError buf PState{ loc = loc } = PFailed (ifaceParseErr buf loc)