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 Const ( Literal(..), mkMachInt_safe )
11 import BasicTypes ( Fixity(..), FixityDirection(..),
12 NewOrData(..), Version
14 import CostCentre ( CostCentre(..), IsCafCC(..), IsDupdCC(..) )
15 import HsPragmas ( noDataPragmas, noClassPragmas )
16 import Type ( Kind, mkArrowKind, boxedTypeKind, openTypeKind, UsageAnn(..) )
17 import IdInfo ( ArityInfo, exactArity, CprInfo(..), InlinePragInfo(..) )
20 import RnMonad ( ImportVersion, LocalVersion, ParsedIface(..), WhatsImported(..),
21 RdrNamePragma, ExportItem, RdrAvailInfo, GenAvailInfo(..), WhetherHasOrphans
23 import Bag ( emptyBag, unitBag, snocBag )
24 import FiniteMap ( emptyFM, unitFM, addToFM, plusFM, bagToFM, FiniteMap )
25 import RdrName ( RdrName, mkRdrUnqual, mkSysQual, mkSysUnqual )
26 import Name ( OccName, Provenance )
27 import OccName ( mkSysOccFS,
28 tcName, varName, ipName, dataName, clsName, tvName, uvName,
31 import Module ( ModuleName, mkSysModuleFS )
32 import PrelMods ( mkTupNameStr, mkUbxTupNameStr )
33 import PrelInfo ( mkTupConRdrName, mkUbxTupConRdrName )
34 import SrcLoc ( SrcLoc )
47 %monad { P }{ thenP }{ returnP }
48 %lexer { lexer } { ITeof }
51 'case' { ITcase } -- Haskell keywords
54 'default' { ITdefault }
55 'deriving' { ITderiving }
64 'instance' { ITinstance }
67 'newtype' { ITnewtype }
73 'qualified' { ITqualified }
76 'forall' { ITforall } -- GHC extension keywords
77 'foreign' { ITforeign }
80 'dynamic' { ITdynamic }
84 '__interface' { ITinterface } -- interface keywords
85 '__export' { IT__export }
86 '__forall' { IT__forall }
87 '__depends' { ITdepends }
88 '__letrec' { ITletrec }
89 '__coerce' { ITcoerce }
90 '__inline_call'{ ITinlineCall }
91 '__inline_me' { ITinlineMe }
92 '__DEFAULT' { ITdefaultbranch }
94 '__integer' { ITinteger_lit }
95 '__float' { ITfloat_lit }
96 '__rational' { ITrational_lit }
97 '__addr' { ITaddr_lit }
98 '__litlit' { ITlit_lit }
99 '__string' { ITstring_lit }
100 '__ccall' { ITccall $$ }
102 '__sccC' { ITsccAllCafs }
105 '__fuall' { ITfuall }
108 '__P' { ITspecialise }
110 '__U' { ITunfold $$ }
111 '__S' { ITstrict $$ }
113 '__D' { ITdeprecated }
114 '__M' { ITcprinfo $$ }
116 '..' { ITdotdot } -- reserved symbols
129 '/\\' { ITbiglam } -- GHC-extension symbols
131 '{' { ITocurly } -- special symbols
142 VARID { ITvarid $$ } -- identifiers
144 VARSYM { ITvarsym $$ }
145 CONSYM { ITconsym $$ }
146 QVARID { ITqvarid $$ }
147 QCONID { ITqconid $$ }
148 QVARSYM { ITqvarsym $$ }
149 QCONSYM { ITqconsym $$ }
151 IPVARID { ITipvarid $$ } -- GHC extension
153 PRAGMA { ITpragma $$ }
156 STRING { ITstring $$ }
157 INTEGER { ITinteger $$ }
158 RATIONAL { ITrational $$ }
159 CLITLIT { ITlitlit $$ }
161 UNKNOWN { ITunknown $$ }
164 -- iface_stuff is the main production.
165 -- It recognises (a) a whole interface file
166 -- (b) a type (so that type sigs can be parsed lazily)
167 -- (c) the IdInfo part of a signature (same reason)
169 iface_stuff :: { IfaceStuff }
170 iface_stuff : iface { let (nm, iff) = $1 in PIface nm iff }
172 | id_info { PIdInfo $1 }
173 | '__R' rules { PRules $2 }
174 | '__D' deprecs { PDeprecs $2 }
177 iface :: { (ModuleName, ParsedIface) }
178 iface : '__interface' mod_fs INTEGER orphans checkVersion 'where'
184 { ( $2 -- Module name
186 pi_mod = fromInteger $3, -- Module version
188 pi_exports = $7, -- Exports
189 pi_usages = $8, -- Usages
190 pi_insts = $9, -- Local instances
191 pi_decls = $10, -- Decls
192 pi_rules = fst $11, -- Rules
193 pi_deprecs = snd $11 -- Deprecations
196 --------------------------------------------------------------------------
198 import_part :: { [ImportVersion OccName] }
200 | import_part import_decl { $2 : $1 }
202 import_decl :: { ImportVersion OccName }
203 import_decl : 'import' mod_fs INTEGER orphans whats_imported ';'
204 { (mkSysModuleFS $2, fromInteger $3, $4, $5) }
205 -- import Foo 3 :: a 1 b 3 c 7 ; means import a,b,c from Foo
206 -- import Foo 3 ; means import all of Foo
207 -- import Foo 3 ! :: ...stuff... ; the ! means that Foo contains orphans
209 orphans :: { WhetherHasOrphans }
213 whats_imported :: { WhatsImported OccName }
214 whats_imported : { Everything }
215 | '::' name_version_pairs { Specifically $2 }
217 name_version_pairs :: { [LocalVersion OccName] }
218 name_version_pairs : { [] }
219 | name_version_pair name_version_pairs { $1 : $2 }
221 name_version_pair :: { LocalVersion OccName }
222 name_version_pair : var_occ INTEGER { ($1, fromInteger $2) }
223 | tc_occ INTEGER { ($1, fromInteger $2) }
226 --------------------------------------------------------------------------
228 exports_part :: { [ExportItem] }
229 exports_part : { [] }
230 | exports_part '__export'
231 mod_fs entities ';' { (mkSysModuleFS $3, $4) : $1 }
233 entities :: { [RdrAvailInfo] }
235 | entity entities { $1 : $2 }
237 entity :: { RdrAvailInfo }
238 entity : tc_occ { AvailTC $1 [$1] }
239 | var_occ { Avail $1 }
240 | tc_occ stuff_inside { AvailTC $1 ($1:$2) }
241 | tc_occ '|' stuff_inside { AvailTC $1 $3 }
243 stuff_inside :: { [OccName] }
244 stuff_inside : '{' val_occs '}' { $2 }
246 val_occ :: { OccName }
250 val_occs :: { [OccName] }
252 | val_occ val_occs { $1 : $2 }
255 --------------------------------------------------------------------------
257 fixity :: { FixityDirection }
258 fixity : 'infixl' { InfixL }
259 | 'infixr' { InfixR }
263 mb_fix : {-nothing-} { 9 }
264 | INTEGER { (fromInteger $1) }
266 -----------------------------------------------------------------------------
268 csigs :: { [RdrNameSig] }
270 | 'where' '{' csigs1 '}' { $3 }
272 csigs1 :: { [RdrNameSig] }
273 csigs1 : csig { [$1] }
274 | csig ';' csigs1 { $1 : $3 }
276 csig :: { RdrNameSig }
277 csig : src_loc var_name '::' type { mkClassOpSig False $2 $4 $1 }
278 | src_loc var_name '=' '::' type { mkClassOpSig True $2 $5 $1 }
280 --------------------------------------------------------------------------
282 instance_decl_part :: { [RdrNameInstDecl] }
283 instance_decl_part : {- empty -} { [] }
284 | instance_decl_part inst_decl { $2 : $1 }
286 inst_decl :: { RdrNameInstDecl }
287 inst_decl : src_loc 'instance' type '=' var_name ';'
289 EmptyMonoBinds {- No bindings -}
290 [] {- No user pragmas -}
295 --------------------------------------------------------------------------
297 decls_part :: { [(Version, RdrNameHsDecl)] }
300 | decls_part version decl ';' { ($2,$3):$1 }
302 decl :: { RdrNameHsDecl }
303 decl : src_loc var_name '::' type maybe_idinfo
304 { SigD (IfaceSig $2 $4 ($5 $2) $1) }
305 | src_loc 'type' tc_name tv_bndrs '=' type
306 { TyClD (TySynonym $3 $4 $6 $1) }
307 | src_loc 'data' decl_context tc_name tv_bndrs constrs
308 { TyClD (TyData DataType $3 $4 $5 $6 Nothing noDataPragmas $1) }
309 | src_loc 'newtype' decl_context tc_name tv_bndrs newtype_constr
310 { TyClD (TyData NewType $3 $4 $5 $6 Nothing noDataPragmas $1) }
311 | src_loc 'class' decl_context tc_name tv_bndrs fds csigs
312 { TyClD (mkClassDecl $3 $4 $5 $6 $7 EmptyMonoBinds
314 | src_loc fixity mb_fix var_or_data_name
315 { FixD (FixitySig $4 (Fixity $3 $2) $1) }
317 maybe_idinfo :: { RdrName -> [HsIdInfo RdrName] }
318 maybe_idinfo : {- empty -} { \_ -> [] }
319 | pragma { \x -> case $1 of
320 POk _ (PIdInfo id_info) -> id_info
322 pprPanic "IdInfo parse failed"
326 pragma :: { ParseResult IfaceStuff }
327 pragma : src_loc PRAGMA { parseIface $2 PState{ bol = 0#, atbol = 1#,
333 -----------------------------------------------------------------------------
335 rules_and_deprecs :: { ([RdrNameRuleDecl], [RdrNameDeprecation]) }
336 rules_and_deprecs : {- empty -} { ([], []) }
337 | rules_and_deprecs rule_or_deprec
339 append2 (xs1,ys1) (xs2,ys2) =
340 (xs1 `app` xs2, ys1 `app` ys2)
341 xs `app` [] = xs -- performance paranoia
342 xs `app` ys = xs ++ ys
346 rule_or_deprec :: { ([RdrNameRuleDecl], [RdrNameDeprecation]) }
347 rule_or_deprec : pragma { case $1 of
348 POk _ (PRules rules) -> (rules,[])
349 POk _ (PDeprecs deprecs) -> ([],deprecs)
350 PFailed err -> pprPanic "Rules/Deprecations parse failed" err
353 -----------------------------------------------------------------------------
355 rules :: { [RdrNameRuleDecl] }
357 | rule ';' rules { $1:$3 }
359 rule :: { RdrNameRuleDecl }
360 rule : src_loc STRING rule_forall qvar_name
361 core_args '=' core_expr { IfaceRuleDecl $4 (UfRuleBody $2 $3 $5 $7) $1 }
363 rule_forall :: { [UfBinder RdrName] }
364 rule_forall : '__forall' '{' core_bndrs '}' { $3 }
366 -----------------------------------------------------------------------------
368 deprecs :: { [RdrNameDeprecation] }
369 deprecs : {- empty -} { [] }
370 | deprecs deprec ';' { $2 : $1 }
372 deprec :: { RdrNameDeprecation }
373 deprec : STRING { DeprecMod $1 }
374 | deprec_name STRING { DeprecName $1 $2 }
376 deprec_name :: { RdrName }
380 -----------------------------------------------------------------------------
382 version :: { Version }
383 version : INTEGER { fromInteger $1 }
385 decl_context :: { RdrNameContext }
386 decl_context : { [] }
387 | '{' context_list1 '}' '=>' { $2 }
389 ----------------------------------------------------------------------------
391 constrs :: { [RdrNameConDecl] {- empty for handwritten abstract -} }
393 | '=' constrs1 { $2 }
395 constrs1 :: { [RdrNameConDecl] }
396 constrs1 : constr { [$1] }
397 | constr '|' constrs1 { $1 : $3 }
399 constr :: { RdrNameConDecl }
400 constr : src_loc ex_stuff data_name batypes { mkConDecl $3 $2 (VanillaCon $4) $1 }
401 | src_loc ex_stuff data_name '{' fields1 '}' { mkConDecl $3 $2 (RecCon $5) $1 }
402 -- We use "data_fs" so as to include ()
404 newtype_constr :: { [RdrNameConDecl] {- Empty if handwritten abstract -} }
405 newtype_constr : { [] }
406 | src_loc '=' ex_stuff data_name atype { [mkConDecl $4 $3 (NewCon $5 Nothing) $1] }
407 | src_loc '=' ex_stuff data_name '{' var_name '::' atype '}'
408 { [mkConDecl $4 $3 (NewCon $8 (Just $6)) $1] }
410 ex_stuff :: { ([HsTyVar RdrName], RdrNameContext) }
411 ex_stuff : { ([],[]) }
412 | '__forall' forall context '=>' { ($2,$3) }
414 batypes :: { [RdrNameBangType] }
416 | batype batypes { $1 : $2 }
418 batype :: { RdrNameBangType }
419 batype : atype { Unbanged $1 }
420 | '!' atype { Banged $2 }
421 | '!' '!' atype { Unpacked $3 }
423 fields1 :: { [([RdrName], RdrNameBangType)] }
424 fields1 : field { [$1] }
425 | field ',' fields1 { $1 : $3 }
427 field :: { ([RdrName], RdrNameBangType) }
428 field : var_names1 '::' type { ($1, Unbanged $3) }
429 | var_names1 '::' '!' type { ($1, Banged $4) }
430 | var_names1 '::' '!' '!' type { ($1, Unpacked $5) }
431 --------------------------------------------------------------------------
433 type :: { RdrNameHsType }
434 type : '__fuall' fuall '=>' type { mkHsUsForAllTy $2 $4 }
435 | '__forall' forall context '=>' type
436 { mkHsForAllTy (Just $2) $3 $5 }
437 | btype '->' type { MonoFunTy $1 $3 }
440 fuall :: { [RdrName] }
441 fuall : '[' uv_bndrs ']' { $2 }
443 forall :: { [HsTyVar RdrName] }
444 forall : '[' tv_bndrs ']' { $2 }
446 context :: { RdrNameContext }
448 | '{' context_list1 '}' { $2 }
450 context_list1 :: { RdrNameContext }
451 context_list1 : class { [$1] }
452 | class ',' context_list1 { $1 : $3 }
454 class :: { HsPred RdrName }
455 class : qcls_name atypes { (HsPClass $1 $2) }
456 | IPVARID '::' type { (HsPIParam (mkSysUnqual ipName $1) $3) }
458 types0 :: { [RdrNameHsType] {- Zero or more -} }
459 types0 : {- empty -} { [ ] }
463 types2 :: { [RdrNameHsType] {- Two or more -} }
464 types2 : type ',' type { [$1,$3] }
465 | type ',' types2 { $1 : $3 }
467 btype :: { RdrNameHsType }
469 | btype atype { MonoTyApp $1 $2 }
470 | '__u' usage atype { MonoUsgTy $2 $3 }
472 usage :: { MonoUsageAnn RdrName }
473 usage : '-' { MonoUsOnce }
475 | uv_name { MonoUsVar $1 }
477 atype :: { RdrNameHsType }
478 atype : qtc_name { MonoTyVar $1 }
479 | tv_name { MonoTyVar $1 }
480 | '(' types2 ')' { MonoTupleTy $2 True{-boxed-} }
481 | '(#' types0 '#)' { MonoTupleTy $2 False{-unboxed-} }
482 | '[' type ']' { MonoListTy $2 }
483 | '{' qcls_name atypes '}' { MonoDictTy $2 $3 }
484 | '{' IPVARID '::' type '}' { MonoIParamTy (mkSysUnqual ipName $2) $4 }
485 | '(' type ')' { $2 }
487 -- This one is dealt with via qtc_name
488 -- | '(' ')' { MonoTupleTy [] True }
490 atypes :: { [RdrNameHsType] {- Zero or more -} }
492 | atype atypes { $1 : $2 }
493 ---------------------------------------------------------------------
494 mod_fs :: { EncodedFS }
497 mod_name :: { ModuleName }
498 : mod_fs { mkSysModuleFS $1 }
501 ---------------------------------------------------
502 var_fs :: { EncodedFS }
505 | 'as' { SLIT("as") }
506 | 'qualified' { SLIT("qualified") }
507 | 'hiding' { SLIT("hiding") }
508 | 'forall' { SLIT("forall") }
509 | 'foreign' { SLIT("foreign") }
510 | 'export' { SLIT("export") }
511 | 'label' { SLIT("label") }
512 | 'dynamic' { SLIT("dynamic") }
513 | 'unsafe' { SLIT("unsafe") }
514 | 'with' { SLIT("with") }
516 qvar_fs :: { (EncodedFS, EncodedFS) }
520 var_occ :: { OccName }
521 : var_fs { mkSysOccFS varName $1 }
523 var_name :: { RdrName }
524 var_name : var_occ { mkRdrUnqual $1 }
526 qvar_name :: { RdrName }
527 qvar_name : var_name { $1 }
528 | qvar_fs { mkSysQual varName $1 }
530 var_names :: { [RdrName] }
532 | var_name var_names { $1 : $2 }
534 var_names1 :: { [RdrName] }
535 var_names1 : var_name var_names { $1 : $2 }
537 ---------------------------------------------------
538 -- For some bizarre reason,
539 -- (,,,) is dealt with by the parser
540 -- Foo.(,,,) is dealt with by the lexer
543 data_fs :: { EncodedFS }
547 qdata_fs :: { (EncodedFS, EncodedFS) }
551 data_occ :: { OccName }
552 : data_fs { mkSysOccFS dataName $1 }
554 data_name :: { RdrName }
555 : data_occ { mkRdrUnqual $1 }
557 qdata_name :: { RdrName }
558 qdata_name : data_name { $1 }
559 | qdata_fs { mkSysQual dataName $1 }
561 qdata_names :: { [RdrName] }
563 | qdata_name qdata_names { $1 : $2 }
565 var_or_data_name :: { RdrName }
569 ---------------------------------------------------
570 tc_fs :: { EncodedFS }
573 tc_occ :: { OccName }
574 : tc_fs { mkSysOccFS tcName $1 }
576 tc_name :: { RdrName }
577 : tc_occ { mkRdrUnqual $1 }
579 qtc_name :: { RdrName }
581 | qdata_fs { mkSysQual tcName $1 }
583 ---------------------------------------------------
584 cls_name :: { RdrName }
585 : data_fs { mkSysUnqual clsName $1 }
587 qcls_name :: { RdrName }
589 | qdata_fs { mkSysQual clsName $1 }
591 ---------------------------------------------------
592 uv_name :: { RdrName }
593 : VARID { mkSysUnqual uvName $1 }
595 uv_bndr :: { RdrName }
598 uv_bndrs :: { [RdrName] }
600 | uv_bndr uv_bndrs { $1 : $2 }
602 ---------------------------------------------------
603 tv_name :: { RdrName }
604 : VARID { mkSysUnqual tvName $1 }
605 | VARSYM { mkSysUnqual tvName $1 {- Allow t2 as a tyvar -} }
607 tv_bndr :: { HsTyVar RdrName }
608 : tv_name '::' akind { IfaceTyVar $1 $3 }
609 | tv_name { IfaceTyVar $1 boxedTypeKind }
611 tv_bndrs :: { [HsTyVar RdrName] }
613 | tv_bndr tv_bndrs { $1 : $2 }
615 ---------------------------------------------------
616 fds :: { [([RdrName], [RdrName])] }
618 | '|' fds1 { reverse $2 }
620 fds1 :: { [([RdrName], [RdrName])] }
621 : fds1 ',' fd { $3 : $1 }
624 fd :: { ([RdrName], [RdrName]) }
625 : varids0 '->' varids0 { (reverse $1, reverse $3) }
627 varids0 :: { [RdrName] }
629 | varids0 tv_name { $2 : $1 }
631 ---------------------------------------------------
634 | akind '->' kind { mkArrowKind $1 $3 }
637 : VARSYM { if $1 == SLIT("*") then
639 else if $1 == SLIT("?") then
641 else panic "ParseInterface: akind"
643 | '(' kind ')' { $2 }
645 --------------------------------------------------------------------------
647 id_info :: { [HsIdInfo RdrName] }
649 | id_info_item id_info { $1 : $2 }
651 id_info_item :: { HsIdInfo RdrName }
652 : '__A' INTEGER { HsArity (exactArity (fromInteger $2)) }
653 | '__U' inline_prag core_expr { HsUnfold $2 $3 }
654 | '__M' { HsCprInfo $1 }
655 | '__S' { HsStrictness (HsStrictnessInfo $1) }
656 | '__C' { HsNoCafRefs }
657 | '__P' qvar_name { HsWorker $2 }
659 inline_prag :: { InlinePragInfo }
660 : {- empty -} { NoInlinePragInfo }
661 | '[' INTEGER ']' { IMustNotBeINLINEd True (Just (fromInteger $2)) } -- INLINE n
662 | '[' '!' INTEGER ']' { IMustNotBeINLINEd False (Just (fromInteger $3)) } -- NOINLINE n
664 -------------------------------------------------------
665 core_expr :: { UfExpr RdrName }
666 core_expr : '\\' core_bndrs '->' core_expr { foldr UfLam $4 $2 }
667 | 'case' core_expr 'of' var_name
668 '{' core_alts '}' { UfCase $2 $4 $6 }
670 | 'let' '{' core_val_bndr '=' core_expr
671 '}' 'in' core_expr { UfLet (UfNonRec $3 $5) $8 }
672 | '__letrec' '{' rec_binds '}'
673 'in' core_expr { UfLet (UfRec $3) $6 }
675 | con_or_primop '{' core_args '}' { UfCon $1 $3 }
676 | '__litlit' STRING atype { UfCon (UfLitLitCon $2 $3) [] }
678 | '__inline_me' core_expr { UfNote UfInlineMe $2 }
679 | '__inline_call' core_expr { UfNote UfInlineCall $2 }
680 | '__coerce' atype core_expr { UfNote (UfCoerce $2) $3 }
681 | scc core_expr { UfNote (UfSCC $1) $2 }
684 fexpr :: { UfExpr RdrName }
685 fexpr : fexpr core_arg { UfApp $1 $2 }
688 core_arg :: { UfExpr RdrName }
689 : '@' atype { UfType $2 }
692 core_args :: { [UfExpr RdrName] }
694 | core_arg core_args { $1 : $2 }
696 core_aexpr :: { UfExpr RdrName } -- Atomic expressions
697 core_aexpr : qvar_name { UfVar $1 }
699 | qdata_name { UfVar $1 }
700 -- This one means that e.g. "True" will parse as
701 -- (UfVar True_Id) rather than (UfCon True_Con []).
702 -- No big deal; it'll be inlined in a jiffy. I tried
703 -- parsing it to (Con con []) directly, but got bitten
704 -- when a real constructor Id showed up in an interface
705 -- file. As usual, a hack bites you in the end.
706 -- If you want to get a UfCon, then use the
707 -- curly-bracket notation (True {}).
709 | core_lit { UfCon (UfLitCon $1) [] }
710 | '(' core_expr ')' { $2 }
711 | '(' comma_exprs2 ')' { UfTuple (mkTupConRdrName (length $2)) $2 }
712 | '(#' comma_exprs0 '#)' { UfTuple (mkUbxTupConRdrName (length $2)) $2 }
714 -- This one is dealt with by qdata_name: see above comments
715 -- | '(' ')' { UfTuple (mkTupConRdrName 0) [] }
717 comma_exprs0 :: { [UfExpr RdrName] } -- Zero or more
718 comma_exprs0 : {- empty -} { [ ] }
719 | core_expr { [ $1 ] }
720 | comma_exprs2 { $1 }
722 comma_exprs2 :: { [UfExpr RdrName] } -- Two or more
723 comma_exprs2 : core_expr ',' core_expr { [$1,$3] }
724 | core_expr ',' comma_exprs2 { $1 : $3 }
726 con_or_primop :: { UfCon RdrName }
727 con_or_primop : qdata_name { UfDataCon $1 }
728 | qvar_name { UfPrimOp $1 }
729 | '__ccall' ccall_string { let
730 (is_dyn, is_casm, may_gc) = $1
732 UfCCallOp $2 is_dyn is_casm may_gc
735 rec_binds :: { [(UfBinder RdrName, UfExpr RdrName)] }
737 | core_val_bndr '=' core_expr ';' rec_binds { ($1,$3) : $5 }
739 core_alts :: { [UfAlt RdrName] }
741 | core_alt ';' core_alts { $1 : $3 }
743 core_alt :: { UfAlt RdrName }
744 core_alt : core_pat '->' core_expr { (fst $1, snd $1, $3) }
746 core_pat :: { (UfCon RdrName, [RdrName]) }
747 core_pat : core_lit { (UfLitCon $1, []) }
748 | '__litlit' STRING atype { (UfLitLitCon $2 $3, []) }
749 | qdata_name core_pat_names { (UfDataCon $1, $2) }
750 | '(' comma_var_names1 ')' { (UfDataCon (mkTupConRdrName (length $2)), $2) }
751 | '(#' comma_var_names1 '#)' { (UfDataCon (mkUbxTupConRdrName (length $2)), $2) }
752 | '__DEFAULT' { (UfDefault, []) }
753 | '(' core_pat ')' { $2 }
755 core_pat_names :: { [RdrName] }
756 core_pat_names : { [] }
757 | core_pat_name core_pat_names { $1 : $2 }
759 -- Tyvar names and variable names live in different name spaces
760 -- so they need to be signalled separately. But we don't record
761 -- types or kinds in a pattern; we work that out from the type
762 -- of the case scrutinee
763 core_pat_name :: { RdrName }
764 core_pat_name : var_name { $1 }
767 comma_var_names1 :: { [RdrName] } -- One or more
768 comma_var_names1 : var_name { [$1] }
769 | var_name ',' comma_var_names1 { $1 : $3 }
771 core_lit :: { Literal }
772 core_lit : integer { mkMachInt_safe $1 }
773 | CHAR { MachChar $1 }
774 | STRING { MachStr $1 }
775 | '__string' STRING { NoRepStr $2 (panic "NoRepStr type") }
776 | rational { MachDouble $1 }
777 | '__float' rational { MachFloat $2 }
779 | '__integer' integer { NoRepInteger $2 (panic "NoRepInteger type")
780 -- The type checker will add the types
783 | '__rational' integer integer { NoRepRational ($2 % $3)
784 (panic "NoRepRational type")
785 -- The type checker will add the type
788 | '__addr' integer { MachAddr $2 }
790 integer :: { Integer }
792 | '-' INTEGER { (-$2) }
794 rational :: { Rational }
796 | '-' RATIONAL { (-$2) }
798 core_bndr :: { UfBinder RdrName }
799 core_bndr : core_val_bndr { $1 }
800 | core_tv_bndr { $1 }
802 core_bndrs :: { [UfBinder RdrName] }
804 | core_bndr core_bndrs { $1 : $2 }
806 core_val_bndr :: { UfBinder RdrName }
807 core_val_bndr : var_name '::' atype { UfValBinder $1 $3 }
809 core_tv_bndr :: { UfBinder RdrName }
810 core_tv_bndr : '@' tv_name '::' akind { UfTyBinder $2 $4 }
811 | '@' tv_name { UfTyBinder $2 boxedTypeKind }
813 ccall_string :: { FAST_STRING }
819 ------------------------------------------------------------------------
820 scc :: { CostCentre }
821 : '__sccC' '{' mod_name STRING '}' { AllCafsCC $3 $4 }
822 | '__scc' '{' cc_name mod_name STRING cc_dup cc_caf '}'
823 { NormalCC { cc_name = $3, cc_mod = $4, cc_grp = $5,
824 cc_is_dupd = $6, cc_is_caf = $7 } }
826 cc_name :: { EncodedFS }
830 cc_dup :: { IsDupdCC }
831 cc_dup : { OriginalCC }
834 cc_caf :: { IsCafCC }
838 -------------------------------------------------------------------
840 src_loc :: { SrcLoc }
841 src_loc : {% getSrcLocP }
843 checkVersion :: { () }
844 : {-empty-} {% checkVersion Nothing }
845 | INTEGER {% checkVersion (Just (fromInteger $1)) }
847 -------------------------------------------------------------------
852 happyError buf PState{ loc = loc } = PFailed (ifaceParseErr buf loc)
854 data IfaceStuff = PIface EncodedFS{-.hi module name-} ParsedIface
855 | PIdInfo [HsIdInfo RdrName]
856 | PType RdrNameHsType
857 | PRules [RdrNameRuleDecl]
858 | PDeprecs [RdrNameDeprecation]
860 mkConDecl name (ex_tvs, ex_ctxt) details loc = ConDecl name ex_tvs ex_ctxt details loc