2 module ParseIface ( parseIface, IfaceStuff(..) ) where
4 #include "HsVersions.h"
6 import HsSyn -- quite a bit of stuff
7 import RdrHsSyn -- oodles of synonyms
8 import HsTypes ( mkHsForAllTy, mkHsUsForAllTy )
10 import Literal ( Literal(..), mkMachInt, mkMachInt64, mkMachWord, mkMachWord64 )
11 import BasicTypes ( Fixity(..), FixityDirection(..),
12 NewOrData(..), Version
14 import CostCentre ( CostCentre(..), IsCafCC(..), IsDupdCC(..) )
15 import CallConv ( cCallConv )
16 import HsPragmas ( noDataPragmas, noClassPragmas )
17 import Type ( Kind, mkArrowKind, boxedTypeKind, openTypeKind, UsageAnn(..) )
18 import IdInfo ( ArityInfo, exactArity, CprInfo(..), InlinePragInfo(..) )
19 import PrimOp ( CCall(..), CCallTarget(..) )
22 import RnMonad ( ImportVersion, LocalVersion, ParsedIface(..), WhatsImported(..),
23 RdrNamePragma, ExportItem, RdrAvailInfo, GenAvailInfo(..),
24 WhetherHasOrphans, IsBootInterface
26 import Bag ( emptyBag, unitBag, snocBag )
27 import FiniteMap ( emptyFM, unitFM, addToFM, plusFM, bagToFM, FiniteMap )
28 import RdrName ( RdrName, mkRdrUnqual, mkSysQual, mkSysUnqual, mkRdrNameWkr )
29 import Name ( OccName, Provenance )
30 import OccName ( mkSysOccFS,
31 tcName, varName, ipName, dataName, clsName, tvName, uvName,
34 import Module ( ModuleName, mkSysModuleFS )
35 import PrelInfo ( mkTupConRdrName, mkUbxTupConRdrName )
36 import SrcLoc ( SrcLoc )
41 import FastString ( tailFS )
50 %monad { P }{ thenP }{ returnP }
51 %lexer { lexer } { ITeof }
54 'case' { ITcase } -- Haskell keywords
57 'default' { ITdefault }
58 'deriving' { ITderiving }
67 'instance' { ITinstance }
70 'newtype' { ITnewtype }
76 'qualified' { ITqualified }
79 'forall' { ITforall } -- GHC extension keywords
80 'foreign' { ITforeign }
83 'dynamic' { ITdynamic }
87 '__interface' { ITinterface } -- interface keywords
88 '__export' { IT__export }
89 '__forall' { IT__forall }
90 '__depends' { ITdepends }
91 '__letrec' { ITletrec }
92 '__coerce' { ITcoerce }
93 '__inline_call'{ ITinlineCall }
94 '__inline_me' { ITinlineMe }
95 '__DEFAULT' { ITdefaultbranch }
97 '__integer' { ITinteger_lit }
98 '__float' { ITfloat_lit }
99 '__word' { ITword_lit }
100 '__int64' { ITint64_lit }
101 '__word64' { ITword64_lit }
102 '__rational' { ITrational_lit }
103 '__addr' { ITaddr_lit }
104 '__litlit' { ITlit_lit }
105 '__string' { ITstring_lit }
106 '__ccall' { ITccall $$ }
108 '__sccC' { ITsccAllCafs }
111 '__fuall' { ITfuall }
114 '__P' { ITspecialise }
116 '__U' { ITunfold $$ }
117 '__S' { ITstrict $$ }
120 '__D' { ITdeprecated }
122 '..' { ITdotdot } -- reserved symbols
135 '/\\' { ITbiglam } -- GHC-extension symbols
137 '{' { ITocurly } -- special symbols
148 VARID { ITvarid $$ } -- identifiers
150 VARSYM { ITvarsym $$ }
151 CONSYM { ITconsym $$ }
152 QVARID { ITqvarid $$ }
153 QCONID { ITqconid $$ }
154 QVARSYM { ITqvarsym $$ }
155 QCONSYM { ITqconsym $$ }
157 IPVARID { ITipvarid $$ } -- GHC extension
159 PRAGMA { ITpragma $$ }
162 STRING { ITstring $$ }
163 INTEGER { ITinteger $$ }
164 RATIONAL { ITrational $$ }
165 CLITLIT { ITlitlit $$ }
167 UNKNOWN { ITunknown $$ }
170 -- iface_stuff is the main production.
171 -- It recognises (a) a whole interface file
172 -- (b) a type (so that type sigs can be parsed lazily)
173 -- (c) the IdInfo part of a signature (same reason)
175 iface_stuff :: { IfaceStuff }
176 iface_stuff : iface { let (nm, iff) = $1 in PIface nm iff }
178 | id_info { PIdInfo $1 }
179 | '__R' rules { PRules $2 }
180 | '__D' deprecs { PDeprecs $2 }
183 iface :: { (ModuleName, ParsedIface) }
184 iface : '__interface' mod_fs INTEGER orphans checkVersion 'where'
190 { ( $2 -- Module name
192 pi_mod = fromInteger $3, -- Module version
194 pi_exports = $7, -- Exports
195 pi_usages = $8, -- Usages
196 pi_insts = $9, -- Local instances
197 pi_decls = $10, -- Decls
198 pi_rules = fst $11, -- Rules
199 pi_deprecs = snd $11 -- Deprecations
202 --------------------------------------------------------------------------
204 import_part :: { [ImportVersion OccName] }
206 | import_part import_decl { $2 : $1 }
208 import_decl :: { ImportVersion OccName }
209 import_decl : 'import' mod_fs INTEGER orphans is_boot whats_imported ';'
210 { (mkSysModuleFS $2, fromInteger $3, $4, $5, $6) }
211 -- import Foo 3 :: a 1 b 3 c 7 ; means import a,b,c from Foo
212 -- import Foo 3 ; means import all of Foo
213 -- import Foo 3 ! @ :: ...stuff... ; the ! means that Foo contains orphans
214 -- and @ that Foo is a boot interface
216 orphans :: { WhetherHasOrphans }
220 is_boot :: { IsBootInterface }
224 whats_imported :: { WhatsImported OccName }
225 whats_imported : { Everything }
226 | '::' name_version_pairs { Specifically $2 }
228 name_version_pairs :: { [LocalVersion OccName] }
229 name_version_pairs : { [] }
230 | name_version_pair name_version_pairs { $1 : $2 }
232 name_version_pair :: { LocalVersion OccName }
233 name_version_pair : var_occ INTEGER { ($1, fromInteger $2) }
234 | tc_occ INTEGER { ($1, fromInteger $2) }
237 --------------------------------------------------------------------------
239 exports_part :: { [ExportItem] }
240 exports_part : { [] }
241 | exports_part '__export'
242 mod_fs entities ';' { (mkSysModuleFS $3, $4) : $1 }
244 entities :: { [RdrAvailInfo] }
246 | entity entities { $1 : $2 }
248 entity :: { RdrAvailInfo }
249 entity : tc_occ { AvailTC $1 [$1] }
250 | var_occ { Avail $1 }
251 | tc_occ stuff_inside { AvailTC $1 ($1:$2) }
252 | tc_occ '|' stuff_inside { AvailTC $1 $3 }
254 stuff_inside :: { [OccName] }
255 stuff_inside : '{' val_occs '}' { $2 }
257 val_occ :: { OccName }
261 val_occs :: { [OccName] }
263 | val_occ val_occs { $1 : $2 }
266 --------------------------------------------------------------------------
268 fixity :: { FixityDirection }
269 fixity : 'infixl' { InfixL }
270 | 'infixr' { InfixR }
274 mb_fix : {-nothing-} { 9 }
275 | INTEGER { (fromInteger $1) }
277 -----------------------------------------------------------------------------
279 csigs :: { [RdrNameSig] }
281 | 'where' '{' csigs1 '}' { $3 }
283 csigs1 :: { [RdrNameSig] }
284 csigs1 : csig { [$1] }
285 | csig ';' csigs1 { $1 : $3 }
287 csig :: { RdrNameSig }
288 csig : src_loc var_name '::' type { mkClassOpSig False $2 $4 $1 }
289 | src_loc var_name '=' '::' type { mkClassOpSig True $2 $5 $1 }
291 --------------------------------------------------------------------------
293 instance_decl_part :: { [RdrNameInstDecl] }
294 instance_decl_part : {- empty -} { [] }
295 | instance_decl_part inst_decl { $2 : $1 }
297 inst_decl :: { RdrNameInstDecl }
298 inst_decl : src_loc 'instance' type '=' var_name ';'
300 EmptyMonoBinds {- No bindings -}
301 [] {- No user pragmas -}
306 --------------------------------------------------------------------------
308 decls_part :: { [(Version, RdrNameHsDecl)] }
311 | decls_part version decl ';' { ($2,$3):$1 }
313 decl :: { RdrNameHsDecl }
314 decl : src_loc var_name '::' type maybe_idinfo
315 { SigD (IfaceSig $2 $4 ($5 $2) $1) }
316 | src_loc 'type' tc_name tv_bndrs '=' type
317 { TyClD (TySynonym $3 $4 $6 $1) }
318 | src_loc 'data' decl_context tc_name tv_bndrs constrs
319 { TyClD (TyData DataType $3 $4 $5 $6 Nothing noDataPragmas $1) }
320 | src_loc 'newtype' decl_context tc_name tv_bndrs newtype_constr
321 { TyClD (TyData NewType $3 $4 $5 $6 Nothing noDataPragmas $1) }
322 | src_loc 'class' decl_context tc_name tv_bndrs fds csigs
323 { TyClD (mkClassDecl $3 $4 $5 $6 $7 EmptyMonoBinds
325 | src_loc fixity mb_fix var_or_data_name
326 { FixD (FixitySig $4 (Fixity $3 $2) $1) }
328 maybe_idinfo :: { RdrName -> [HsIdInfo RdrName] }
329 maybe_idinfo : {- empty -} { \_ -> [] }
330 | pragma { \x -> case $1 of
331 POk _ (PIdInfo id_info) -> id_info
333 pprPanic "IdInfo parse failed"
337 pragma :: { ParseResult IfaceStuff }
338 pragma : src_loc PRAGMA { parseIface $2 PState{ bol = 0#, atbol = 1#,
344 -----------------------------------------------------------------------------
346 rules_and_deprecs :: { ([RdrNameRuleDecl], [RdrNameDeprecation]) }
347 rules_and_deprecs : {- empty -} { ([], []) }
348 | rules_and_deprecs rule_or_deprec
350 append2 (xs1,ys1) (xs2,ys2) =
351 (xs1 `app` xs2, ys1 `app` ys2)
352 xs `app` [] = xs -- performance paranoia
353 xs `app` ys = xs ++ ys
357 rule_or_deprec :: { ([RdrNameRuleDecl], [RdrNameDeprecation]) }
358 rule_or_deprec : pragma { case $1 of
359 POk _ (PRules rules) -> (rules,[])
360 POk _ (PDeprecs deprecs) -> ([],deprecs)
361 PFailed err -> pprPanic "Rules/Deprecations parse failed" err
364 -----------------------------------------------------------------------------
366 rules :: { [RdrNameRuleDecl] }
368 | rule ';' rules { $1:$3 }
370 rule :: { RdrNameRuleDecl }
371 rule : src_loc STRING rule_forall qvar_name
372 core_args '=' core_expr { IfaceRuleDecl $4 (UfRuleBody $2 $3 $5 $7) $1 }
374 rule_forall :: { [UfBinder RdrName] }
375 rule_forall : '__forall' '{' core_bndrs '}' { $3 }
377 -----------------------------------------------------------------------------
379 deprecs :: { [RdrNameDeprecation] }
380 deprecs : {- empty -} { [] }
381 | deprecs deprec ';' { $2 : $1 }
383 deprec :: { RdrNameDeprecation }
384 deprec : STRING { Deprecation (IEModuleContents undefined) $1 }
385 | deprec_name STRING { Deprecation $1 $2 }
387 -- SUP: TEMPORARY HACK
388 deprec_name :: { RdrNameIE }
389 : var_name { IEVar $1 }
390 | data_name { IEThingAbs $1 }
392 -----------------------------------------------------------------------------
394 version :: { Version }
395 version : INTEGER { fromInteger $1 }
397 decl_context :: { RdrNameContext }
398 decl_context : { [] }
399 | '{' context_list1 '}' '=>' { $2 }
401 ----------------------------------------------------------------------------
403 constrs :: { [RdrNameConDecl] {- empty for handwritten abstract -} }
405 | '=' constrs1 { $2 }
407 constrs1 :: { [RdrNameConDecl] }
408 constrs1 : constr { [$1] }
409 | constr '|' constrs1 { $1 : $3 }
411 constr :: { RdrNameConDecl }
412 constr : src_loc ex_stuff data_name batypes { mk_con_decl $3 $2 (VanillaCon $4) $1 }
413 | src_loc ex_stuff data_name '{' fields1 '}' { mk_con_decl $3 $2 (RecCon $5) $1 }
414 -- We use "data_fs" so as to include ()
416 newtype_constr :: { [RdrNameConDecl] {- Empty if handwritten abstract -} }
417 newtype_constr : { [] }
418 | src_loc '=' ex_stuff data_name atype { [mk_con_decl $4 $3 (NewCon $5 Nothing) $1] }
419 | src_loc '=' ex_stuff data_name '{' var_name '::' atype '}'
420 { [mk_con_decl $4 $3 (NewCon $8 (Just $6)) $1] }
422 ex_stuff :: { ([HsTyVar RdrName], RdrNameContext) }
423 ex_stuff : { ([],[]) }
424 | '__forall' forall context '=>' { ($2,$3) }
426 batypes :: { [RdrNameBangType] }
428 | batype batypes { $1 : $2 }
430 batype :: { RdrNameBangType }
431 batype : atype { Unbanged $1 }
432 | '!' atype { Banged $2 }
433 | '!' '!' atype { Unpacked $3 }
435 fields1 :: { [([RdrName], RdrNameBangType)] }
436 fields1 : field { [$1] }
437 | field ',' fields1 { $1 : $3 }
439 field :: { ([RdrName], RdrNameBangType) }
440 field : var_names1 '::' type { ($1, Unbanged $3) }
441 | var_names1 '::' '!' type { ($1, Banged $4) }
442 | var_names1 '::' '!' '!' type { ($1, Unpacked $5) }
443 --------------------------------------------------------------------------
445 type :: { RdrNameHsType }
446 type : '__fuall' fuall '=>' type { mkHsUsForAllTy $2 $4 }
447 | '__forall' forall context '=>' type
448 { mkHsForAllTy (Just $2) $3 $5 }
449 | btype '->' type { MonoFunTy $1 $3 }
452 fuall :: { [RdrName] }
453 fuall : '[' uv_bndrs ']' { $2 }
455 forall :: { [HsTyVar RdrName] }
456 forall : '[' tv_bndrs ']' { $2 }
458 context :: { RdrNameContext }
460 | '{' context_list1 '}' { $2 }
462 context_list1 :: { RdrNameContext }
463 context_list1 : class { [$1] }
464 | class ',' context_list1 { $1 : $3 }
466 class :: { HsPred RdrName }
467 class : qcls_name atypes { (HsPClass $1 $2) }
468 | ipvar_name '::' type { (HsPIParam $1 $3) }
470 types0 :: { [RdrNameHsType] {- Zero or more -} }
471 types0 : {- empty -} { [ ] }
475 types2 :: { [RdrNameHsType] {- Two or more -} }
476 types2 : type ',' type { [$1,$3] }
477 | type ',' types2 { $1 : $3 }
479 btype :: { RdrNameHsType }
481 | btype atype { MonoTyApp $1 $2 }
482 | '__u' usage atype { MonoUsgTy $2 $3 }
484 usage :: { MonoUsageAnn RdrName }
485 usage : '-' { MonoUsOnce }
487 | uv_name { MonoUsVar $1 }
489 atype :: { RdrNameHsType }
490 atype : qtc_name { MonoTyVar $1 }
491 | tv_name { MonoTyVar $1 }
492 | '(' types2 ')' { MonoTupleTy $2 True{-boxed-} }
493 | '(#' types0 '#)' { MonoTupleTy $2 False{-unboxed-} }
494 | '[' type ']' { MonoListTy $2 }
495 | '{' qcls_name atypes '}' { MonoDictTy $2 $3 }
496 | '{' ipvar_name '::' type '}' { MonoIParamTy $2 $4 }
497 | '(' type ')' { $2 }
499 -- This one is dealt with via qtc_name
500 -- | '(' ')' { MonoTupleTy [] True }
502 atypes :: { [RdrNameHsType] {- Zero or more -} }
504 | atype atypes { $1 : $2 }
505 ---------------------------------------------------------------------
506 mod_fs :: { EncodedFS }
509 mod_name :: { ModuleName }
510 : mod_fs { mkSysModuleFS $1 }
513 ---------------------------------------------------
514 var_fs :: { EncodedFS }
517 | 'as' { SLIT("as") }
518 | 'qualified' { SLIT("qualified") }
519 | 'hiding' { SLIT("hiding") }
520 | 'forall' { SLIT("forall") }
521 | 'foreign' { SLIT("foreign") }
522 | 'export' { SLIT("export") }
523 | 'label' { SLIT("label") }
524 | 'dynamic' { SLIT("dynamic") }
525 | 'unsafe' { SLIT("unsafe") }
526 | 'with' { SLIT("with") }
528 qvar_fs :: { (EncodedFS, EncodedFS) }
532 var_occ :: { OccName }
533 : var_fs { mkSysOccFS varName $1 }
535 var_name :: { RdrName }
536 var_name : var_occ { mkRdrUnqual $1 }
538 qvar_name :: { RdrName }
539 qvar_name : var_name { $1 }
540 | qvar_fs { mkSysQual varName $1 }
542 ipvar_name :: { RdrName }
543 : IPVARID { mkSysUnqual ipName (tailFS $1) }
545 var_names :: { [RdrName] }
547 | var_name var_names { $1 : $2 }
549 var_names1 :: { [RdrName] }
550 var_names1 : var_name var_names { $1 : $2 }
552 ---------------------------------------------------
553 -- For some bizarre reason,
554 -- (,,,) is dealt with by the parser
555 -- Foo.(,,,) is dealt with by the lexer
558 data_fs :: { EncodedFS }
562 qdata_fs :: { (EncodedFS, EncodedFS) }
566 data_occ :: { OccName }
567 : data_fs { mkSysOccFS dataName $1 }
569 data_name :: { RdrName }
570 : data_occ { mkRdrUnqual $1 }
572 qdata_name :: { RdrName }
573 qdata_name : data_name { $1 }
574 | qdata_fs { mkSysQual dataName $1 }
576 qdata_names :: { [RdrName] }
578 | qdata_name qdata_names { $1 : $2 }
580 var_or_data_name :: { RdrName }
584 ---------------------------------------------------
585 tc_fs :: { EncodedFS }
588 tc_occ :: { OccName }
589 : tc_fs { mkSysOccFS tcName $1 }
591 tc_name :: { RdrName }
592 : tc_occ { mkRdrUnqual $1 }
594 qtc_name :: { RdrName }
596 | qdata_fs { mkSysQual tcName $1 }
598 ---------------------------------------------------
599 cls_name :: { RdrName }
600 : data_fs { mkSysUnqual clsName $1 }
602 qcls_name :: { RdrName }
604 | qdata_fs { mkSysQual clsName $1 }
606 ---------------------------------------------------
607 uv_name :: { RdrName }
608 : VARID { mkSysUnqual uvName $1 }
610 uv_bndr :: { RdrName }
613 uv_bndrs :: { [RdrName] }
615 | uv_bndr uv_bndrs { $1 : $2 }
617 ---------------------------------------------------
618 tv_name :: { RdrName }
619 : VARID { mkSysUnqual tvName $1 }
620 | VARSYM { mkSysUnqual tvName $1 {- Allow t2 as a tyvar -} }
622 tv_bndr :: { HsTyVar RdrName }
623 : tv_name '::' akind { IfaceTyVar $1 $3 }
624 | tv_name { IfaceTyVar $1 boxedTypeKind }
626 tv_bndrs :: { [HsTyVar RdrName] }
628 | tv_bndr tv_bndrs { $1 : $2 }
630 ---------------------------------------------------
631 fds :: { [([RdrName], [RdrName])] }
633 | '|' fds1 { reverse $2 }
635 fds1 :: { [([RdrName], [RdrName])] }
636 : fds1 ',' fd { $3 : $1 }
639 fd :: { ([RdrName], [RdrName]) }
640 : varids0 '->' varids0 { (reverse $1, reverse $3) }
642 varids0 :: { [RdrName] }
644 | varids0 tv_name { $2 : $1 }
646 ---------------------------------------------------
649 | akind '->' kind { mkArrowKind $1 $3 }
652 : VARSYM { if $1 == SLIT("*") then
654 else if $1 == SLIT("?") then
656 else panic "ParseInterface: akind"
658 | '(' kind ')' { $2 }
660 --------------------------------------------------------------------------
662 id_info :: { [HsIdInfo RdrName] }
664 | id_info_item id_info { $1 : $2 }
666 id_info_item :: { HsIdInfo RdrName }
667 : '__A' INTEGER { HsArity (exactArity (fromInteger $2)) }
668 | '__U' inline_prag core_expr { HsUnfold $2 $3 }
669 | '__M' { HsCprInfo }
670 | '__S' { HsStrictness (HsStrictnessInfo $1) }
671 | '__C' { HsNoCafRefs }
672 | '__P' qvar_name { HsWorker $2 }
674 inline_prag :: { InlinePragInfo }
675 : {- empty -} { NoInlinePragInfo }
676 | '[' INTEGER ']' { IMustNotBeINLINEd True (Just (fromInteger $2)) } -- INLINE n
677 | '[' '!' INTEGER ']' { IMustNotBeINLINEd False (Just (fromInteger $3)) } -- NOINLINE n
679 -------------------------------------------------------
680 core_expr :: { UfExpr RdrName }
681 core_expr : '\\' core_bndrs '->' core_expr { foldr UfLam $4 $2 }
682 | 'case' core_expr 'of' var_name
683 '{' core_alts '}' { UfCase $2 $4 $6 }
685 | 'let' '{' core_val_bndr '=' core_expr
686 '}' 'in' core_expr { UfLet (UfNonRec $3 $5) $8 }
687 | '__letrec' '{' rec_binds '}'
688 'in' core_expr { UfLet (UfRec $3) $6 }
690 | '__litlit' STRING atype { UfLitLit $2 $3 }
692 | '__inline_me' core_expr { UfNote UfInlineMe $2 }
693 | '__inline_call' core_expr { UfNote UfInlineCall $2 }
694 | '__coerce' atype core_expr { UfNote (UfCoerce $2) $3 }
695 | scc core_expr { UfNote (UfSCC $1) $2 }
698 fexpr :: { UfExpr RdrName }
699 fexpr : fexpr core_arg { UfApp $1 $2 }
702 core_arg :: { UfExpr RdrName }
703 : '@' atype { UfType $2 }
706 core_args :: { [UfExpr RdrName] }
708 | core_arg core_args { $1 : $2 }
710 core_aexpr :: { UfExpr RdrName } -- Atomic expressions
711 core_aexpr : qvar_name { UfVar $1 }
712 | qdata_name { UfVar $1 }
713 -- This one means that e.g. "True" will parse as
714 -- (UfVar True_Id) rather than (UfCon True_Con []).
715 -- No big deal; it'll be inlined in a jiffy. I tried
716 -- parsing it to (Con con []) directly, but got bitten
717 -- when a real constructor Id showed up in an interface
718 -- file. As usual, a hack bites you in the end.
719 -- If you want to get a UfCon, then use the
720 -- curly-bracket notation (True {}).
722 -- This one is dealt with by qdata_name: see above comments
723 -- | '(' ')' { UfTuple (mkTupConRdrName 0) [] }
725 | core_lit { UfLit $1 }
726 | '(' core_expr ')' { $2 }
728 -- Tuple construtors are for the *worker* of the tuple
729 -- Going direct saves needless messing about
730 | '(' comma_exprs2 ')' { UfTuple (mkRdrNameWkr (mkTupConRdrName (length $2))) $2 }
731 | '(#' comma_exprs0 '#)' { UfTuple (mkRdrNameWkr (mkUbxTupConRdrName (length $2))) $2 }
733 | '{' '__ccall' ccall_string type '}'
735 (is_dyn, is_casm, may_gc) = $2
737 target | is_dyn = DynamicTarget (error "CCall dyn target bogus unique")
738 | otherwise = StaticTarget $3
740 ccall = CCall target is_casm may_gc cCallConv
746 comma_exprs0 :: { [UfExpr RdrName] } -- Zero or more
747 comma_exprs0 : {- empty -} { [ ] }
748 | core_expr { [ $1 ] }
749 | comma_exprs2 { $1 }
751 comma_exprs2 :: { [UfExpr RdrName] } -- Two or more
752 comma_exprs2 : core_expr ',' core_expr { [$1,$3] }
753 | core_expr ',' comma_exprs2 { $1 : $3 }
755 rec_binds :: { [(UfBinder RdrName, UfExpr RdrName)] }
757 | core_val_bndr '=' core_expr ';' rec_binds { ($1,$3) : $5 }
759 core_alts :: { [UfAlt RdrName] }
761 | core_alt ';' core_alts { $1 : $3 }
763 core_alt :: { UfAlt RdrName }
764 core_alt : core_pat '->' core_expr { (fst $1, snd $1, $3) }
766 core_pat :: { (UfConAlt RdrName, [RdrName]) }
767 core_pat : core_lit { (UfLitAlt $1, []) }
768 | '__litlit' STRING atype { (UfLitLitAlt $2 $3, []) }
769 | qdata_name core_pat_names { (UfDataAlt $1, $2) }
770 | '(' comma_var_names1 ')' { (UfDataAlt (mkTupConRdrName (length $2)), $2) }
771 | '(#' comma_var_names1 '#)' { (UfDataAlt (mkUbxTupConRdrName (length $2)), $2) }
772 | '__DEFAULT' { (UfDefault, []) }
773 | '(' core_pat ')' { $2 }
775 core_pat_names :: { [RdrName] }
776 core_pat_names : { [] }
777 | core_pat_name core_pat_names { $1 : $2 }
779 -- Tyvar names and variable names live in different name spaces
780 -- so they need to be signalled separately. But we don't record
781 -- types or kinds in a pattern; we work that out from the type
782 -- of the case scrutinee
783 core_pat_name :: { RdrName }
784 core_pat_name : var_name { $1 }
787 comma_var_names1 :: { [RdrName] } -- One or more
788 comma_var_names1 : var_name { [$1] }
789 | var_name ',' comma_var_names1 { $1 : $3 }
791 core_lit :: { Literal }
792 core_lit : integer { mkMachInt $1 }
793 | CHAR { MachChar $1 }
794 | STRING { MachStr $1 }
795 | rational { MachDouble $1 }
796 | '__word' integer { mkMachWord $2 }
797 | '__word64' integer { mkMachWord64 $2 }
798 | '__int64' integer { mkMachInt64 $2 }
799 | '__float' rational { MachFloat $2 }
800 | '__addr' integer { MachAddr $2 }
802 integer :: { Integer }
804 | '-' INTEGER { (-$2) }
806 rational :: { Rational }
808 | '-' RATIONAL { (-$2) }
810 core_bndr :: { UfBinder RdrName }
811 core_bndr : core_val_bndr { $1 }
812 | core_tv_bndr { $1 }
814 core_bndrs :: { [UfBinder RdrName] }
816 | core_bndr core_bndrs { $1 : $2 }
818 core_val_bndr :: { UfBinder RdrName }
819 core_val_bndr : var_name '::' atype { UfValBinder $1 $3 }
821 core_tv_bndr :: { UfBinder RdrName }
822 core_tv_bndr : '@' tv_name '::' akind { UfTyBinder $2 $4 }
823 | '@' tv_name { UfTyBinder $2 boxedTypeKind }
825 ccall_string :: { FAST_STRING }
831 ------------------------------------------------------------------------
832 scc :: { CostCentre }
833 : '__sccC' '{' mod_name '}' { AllCafsCC $3 }
834 | '__scc' '{' cc_name mod_name cc_dup cc_caf '}'
835 { NormalCC { cc_name = $3, cc_mod = $4,
836 cc_is_dupd = $5, cc_is_caf = $6 } }
838 cc_name :: { EncodedFS }
842 cc_dup :: { IsDupdCC }
843 cc_dup : { OriginalCC }
846 cc_caf :: { IsCafCC }
850 -------------------------------------------------------------------
852 src_loc :: { SrcLoc }
853 src_loc : {% getSrcLocP }
855 checkVersion :: { () }
856 : {-empty-} {% checkVersion Nothing }
857 | INTEGER {% checkVersion (Just (fromInteger $1)) }
859 -------------------------------------------------------------------
864 happyError buf PState{ loc = loc } = PFailed (ifaceParseErr buf loc)
866 data IfaceStuff = PIface EncodedFS{-.hi module name-} ParsedIface
867 | PIdInfo [HsIdInfo RdrName]
868 | PType RdrNameHsType
869 | PRules [RdrNameRuleDecl]
870 | PDeprecs [RdrNameDeprecation]
872 mk_con_decl name (ex_tvs, ex_ctxt) details loc = mkConDecl name ex_tvs ex_ctxt details loc