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, PackageName, mkSysModuleFS, mkModule )
35 import PrelInfo ( mkTupConRdrName, mkUbxTupConRdrName )
36 import SrcLoc ( SrcLoc )
37 import CmdLineOpts ( opt_InPackage )
42 import FastString ( tailFS )
51 %monad { P }{ thenP }{ returnP }
52 %lexer { lexer } { ITeof }
56 'case' { ITcase } -- Haskell keywords
59 'default' { ITdefault }
60 'deriving' { ITderiving }
70 'instance' { ITinstance }
73 'newtype' { ITnewtype }
75 'qualified' { ITqualified }
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 { PIface $1 }
181 | id_info { PIdInfo $1 }
182 | '__R' rules { PRules $2 }
183 | '__D' deprecs { PDeprecs $2 }
186 iface :: { ParsedIface }
187 iface : '__interface' package mod_name INTEGER orphans checkVersion 'where'
194 pi_mod = mkModule $3 $2, -- Module itself
195 pi_vers = fromInteger $4, -- Module version
197 pi_exports = $8, -- Exports
198 pi_usages = $9, -- Usages
199 pi_insts = $10, -- Local instances
200 pi_decls = $11, -- Decls
201 pi_rules = fst $12, -- Rules
202 pi_deprecs = snd $12 -- Deprecations
205 --------------------------------------------------------------------------
207 import_part :: { [ImportVersion OccName] }
209 | import_part import_decl { $2 : $1 }
211 import_decl :: { ImportVersion OccName }
212 import_decl : 'import' mod_name 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
218 orphans :: { WhetherHasOrphans }
222 is_boot :: { IsBootInterface }
226 whats_imported :: { WhatsImported OccName }
227 whats_imported : { Everything }
228 | '::' name_version_pairs { Specifically $2 }
230 name_version_pairs :: { [LocalVersion OccName] }
231 name_version_pairs : { [] }
232 | name_version_pair name_version_pairs { $1 : $2 }
234 name_version_pair :: { LocalVersion OccName }
235 name_version_pair : var_occ INTEGER { ($1, fromInteger $2) }
236 | tc_occ INTEGER { ($1, fromInteger $2) }
239 --------------------------------------------------------------------------
241 exports_part :: { [ExportItem] }
242 exports_part : { [] }
243 | exports_part '__export'
244 mod_name entities ';' { (mkSysModuleFS $3, $4) : $1 }
246 entities :: { [RdrAvailInfo] }
248 | entity entities { $1 : $2 }
250 entity :: { RdrAvailInfo }
251 entity : tc_occ { AvailTC $1 [$1] }
252 | var_occ { Avail $1 }
253 | tc_occ stuff_inside { AvailTC $1 ($1:$2) }
254 | tc_occ '|' stuff_inside { AvailTC $1 $3 }
256 stuff_inside :: { [OccName] }
257 stuff_inside : '{' val_occs '}' { $2 }
259 val_occ :: { OccName }
263 val_occs :: { [OccName] }
265 | val_occ val_occs { $1 : $2 }
268 --------------------------------------------------------------------------
270 fixity :: { FixityDirection }
271 fixity : 'infixl' { InfixL }
272 | 'infixr' { InfixR }
276 mb_fix : {-nothing-} { 9 }
277 | INTEGER { (fromInteger $1) }
279 -----------------------------------------------------------------------------
281 csigs :: { [RdrNameSig] }
283 | 'where' '{' csigs1 '}' { $3 }
285 csigs1 :: { [RdrNameSig] }
286 csigs1 : csig { [$1] }
287 | csig ';' csigs1 { $1 : $3 }
289 csig :: { RdrNameSig }
290 csig : src_loc var_name '::' type { mkClassOpSig False $2 $4 $1 }
291 | src_loc var_name '=' '::' type { mkClassOpSig True $2 $5 $1 }
293 --------------------------------------------------------------------------
295 instance_decl_part :: { [RdrNameInstDecl] }
296 instance_decl_part : {- empty -} { [] }
297 | instance_decl_part inst_decl { $2 : $1 }
299 inst_decl :: { RdrNameInstDecl }
300 inst_decl : src_loc 'instance' type '=' var_name ';'
302 EmptyMonoBinds {- No bindings -}
303 [] {- No user pragmas -}
308 --------------------------------------------------------------------------
310 decls_part :: { [(Version, RdrNameHsDecl)] }
313 | decls_part version decl ';' { ($2,$3):$1 }
315 decl :: { RdrNameHsDecl }
316 decl : src_loc var_name '::' type maybe_idinfo
317 { SigD (IfaceSig $2 $4 ($5 $2) $1) }
318 | src_loc 'type' tc_name tv_bndrs '=' type
319 { TyClD (TySynonym $3 $4 $6 $1) }
320 | src_loc 'data' decl_context tc_name tv_bndrs constrs
321 { TyClD (TyData DataType $3 $4 $5 $6 Nothing noDataPragmas $1) }
322 | src_loc 'newtype' decl_context tc_name tv_bndrs newtype_constr
323 { TyClD (TyData NewType $3 $4 $5 $6 Nothing noDataPragmas $1) }
324 | src_loc 'class' decl_context tc_name tv_bndrs fds csigs
325 { TyClD (mkClassDecl $3 $4 $5 $6 $7 EmptyMonoBinds
327 | src_loc fixity mb_fix var_or_data_name
328 { FixD (FixitySig $4 (Fixity $3 $2) $1) }
330 maybe_idinfo :: { RdrName -> [HsIdInfo RdrName] }
331 maybe_idinfo : {- empty -} { \_ -> [] }
332 | pragma { \x -> case $1 of
333 POk _ (PIdInfo id_info) -> id_info
335 pprPanic "IdInfo parse failed"
339 pragma :: { ParseResult IfaceStuff }
340 pragma : src_loc PRAGMA { parseIface $2 PState{ bol = 0#, atbol = 1#,
346 -----------------------------------------------------------------------------
348 rules_and_deprecs :: { ([RdrNameRuleDecl], [RdrNameDeprecation]) }
349 rules_and_deprecs : {- empty -} { ([], []) }
350 | rules_and_deprecs rule_or_deprec
352 append2 (xs1,ys1) (xs2,ys2) =
353 (xs1 `app` xs2, ys1 `app` ys2)
354 xs `app` [] = xs -- performance paranoia
355 xs `app` ys = xs ++ ys
359 rule_or_deprec :: { ([RdrNameRuleDecl], [RdrNameDeprecation]) }
360 rule_or_deprec : pragma { case $1 of
361 POk _ (PRules rules) -> (rules,[])
362 POk _ (PDeprecs deprecs) -> ([],deprecs)
363 PFailed err -> pprPanic "Rules/Deprecations parse failed" err
366 -----------------------------------------------------------------------------
368 rules :: { [RdrNameRuleDecl] }
370 | rule ';' rules { $1:$3 }
372 rule :: { RdrNameRuleDecl }
373 rule : src_loc STRING rule_forall qvar_name
374 core_args '=' core_expr { IfaceRuleDecl $4 (UfRuleBody $2 $3 $5 $7) $1 }
376 rule_forall :: { [UfBinder RdrName] }
377 rule_forall : '__forall' '{' core_bndrs '}' { $3 }
379 -----------------------------------------------------------------------------
381 deprecs :: { [RdrNameDeprecation] }
382 deprecs : {- empty -} { [] }
383 | deprecs deprec ';' { $2 : $1 }
385 deprec :: { RdrNameDeprecation }
386 deprec : STRING { Deprecation (IEModuleContents undefined) $1 }
387 | deprec_name STRING { Deprecation $1 $2 }
389 -- SUP: TEMPORARY HACK
390 deprec_name :: { RdrNameIE }
391 : var_name { IEVar $1 }
392 | data_name { IEThingAbs $1 }
394 -----------------------------------------------------------------------------
396 version :: { Version }
397 version : INTEGER { fromInteger $1 }
399 decl_context :: { RdrNameContext }
400 decl_context : { [] }
401 | '{' context_list1 '}' '=>' { $2 }
403 ----------------------------------------------------------------------------
405 constrs :: { [RdrNameConDecl] {- empty for handwritten abstract -} }
407 | '=' constrs1 { $2 }
409 constrs1 :: { [RdrNameConDecl] }
410 constrs1 : constr { [$1] }
411 | constr '|' constrs1 { $1 : $3 }
413 constr :: { RdrNameConDecl }
414 constr : src_loc ex_stuff data_name batypes { mk_con_decl $3 $2 (VanillaCon $4) $1 }
415 | src_loc ex_stuff data_name '{' fields1 '}' { mk_con_decl $3 $2 (RecCon $5) $1 }
416 -- We use "data_fs" so as to include ()
418 newtype_constr :: { [RdrNameConDecl] {- Empty if handwritten abstract -} }
419 newtype_constr : { [] }
420 | src_loc '=' ex_stuff data_name atype { [mk_con_decl $4 $3 (NewCon $5 Nothing) $1] }
421 | src_loc '=' ex_stuff data_name '{' var_name '::' atype '}'
422 { [mk_con_decl $4 $3 (NewCon $8 (Just $6)) $1] }
424 ex_stuff :: { ([HsTyVar RdrName], RdrNameContext) }
425 ex_stuff : { ([],[]) }
426 | '__forall' forall context '=>' { ($2,$3) }
428 batypes :: { [RdrNameBangType] }
430 | batype batypes { $1 : $2 }
432 batype :: { RdrNameBangType }
433 batype : atype { Unbanged $1 }
434 | '!' atype { Banged $2 }
435 | '!' '!' atype { Unpacked $3 }
437 fields1 :: { [([RdrName], RdrNameBangType)] }
438 fields1 : field { [$1] }
439 | field ',' fields1 { $1 : $3 }
441 field :: { ([RdrName], RdrNameBangType) }
442 field : var_names1 '::' type { ($1, Unbanged $3) }
443 | var_names1 '::' '!' type { ($1, Banged $4) }
444 | var_names1 '::' '!' '!' type { ($1, Unpacked $5) }
445 --------------------------------------------------------------------------
447 type :: { RdrNameHsType }
448 type : '__fuall' fuall '=>' type { mkHsUsForAllTy $2 $4 }
449 | '__forall' forall context '=>' type
450 { mkHsForAllTy (Just $2) $3 $5 }
451 | btype '->' type { MonoFunTy $1 $3 }
454 fuall :: { [RdrName] }
455 fuall : '[' uv_bndrs ']' { $2 }
457 forall :: { [HsTyVar RdrName] }
458 forall : '[' tv_bndrs ']' { $2 }
460 context :: { RdrNameContext }
462 | '{' context_list1 '}' { $2 }
464 context_list1 :: { RdrNameContext }
465 context_list1 : class { [$1] }
466 | class ',' context_list1 { $1 : $3 }
468 class :: { HsPred RdrName }
469 class : qcls_name atypes { (HsPClass $1 $2) }
470 | ipvar_name '::' type { (HsPIParam $1 $3) }
472 types0 :: { [RdrNameHsType] {- Zero or more -} }
473 types0 : {- empty -} { [ ] }
477 types2 :: { [RdrNameHsType] {- Two or more -} }
478 types2 : type ',' type { [$1,$3] }
479 | type ',' types2 { $1 : $3 }
481 btype :: { RdrNameHsType }
483 | btype atype { MonoTyApp $1 $2 }
484 | '__u' usage atype { MonoUsgTy $2 $3 }
486 usage :: { MonoUsageAnn RdrName }
487 usage : '-' { MonoUsOnce }
489 | uv_name { MonoUsVar $1 }
491 atype :: { RdrNameHsType }
492 atype : qtc_name { MonoTyVar $1 }
493 | tv_name { MonoTyVar $1 }
494 | '(' types2 ')' { MonoTupleTy $2 True{-boxed-} }
495 | '(#' types0 '#)' { MonoTupleTy $2 False{-unboxed-} }
496 | '[' type ']' { MonoListTy $2 }
497 | '{' qcls_name atypes '}' { MonoDictTy $2 $3 }
498 | '{' ipvar_name '::' type '}' { MonoIParamTy $2 $4 }
499 | '(' type ')' { $2 }
501 -- This one is dealt with via qtc_name
502 -- | '(' ')' { MonoTupleTy [] True }
504 atypes :: { [RdrNameHsType] {- Zero or more -} }
506 | atype atypes { $1 : $2 }
507 ---------------------------------------------------------------------
508 package :: { PackageName }
510 | {- empty -} { opt_InPackage } -- Useful for .hi-boot files,
511 -- which can omit the package Id
512 -- Module loops are always within a package
514 mod_name :: { ModuleName }
515 : CONID { mkSysModuleFS $1 }
518 ---------------------------------------------------
519 var_fs :: { EncodedFS }
522 | 'as' { SLIT("as") }
523 | 'qualified' { SLIT("qualified") }
524 | 'hiding' { SLIT("hiding") }
525 | 'forall' { SLIT("forall") }
526 | 'foreign' { SLIT("foreign") }
527 | 'export' { SLIT("export") }
528 | 'label' { SLIT("label") }
529 | 'dynamic' { SLIT("dynamic") }
530 | 'unsafe' { SLIT("unsafe") }
531 | 'with' { SLIT("with") }
532 | 'ccall' { SLIT("ccall") }
533 | 'stdcall' { SLIT("stdcall") }
535 qvar_fs :: { (EncodedFS, EncodedFS) }
539 var_occ :: { OccName }
540 : var_fs { mkSysOccFS varName $1 }
542 var_name :: { RdrName }
543 var_name : var_occ { mkRdrUnqual $1 }
545 qvar_name :: { RdrName }
546 qvar_name : var_name { $1 }
547 | qvar_fs { mkSysQual varName $1 }
549 ipvar_name :: { RdrName }
550 : IPVARID { mkSysUnqual ipName (tailFS $1) }
552 var_names :: { [RdrName] }
554 | var_name var_names { $1 : $2 }
556 var_names1 :: { [RdrName] }
557 var_names1 : var_name var_names { $1 : $2 }
559 ---------------------------------------------------
560 -- For some bizarre reason,
561 -- (,,,) is dealt with by the parser
562 -- Foo.(,,,) is dealt with by the lexer
565 data_fs :: { EncodedFS }
569 qdata_fs :: { (EncodedFS, EncodedFS) }
573 data_occ :: { OccName }
574 : data_fs { mkSysOccFS dataName $1 }
576 data_name :: { RdrName }
577 : data_occ { mkRdrUnqual $1 }
579 qdata_name :: { RdrName }
580 qdata_name : data_name { $1 }
581 | qdata_fs { mkSysQual dataName $1 }
583 qdata_names :: { [RdrName] }
585 | qdata_name qdata_names { $1 : $2 }
587 var_or_data_name :: { RdrName }
591 ---------------------------------------------------
592 tc_fs :: { EncodedFS }
595 tc_occ :: { OccName }
596 : tc_fs { mkSysOccFS tcName $1 }
598 tc_name :: { RdrName }
599 : tc_occ { mkRdrUnqual $1 }
601 qtc_name :: { RdrName }
603 | qdata_fs { mkSysQual tcName $1 }
605 ---------------------------------------------------
606 cls_name :: { RdrName }
607 : data_fs { mkSysUnqual clsName $1 }
609 qcls_name :: { RdrName }
611 | qdata_fs { mkSysQual clsName $1 }
613 ---------------------------------------------------
614 uv_name :: { RdrName }
615 : VARID { mkSysUnqual uvName $1 }
617 uv_bndr :: { RdrName }
620 uv_bndrs :: { [RdrName] }
622 | uv_bndr uv_bndrs { $1 : $2 }
624 ---------------------------------------------------
625 tv_name :: { RdrName }
626 : VARID { mkSysUnqual tvName $1 }
627 | VARSYM { mkSysUnqual tvName $1 {- Allow t2 as a tyvar -} }
629 tv_bndr :: { HsTyVar RdrName }
630 : tv_name '::' akind { IfaceTyVar $1 $3 }
631 | tv_name { IfaceTyVar $1 boxedTypeKind }
633 tv_bndrs :: { [HsTyVar RdrName] }
635 | tv_bndr tv_bndrs { $1 : $2 }
637 ---------------------------------------------------
638 fds :: { [([RdrName], [RdrName])] }
640 | '|' fds1 { reverse $2 }
642 fds1 :: { [([RdrName], [RdrName])] }
643 : fds1 ',' fd { $3 : $1 }
646 fd :: { ([RdrName], [RdrName]) }
647 : varids0 '->' varids0 { (reverse $1, reverse $3) }
649 varids0 :: { [RdrName] }
651 | varids0 tv_name { $2 : $1 }
653 ---------------------------------------------------
656 | akind '->' kind { mkArrowKind $1 $3 }
659 : VARSYM { if $1 == SLIT("*") then
661 else if $1 == SLIT("?") then
663 else panic "ParseInterface: akind"
665 | '(' kind ')' { $2 }
667 --------------------------------------------------------------------------
669 id_info :: { [HsIdInfo RdrName] }
671 | id_info_item id_info { $1 : $2 }
673 id_info_item :: { HsIdInfo RdrName }
674 : '__A' INTEGER { HsArity (exactArity (fromInteger $2)) }
675 | '__U' inline_prag core_expr { HsUnfold $2 $3 }
676 | '__M' { HsCprInfo }
677 | '__S' { HsStrictness (HsStrictnessInfo $1) }
678 | '__C' { HsNoCafRefs }
679 | '__P' qvar_name { HsWorker $2 }
681 inline_prag :: { InlinePragInfo }
682 : {- empty -} { NoInlinePragInfo }
683 | '[' INTEGER ']' { IMustNotBeINLINEd True (Just (fromInteger $2)) } -- INLINE n
684 | '[' '!' INTEGER ']' { IMustNotBeINLINEd False (Just (fromInteger $3)) } -- NOINLINE n
686 -------------------------------------------------------
687 core_expr :: { UfExpr RdrName }
688 core_expr : '\\' core_bndrs '->' core_expr { foldr UfLam $4 $2 }
689 | 'case' core_expr 'of' var_name
690 '{' core_alts '}' { UfCase $2 $4 $6 }
692 | 'let' '{' core_val_bndr '=' core_expr
693 '}' 'in' core_expr { UfLet (UfNonRec $3 $5) $8 }
694 | '__letrec' '{' rec_binds '}'
695 'in' core_expr { UfLet (UfRec $3) $6 }
697 | '__litlit' STRING atype { UfLitLit $2 $3 }
699 | '__inline_me' core_expr { UfNote UfInlineMe $2 }
700 | '__inline_call' core_expr { UfNote UfInlineCall $2 }
701 | '__coerce' atype core_expr { UfNote (UfCoerce $2) $3 }
702 | scc core_expr { UfNote (UfSCC $1) $2 }
705 fexpr :: { UfExpr RdrName }
706 fexpr : fexpr core_arg { UfApp $1 $2 }
709 core_arg :: { UfExpr RdrName }
710 : '@' atype { UfType $2 }
713 core_args :: { [UfExpr RdrName] }
715 | core_arg core_args { $1 : $2 }
717 core_aexpr :: { UfExpr RdrName } -- Atomic expressions
718 core_aexpr : qvar_name { UfVar $1 }
719 | qdata_name { UfVar $1 }
720 -- This one means that e.g. "True" will parse as
721 -- (UfVar True_Id) rather than (UfCon True_Con []).
722 -- No big deal; it'll be inlined in a jiffy. I tried
723 -- parsing it to (Con con []) directly, but got bitten
724 -- when a real constructor Id showed up in an interface
725 -- file. As usual, a hack bites you in the end.
726 -- If you want to get a UfCon, then use the
727 -- curly-bracket notation (True {}).
729 -- This one is dealt with by qdata_name: see above comments
730 -- | '(' ')' { UfTuple (mkTupConRdrName 0) [] }
732 | core_lit { UfLit $1 }
733 | '(' core_expr ')' { $2 }
735 -- Tuple construtors are for the *worker* of the tuple
736 -- Going direct saves needless messing about
737 | '(' comma_exprs2 ')' { UfTuple (mkRdrNameWkr (mkTupConRdrName (length $2))) $2 }
738 | '(#' comma_exprs0 '#)' { UfTuple (mkRdrNameWkr (mkUbxTupConRdrName (length $2))) $2 }
740 | '{' '__ccall' ccall_string type '}'
742 (is_dyn, is_casm, may_gc) = $2
744 target | is_dyn = DynamicTarget (error "CCall dyn target bogus unique")
745 | otherwise = StaticTarget $3
747 ccall = CCall target is_casm may_gc cCallConv
753 comma_exprs0 :: { [UfExpr RdrName] } -- Zero or more
754 comma_exprs0 : {- empty -} { [ ] }
755 | core_expr { [ $1 ] }
756 | comma_exprs2 { $1 }
758 comma_exprs2 :: { [UfExpr RdrName] } -- Two or more
759 comma_exprs2 : core_expr ',' core_expr { [$1,$3] }
760 | core_expr ',' comma_exprs2 { $1 : $3 }
762 rec_binds :: { [(UfBinder RdrName, UfExpr RdrName)] }
764 | core_val_bndr '=' core_expr ';' rec_binds { ($1,$3) : $5 }
766 core_alts :: { [UfAlt RdrName] }
768 | core_alt ';' core_alts { $1 : $3 }
770 core_alt :: { UfAlt RdrName }
771 core_alt : core_pat '->' core_expr { (fst $1, snd $1, $3) }
773 core_pat :: { (UfConAlt RdrName, [RdrName]) }
774 core_pat : core_lit { (UfLitAlt $1, []) }
775 | '__litlit' STRING atype { (UfLitLitAlt $2 $3, []) }
776 | qdata_name core_pat_names { (UfDataAlt $1, $2) }
777 | '(' comma_var_names1 ')' { (UfDataAlt (mkTupConRdrName (length $2)), $2) }
778 | '(#' comma_var_names1 '#)' { (UfDataAlt (mkUbxTupConRdrName (length $2)), $2) }
779 | '__DEFAULT' { (UfDefault, []) }
780 | '(' core_pat ')' { $2 }
782 core_pat_names :: { [RdrName] }
783 core_pat_names : { [] }
784 | core_pat_name core_pat_names { $1 : $2 }
786 -- Tyvar names and variable names live in different name spaces
787 -- so they need to be signalled separately. But we don't record
788 -- types or kinds in a pattern; we work that out from the type
789 -- of the case scrutinee
790 core_pat_name :: { RdrName }
791 core_pat_name : var_name { $1 }
794 comma_var_names1 :: { [RdrName] } -- One or more
795 comma_var_names1 : var_name { [$1] }
796 | var_name ',' comma_var_names1 { $1 : $3 }
798 core_lit :: { Literal }
799 core_lit : integer { mkMachInt $1 }
800 | CHAR { MachChar $1 }
801 | STRING { MachStr $1 }
802 | rational { MachDouble $1 }
803 | '__word' integer { mkMachWord $2 }
804 | '__word64' integer { mkMachWord64 $2 }
805 | '__int64' integer { mkMachInt64 $2 }
806 | '__float' rational { MachFloat $2 }
807 | '__addr' integer { MachAddr $2 }
809 integer :: { Integer }
811 | '-' INTEGER { (-$2) }
813 rational :: { Rational }
815 | '-' RATIONAL { (-$2) }
817 core_bndr :: { UfBinder RdrName }
818 core_bndr : core_val_bndr { $1 }
819 | core_tv_bndr { $1 }
821 core_bndrs :: { [UfBinder RdrName] }
823 | core_bndr core_bndrs { $1 : $2 }
825 core_val_bndr :: { UfBinder RdrName }
826 core_val_bndr : var_name '::' atype { UfValBinder $1 $3 }
828 core_tv_bndr :: { UfBinder RdrName }
829 core_tv_bndr : '@' tv_name '::' akind { UfTyBinder $2 $4 }
830 | '@' tv_name { UfTyBinder $2 boxedTypeKind }
832 ccall_string :: { FAST_STRING }
838 ------------------------------------------------------------------------
839 scc :: { CostCentre }
840 : '__sccC' '{' mod_name '}' { AllCafsCC $3 }
841 | '__scc' '{' cc_name mod_name cc_dup cc_caf '}'
842 { NormalCC { cc_name = $3, cc_mod = $4,
843 cc_is_dupd = $5, cc_is_caf = $6 } }
845 cc_name :: { EncodedFS }
849 cc_dup :: { IsDupdCC }
850 cc_dup : { OriginalCC }
853 cc_caf :: { IsCafCC }
857 -------------------------------------------------------------------
859 src_loc :: { SrcLoc }
860 src_loc : {% getSrcLocP }
862 checkVersion :: { () }
863 : {-empty-} {% checkVersion Nothing }
864 | INTEGER {% checkVersion (Just (fromInteger $1)) }
866 -------------------------------------------------------------------
871 happyError buf PState{ loc = loc } = PFailed (ifaceParseErr buf loc)
873 data IfaceStuff = PIface ParsedIface
874 | PIdInfo [HsIdInfo RdrName]
875 | PType RdrNameHsType
876 | PRules [RdrNameRuleDecl]
877 | PDeprecs [RdrNameDeprecation]
879 mk_con_decl name (ex_tvs, ex_ctxt) details loc = mkConDecl name ex_tvs ex_ctxt details loc