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 }
55 'case' { ITcase } -- Haskell keywords
58 'default' { ITdefault }
59 'deriving' { ITderiving }
69 'instance' { ITinstance }
72 'newtype' { ITnewtype }
74 'qualified' { ITqualified }
78 --???? 'scc' { ITscc }
80 'forall' { ITforall } -- GHC extension keywords
81 'foreign' { ITforeign }
84 'dynamic' { ITdynamic }
87 'stdcall' { ITstdcallconv }
88 'ccall' { ITccallconv }
90 '__interface' { ITinterface } -- interface keywords
91 '__export' { IT__export }
92 '__depends' { ITdepends }
93 '__forall' { IT__forall }
94 '__letrec' { ITletrec }
95 '__coerce' { ITcoerce }
96 '__inline_me' { ITinlineMe }
97 '__inline_call'{ ITinlineCall }
98 '__DEFAULT' { ITdefaultbranch }
100 '__integer' { ITinteger_lit }
101 '__float' { ITfloat_lit }
102 '__word' { ITword_lit }
103 '__int64' { ITint64_lit }
104 '__word64' { ITword64_lit }
105 '__rational' { ITrational_lit }
106 '__addr' { ITaddr_lit }
107 '__litlit' { ITlit_lit }
108 '__string' { ITstring_lit }
109 '__ccall' { ITccall $$ }
111 '__sccC' { ITsccAllCafs }
114 '__fuall' { ITfuall }
117 '__P' { ITspecialise }
119 '__U' { ITunfold $$ }
120 '__S' { ITstrict $$ }
123 '__D' { ITdeprecated }
125 '..' { ITdotdot } -- reserved symbols
138 '/\\' { ITbiglam } -- GHC-extension symbols
140 '{' { ITocurly } -- special symbols
151 VARID { ITvarid $$ } -- identifiers
153 VARSYM { ITvarsym $$ }
154 CONSYM { ITconsym $$ }
155 QVARID { ITqvarid $$ }
156 QCONID { ITqconid $$ }
157 QVARSYM { ITqvarsym $$ }
158 QCONSYM { ITqconsym $$ }
160 IPVARID { ITipvarid $$ } -- GHC extension
162 PRAGMA { ITpragma $$ }
165 STRING { ITstring $$ }
166 INTEGER { ITinteger $$ }
167 RATIONAL { ITrational $$ }
168 CLITLIT { ITlitlit $$ }
170 UNKNOWN { ITunknown $$ }
173 -- iface_stuff is the main production.
174 -- It recognises (a) a whole interface file
175 -- (b) a type (so that type sigs can be parsed lazily)
176 -- (c) the IdInfo part of a signature (same reason)
178 iface_stuff :: { IfaceStuff }
179 iface_stuff : iface { let (nm, iff) = $1 in PIface nm iff }
181 | id_info { PIdInfo $1 }
182 | '__R' rules { PRules $2 }
183 | '__D' deprecs { PDeprecs $2 }
186 iface :: { (ModuleName, ParsedIface) }
187 iface : '__interface' mod_fs INTEGER orphans checkVersion 'where'
193 { ( $2 -- Module name
195 pi_mod = fromInteger $3, -- Module version
197 pi_exports = $7, -- Exports
198 pi_usages = $8, -- Usages
199 pi_insts = $9, -- Local instances
200 pi_decls = $10, -- Decls
201 pi_rules = fst $11, -- Rules
202 pi_deprecs = snd $11 -- Deprecations
205 --------------------------------------------------------------------------
207 import_part :: { [ImportVersion OccName] }
209 | import_part import_decl { $2 : $1 }
211 import_decl :: { ImportVersion OccName }
212 import_decl : 'import' mod_fs INTEGER orphans is_boot whats_imported ';'
213 { (mkSysModuleFS $2, fromInteger $3, $4, $5, $6) }
214 -- import Foo 3 :: a 1 b 3 c 7 ; means import a,b,c from Foo
215 -- import Foo 3 ; means import all of Foo
216 -- import Foo 3 ! @ :: ...stuff... ; the ! means that Foo contains orphans
217 -- and @ that Foo is a boot interface
219 orphans :: { WhetherHasOrphans }
223 is_boot :: { IsBootInterface }
227 whats_imported :: { WhatsImported OccName }
228 whats_imported : { Everything }
229 | '::' name_version_pairs { Specifically $2 }
231 name_version_pairs :: { [LocalVersion OccName] }
232 name_version_pairs : { [] }
233 | name_version_pair name_version_pairs { $1 : $2 }
235 name_version_pair :: { LocalVersion OccName }
236 name_version_pair : var_occ INTEGER { ($1, fromInteger $2) }
237 | tc_occ INTEGER { ($1, fromInteger $2) }
240 --------------------------------------------------------------------------
242 exports_part :: { [ExportItem] }
243 exports_part : { [] }
244 | exports_part '__export'
245 mod_fs entities ';' { (mkSysModuleFS $3, $4) : $1 }
247 entities :: { [RdrAvailInfo] }
249 | entity entities { $1 : $2 }
251 entity :: { RdrAvailInfo }
252 entity : tc_occ { AvailTC $1 [$1] }
253 | var_occ { Avail $1 }
254 | tc_occ stuff_inside { AvailTC $1 ($1:$2) }
255 | tc_occ '|' stuff_inside { AvailTC $1 $3 }
257 stuff_inside :: { [OccName] }
258 stuff_inside : '{' val_occs '}' { $2 }
260 val_occ :: { OccName }
264 val_occs :: { [OccName] }
266 | val_occ val_occs { $1 : $2 }
269 --------------------------------------------------------------------------
271 fixity :: { FixityDirection }
272 fixity : 'infixl' { InfixL }
273 | 'infixr' { InfixR }
277 mb_fix : {-nothing-} { 9 }
278 | INTEGER { (fromInteger $1) }
280 -----------------------------------------------------------------------------
282 csigs :: { [RdrNameSig] }
284 | 'where' '{' csigs1 '}' { $3 }
286 csigs1 :: { [RdrNameSig] }
287 csigs1 : csig { [$1] }
288 | csig ';' csigs1 { $1 : $3 }
290 csig :: { RdrNameSig }
291 csig : src_loc var_name '::' type { mkClassOpSig False $2 $4 $1 }
292 | src_loc var_name '=' '::' type { mkClassOpSig True $2 $5 $1 }
294 --------------------------------------------------------------------------
296 instance_decl_part :: { [RdrNameInstDecl] }
297 instance_decl_part : {- empty -} { [] }
298 | instance_decl_part inst_decl { $2 : $1 }
300 inst_decl :: { RdrNameInstDecl }
301 inst_decl : src_loc 'instance' type '=' var_name ';'
303 EmptyMonoBinds {- No bindings -}
304 [] {- No user pragmas -}
309 --------------------------------------------------------------------------
311 decls_part :: { [(Version, RdrNameHsDecl)] }
314 | decls_part version decl ';' { ($2,$3):$1 }
316 decl :: { RdrNameHsDecl }
317 decl : src_loc var_name '::' type maybe_idinfo
318 { SigD (IfaceSig $2 $4 ($5 $2) $1) }
319 | src_loc 'type' tc_name tv_bndrs '=' type
320 { TyClD (TySynonym $3 $4 $6 $1) }
321 | src_loc 'data' decl_context tc_name tv_bndrs constrs
322 { TyClD (TyData DataType $3 $4 $5 $6 Nothing noDataPragmas $1) }
323 | src_loc 'newtype' decl_context tc_name tv_bndrs newtype_constr
324 { TyClD (TyData NewType $3 $4 $5 $6 Nothing noDataPragmas $1) }
325 | src_loc 'class' decl_context tc_name tv_bndrs fds csigs
326 { TyClD (mkClassDecl $3 $4 $5 $6 $7 EmptyMonoBinds
328 | src_loc fixity mb_fix var_or_data_name
329 { FixD (FixitySig $4 (Fixity $3 $2) $1) }
331 maybe_idinfo :: { RdrName -> [HsIdInfo RdrName] }
332 maybe_idinfo : {- empty -} { \_ -> [] }
333 | pragma { \x -> case $1 of
334 POk _ (PIdInfo id_info) -> id_info
336 pprPanic "IdInfo parse failed"
340 pragma :: { ParseResult IfaceStuff }
341 pragma : src_loc PRAGMA { parseIface $2 PState{ bol = 0#, atbol = 1#,
347 -----------------------------------------------------------------------------
349 rules_and_deprecs :: { ([RdrNameRuleDecl], [RdrNameDeprecation]) }
350 rules_and_deprecs : {- empty -} { ([], []) }
351 | rules_and_deprecs rule_or_deprec
353 append2 (xs1,ys1) (xs2,ys2) =
354 (xs1 `app` xs2, ys1 `app` ys2)
355 xs `app` [] = xs -- performance paranoia
356 xs `app` ys = xs ++ ys
360 rule_or_deprec :: { ([RdrNameRuleDecl], [RdrNameDeprecation]) }
361 rule_or_deprec : pragma { case $1 of
362 POk _ (PRules rules) -> (rules,[])
363 POk _ (PDeprecs deprecs) -> ([],deprecs)
364 PFailed err -> pprPanic "Rules/Deprecations parse failed" err
367 -----------------------------------------------------------------------------
369 rules :: { [RdrNameRuleDecl] }
371 | rule ';' rules { $1:$3 }
373 rule :: { RdrNameRuleDecl }
374 rule : src_loc STRING rule_forall qvar_name
375 core_args '=' core_expr { IfaceRuleDecl $4 (UfRuleBody $2 $3 $5 $7) $1 }
377 rule_forall :: { [UfBinder RdrName] }
378 rule_forall : '__forall' '{' core_bndrs '}' { $3 }
380 -----------------------------------------------------------------------------
382 deprecs :: { [RdrNameDeprecation] }
383 deprecs : {- empty -} { [] }
384 | deprecs deprec ';' { $2 : $1 }
386 deprec :: { RdrNameDeprecation }
387 deprec : STRING { Deprecation (IEModuleContents undefined) $1 }
388 | deprec_name STRING { Deprecation $1 $2 }
390 -- SUP: TEMPORARY HACK
391 deprec_name :: { RdrNameIE }
392 : var_name { IEVar $1 }
393 | data_name { IEThingAbs $1 }
395 -----------------------------------------------------------------------------
397 version :: { Version }
398 version : INTEGER { fromInteger $1 }
400 decl_context :: { RdrNameContext }
401 decl_context : { [] }
402 | '{' context_list1 '}' '=>' { $2 }
404 ----------------------------------------------------------------------------
406 constrs :: { [RdrNameConDecl] {- empty for handwritten abstract -} }
408 | '=' constrs1 { $2 }
410 constrs1 :: { [RdrNameConDecl] }
411 constrs1 : constr { [$1] }
412 | constr '|' constrs1 { $1 : $3 }
414 constr :: { RdrNameConDecl }
415 constr : src_loc ex_stuff data_name batypes { mk_con_decl $3 $2 (VanillaCon $4) $1 }
416 | src_loc ex_stuff data_name '{' fields1 '}' { mk_con_decl $3 $2 (RecCon $5) $1 }
417 -- We use "data_fs" so as to include ()
419 newtype_constr :: { [RdrNameConDecl] {- Empty if handwritten abstract -} }
420 newtype_constr : { [] }
421 | src_loc '=' ex_stuff data_name atype { [mk_con_decl $4 $3 (NewCon $5 Nothing) $1] }
422 | src_loc '=' ex_stuff data_name '{' var_name '::' atype '}'
423 { [mk_con_decl $4 $3 (NewCon $8 (Just $6)) $1] }
425 ex_stuff :: { ([HsTyVar RdrName], RdrNameContext) }
426 ex_stuff : { ([],[]) }
427 | '__forall' forall context '=>' { ($2,$3) }
429 batypes :: { [RdrNameBangType] }
431 | batype batypes { $1 : $2 }
433 batype :: { RdrNameBangType }
434 batype : atype { Unbanged $1 }
435 | '!' atype { Banged $2 }
436 | '!' '!' atype { Unpacked $3 }
438 fields1 :: { [([RdrName], RdrNameBangType)] }
439 fields1 : field { [$1] }
440 | field ',' fields1 { $1 : $3 }
442 field :: { ([RdrName], RdrNameBangType) }
443 field : var_names1 '::' type { ($1, Unbanged $3) }
444 | var_names1 '::' '!' type { ($1, Banged $4) }
445 | var_names1 '::' '!' '!' type { ($1, Unpacked $5) }
446 --------------------------------------------------------------------------
448 type :: { RdrNameHsType }
449 type : '__fuall' fuall '=>' type { mkHsUsForAllTy $2 $4 }
450 | '__forall' forall context '=>' type
451 { mkHsForAllTy (Just $2) $3 $5 }
452 | btype '->' type { MonoFunTy $1 $3 }
455 fuall :: { [RdrName] }
456 fuall : '[' uv_bndrs ']' { $2 }
458 forall :: { [HsTyVar RdrName] }
459 forall : '[' tv_bndrs ']' { $2 }
461 context :: { RdrNameContext }
463 | '{' context_list1 '}' { $2 }
465 context_list1 :: { RdrNameContext }
466 context_list1 : class { [$1] }
467 | class ',' context_list1 { $1 : $3 }
469 class :: { HsPred RdrName }
470 class : qcls_name atypes { (HsPClass $1 $2) }
471 | ipvar_name '::' type { (HsPIParam $1 $3) }
473 types0 :: { [RdrNameHsType] {- Zero or more -} }
474 types0 : {- empty -} { [ ] }
478 types2 :: { [RdrNameHsType] {- Two or more -} }
479 types2 : type ',' type { [$1,$3] }
480 | type ',' types2 { $1 : $3 }
482 btype :: { RdrNameHsType }
484 | btype atype { MonoTyApp $1 $2 }
485 | '__u' usage atype { MonoUsgTy $2 $3 }
487 usage :: { MonoUsageAnn RdrName }
488 usage : '-' { MonoUsOnce }
490 | uv_name { MonoUsVar $1 }
492 atype :: { RdrNameHsType }
493 atype : qtc_name { MonoTyVar $1 }
494 | tv_name { MonoTyVar $1 }
495 | '(' types2 ')' { MonoTupleTy $2 True{-boxed-} }
496 | '(#' types0 '#)' { MonoTupleTy $2 False{-unboxed-} }
497 | '[' type ']' { MonoListTy $2 }
498 | '{' qcls_name atypes '}' { MonoDictTy $2 $3 }
499 | '{' ipvar_name '::' type '}' { MonoIParamTy $2 $4 }
500 | '(' type ')' { $2 }
502 -- This one is dealt with via qtc_name
503 -- | '(' ')' { MonoTupleTy [] True }
505 atypes :: { [RdrNameHsType] {- Zero or more -} }
507 | atype atypes { $1 : $2 }
508 ---------------------------------------------------------------------
509 mod_fs :: { EncodedFS }
512 mod_name :: { ModuleName }
513 : mod_fs { mkSysModuleFS $1 }
516 ---------------------------------------------------
517 var_fs :: { EncodedFS }
520 | 'as' { SLIT("as") }
521 | 'qualified' { SLIT("qualified") }
522 | 'hiding' { SLIT("hiding") }
523 | 'forall' { SLIT("forall") }
524 | 'foreign' { SLIT("foreign") }
525 | 'export' { SLIT("export") }
526 | 'label' { SLIT("label") }
527 | 'dynamic' { SLIT("dynamic") }
528 | 'unsafe' { SLIT("unsafe") }
529 | 'with' { SLIT("with") }
531 qvar_fs :: { (EncodedFS, EncodedFS) }
535 var_occ :: { OccName }
536 : var_fs { mkSysOccFS varName $1 }
538 var_name :: { RdrName }
539 var_name : var_occ { mkRdrUnqual $1 }
541 qvar_name :: { RdrName }
542 qvar_name : var_name { $1 }
543 | qvar_fs { mkSysQual varName $1 }
545 ipvar_name :: { RdrName }
546 : IPVARID { mkSysUnqual ipName (tailFS $1) }
548 var_names :: { [RdrName] }
550 | var_name var_names { $1 : $2 }
552 var_names1 :: { [RdrName] }
553 var_names1 : var_name var_names { $1 : $2 }
555 ---------------------------------------------------
556 -- For some bizarre reason,
557 -- (,,,) is dealt with by the parser
558 -- Foo.(,,,) is dealt with by the lexer
561 data_fs :: { EncodedFS }
565 qdata_fs :: { (EncodedFS, EncodedFS) }
569 data_occ :: { OccName }
570 : data_fs { mkSysOccFS dataName $1 }
572 data_name :: { RdrName }
573 : data_occ { mkRdrUnqual $1 }
575 qdata_name :: { RdrName }
576 qdata_name : data_name { $1 }
577 | qdata_fs { mkSysQual dataName $1 }
579 qdata_names :: { [RdrName] }
581 | qdata_name qdata_names { $1 : $2 }
583 var_or_data_name :: { RdrName }
587 ---------------------------------------------------
588 tc_fs :: { EncodedFS }
591 tc_occ :: { OccName }
592 : tc_fs { mkSysOccFS tcName $1 }
594 tc_name :: { RdrName }
595 : tc_occ { mkRdrUnqual $1 }
597 qtc_name :: { RdrName }
599 | qdata_fs { mkSysQual tcName $1 }
601 ---------------------------------------------------
602 cls_name :: { RdrName }
603 : data_fs { mkSysUnqual clsName $1 }
605 qcls_name :: { RdrName }
607 | qdata_fs { mkSysQual clsName $1 }
609 ---------------------------------------------------
610 uv_name :: { RdrName }
611 : VARID { mkSysUnqual uvName $1 }
613 uv_bndr :: { RdrName }
616 uv_bndrs :: { [RdrName] }
618 | uv_bndr uv_bndrs { $1 : $2 }
620 ---------------------------------------------------
621 tv_name :: { RdrName }
622 : VARID { mkSysUnqual tvName $1 }
623 | VARSYM { mkSysUnqual tvName $1 {- Allow t2 as a tyvar -} }
625 tv_bndr :: { HsTyVar RdrName }
626 : tv_name '::' akind { IfaceTyVar $1 $3 }
627 | tv_name { IfaceTyVar $1 boxedTypeKind }
629 tv_bndrs :: { [HsTyVar RdrName] }
631 | tv_bndr tv_bndrs { $1 : $2 }
633 ---------------------------------------------------
634 fds :: { [([RdrName], [RdrName])] }
636 | '|' fds1 { reverse $2 }
638 fds1 :: { [([RdrName], [RdrName])] }
639 : fds1 ',' fd { $3 : $1 }
642 fd :: { ([RdrName], [RdrName]) }
643 : varids0 '->' varids0 { (reverse $1, reverse $3) }
645 varids0 :: { [RdrName] }
647 | varids0 tv_name { $2 : $1 }
649 ---------------------------------------------------
652 | akind '->' kind { mkArrowKind $1 $3 }
655 : VARSYM { if $1 == SLIT("*") then
657 else if $1 == SLIT("?") then
659 else panic "ParseInterface: akind"
661 | '(' kind ')' { $2 }
663 --------------------------------------------------------------------------
665 id_info :: { [HsIdInfo RdrName] }
667 | id_info_item id_info { $1 : $2 }
669 id_info_item :: { HsIdInfo RdrName }
670 : '__A' INTEGER { HsArity (exactArity (fromInteger $2)) }
671 | '__U' inline_prag core_expr { HsUnfold $2 $3 }
672 | '__M' { HsCprInfo }
673 | '__S' { HsStrictness (HsStrictnessInfo $1) }
674 | '__C' { HsNoCafRefs }
675 | '__P' qvar_name { HsWorker $2 }
677 inline_prag :: { InlinePragInfo }
678 : {- empty -} { NoInlinePragInfo }
679 | '[' INTEGER ']' { IMustNotBeINLINEd True (Just (fromInteger $2)) } -- INLINE n
680 | '[' '!' INTEGER ']' { IMustNotBeINLINEd False (Just (fromInteger $3)) } -- NOINLINE n
682 -------------------------------------------------------
683 core_expr :: { UfExpr RdrName }
684 core_expr : '\\' core_bndrs '->' core_expr { foldr UfLam $4 $2 }
685 | 'case' core_expr 'of' var_name
686 '{' core_alts '}' { UfCase $2 $4 $6 }
688 | 'let' '{' core_val_bndr '=' core_expr
689 '}' 'in' core_expr { UfLet (UfNonRec $3 $5) $8 }
690 | '__letrec' '{' rec_binds '}'
691 'in' core_expr { UfLet (UfRec $3) $6 }
693 | '__litlit' STRING atype { UfLitLit $2 $3 }
695 | '__inline_me' core_expr { UfNote UfInlineMe $2 }
696 | '__inline_call' core_expr { UfNote UfInlineCall $2 }
697 | '__coerce' atype core_expr { UfNote (UfCoerce $2) $3 }
698 | scc core_expr { UfNote (UfSCC $1) $2 }
701 fexpr :: { UfExpr RdrName }
702 fexpr : fexpr core_arg { UfApp $1 $2 }
705 core_arg :: { UfExpr RdrName }
706 : '@' atype { UfType $2 }
709 core_args :: { [UfExpr RdrName] }
711 | core_arg core_args { $1 : $2 }
713 core_aexpr :: { UfExpr RdrName } -- Atomic expressions
714 core_aexpr : qvar_name { UfVar $1 }
715 | qdata_name { UfVar $1 }
716 -- This one means that e.g. "True" will parse as
717 -- (UfVar True_Id) rather than (UfCon True_Con []).
718 -- No big deal; it'll be inlined in a jiffy. I tried
719 -- parsing it to (Con con []) directly, but got bitten
720 -- when a real constructor Id showed up in an interface
721 -- file. As usual, a hack bites you in the end.
722 -- If you want to get a UfCon, then use the
723 -- curly-bracket notation (True {}).
725 -- This one is dealt with by qdata_name: see above comments
726 -- | '(' ')' { UfTuple (mkTupConRdrName 0) [] }
728 | core_lit { UfLit $1 }
729 | '(' core_expr ')' { $2 }
731 -- Tuple construtors are for the *worker* of the tuple
732 -- Going direct saves needless messing about
733 | '(' comma_exprs2 ')' { UfTuple (mkRdrNameWkr (mkTupConRdrName (length $2))) $2 }
734 | '(#' comma_exprs0 '#)' { UfTuple (mkRdrNameWkr (mkUbxTupConRdrName (length $2))) $2 }
736 | '{' '__ccall' ccall_string type '}'
738 (is_dyn, is_casm, may_gc) = $2
740 target | is_dyn = DynamicTarget (error "CCall dyn target bogus unique")
741 | otherwise = StaticTarget $3
743 ccall = CCall target is_casm may_gc cCallConv
749 comma_exprs0 :: { [UfExpr RdrName] } -- Zero or more
750 comma_exprs0 : {- empty -} { [ ] }
751 | core_expr { [ $1 ] }
752 | comma_exprs2 { $1 }
754 comma_exprs2 :: { [UfExpr RdrName] } -- Two or more
755 comma_exprs2 : core_expr ',' core_expr { [$1,$3] }
756 | core_expr ',' comma_exprs2 { $1 : $3 }
758 rec_binds :: { [(UfBinder RdrName, UfExpr RdrName)] }
760 | core_val_bndr '=' core_expr ';' rec_binds { ($1,$3) : $5 }
762 core_alts :: { [UfAlt RdrName] }
764 | core_alt ';' core_alts { $1 : $3 }
766 core_alt :: { UfAlt RdrName }
767 core_alt : core_pat '->' core_expr { (fst $1, snd $1, $3) }
769 core_pat :: { (UfConAlt RdrName, [RdrName]) }
770 core_pat : core_lit { (UfLitAlt $1, []) }
771 | '__litlit' STRING atype { (UfLitLitAlt $2 $3, []) }
772 | qdata_name core_pat_names { (UfDataAlt $1, $2) }
773 | '(' comma_var_names1 ')' { (UfDataAlt (mkTupConRdrName (length $2)), $2) }
774 | '(#' comma_var_names1 '#)' { (UfDataAlt (mkUbxTupConRdrName (length $2)), $2) }
775 | '__DEFAULT' { (UfDefault, []) }
776 | '(' core_pat ')' { $2 }
778 core_pat_names :: { [RdrName] }
779 core_pat_names : { [] }
780 | core_pat_name core_pat_names { $1 : $2 }
782 -- Tyvar names and variable names live in different name spaces
783 -- so they need to be signalled separately. But we don't record
784 -- types or kinds in a pattern; we work that out from the type
785 -- of the case scrutinee
786 core_pat_name :: { RdrName }
787 core_pat_name : var_name { $1 }
790 comma_var_names1 :: { [RdrName] } -- One or more
791 comma_var_names1 : var_name { [$1] }
792 | var_name ',' comma_var_names1 { $1 : $3 }
794 core_lit :: { Literal }
795 core_lit : integer { mkMachInt $1 }
796 | CHAR { MachChar $1 }
797 | STRING { MachStr $1 }
798 | rational { MachDouble $1 }
799 | '__word' integer { mkMachWord $2 }
800 | '__word64' integer { mkMachWord64 $2 }
801 | '__int64' integer { mkMachInt64 $2 }
802 | '__float' rational { MachFloat $2 }
803 | '__addr' integer { MachAddr $2 }
805 integer :: { Integer }
807 | '-' INTEGER { (-$2) }
809 rational :: { Rational }
811 | '-' RATIONAL { (-$2) }
813 core_bndr :: { UfBinder RdrName }
814 core_bndr : core_val_bndr { $1 }
815 | core_tv_bndr { $1 }
817 core_bndrs :: { [UfBinder RdrName] }
819 | core_bndr core_bndrs { $1 : $2 }
821 core_val_bndr :: { UfBinder RdrName }
822 core_val_bndr : var_name '::' atype { UfValBinder $1 $3 }
824 core_tv_bndr :: { UfBinder RdrName }
825 core_tv_bndr : '@' tv_name '::' akind { UfTyBinder $2 $4 }
826 | '@' tv_name { UfTyBinder $2 boxedTypeKind }
828 ccall_string :: { FAST_STRING }
834 ------------------------------------------------------------------------
835 scc :: { CostCentre }
836 : '__sccC' '{' mod_name '}' { AllCafsCC $3 }
837 | '__scc' '{' cc_name mod_name cc_dup cc_caf '}'
838 { NormalCC { cc_name = $3, cc_mod = $4,
839 cc_is_dupd = $5, cc_is_caf = $6 } }
841 cc_name :: { EncodedFS }
845 cc_dup :: { IsDupdCC }
846 cc_dup : { OriginalCC }
849 cc_caf :: { IsCafCC }
853 -------------------------------------------------------------------
855 src_loc :: { SrcLoc }
856 src_loc : {% getSrcLocP }
858 checkVersion :: { () }
859 : {-empty-} {% checkVersion Nothing }
860 | INTEGER {% checkVersion (Just (fromInteger $1)) }
862 -------------------------------------------------------------------
867 happyError buf PState{ loc = loc } = PFailed (ifaceParseErr buf loc)
869 data IfaceStuff = PIface EncodedFS{-.hi module name-} ParsedIface
870 | PIdInfo [HsIdInfo RdrName]
871 | PType RdrNameHsType
872 | PRules [RdrNameRuleDecl]
873 | PDeprecs [RdrNameDeprecation]
875 mk_con_decl name (ex_tvs, ex_ctxt) details loc = mkConDecl name ex_tvs ex_ctxt details loc