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, 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 }
83 '__interface' { ITinterface } -- interface keywords
84 '__export' { IT__export }
85 '__forall' { IT__forall }
86 '__depends' { ITdepends }
87 '__letrec' { ITletrec }
88 '__coerce' { ITcoerce }
89 '__inline_call'{ ITinlineCall }
90 '__inline_me' { ITinlineMe }
91 '__DEFAULT' { ITdefaultbranch }
93 '__integer' { ITinteger_lit }
94 '__float' { ITfloat_lit }
95 '__rational' { ITrational_lit }
96 '__addr' { ITaddr_lit }
97 '__litlit' { ITlit_lit }
98 '__string' { ITstring_lit }
99 '__ccall' { ITccall $$ }
101 '__sccC' { ITsccAllCafs }
104 '__fuall' { ITfuall }
107 '__P' { ITspecialise }
109 '__U' { ITunfold $$ }
110 '__S' { ITstrict $$ }
112 '__M' { ITcprinfo $$ }
114 '..' { ITdotdot } -- reserved symbols
127 '/\\' { ITbiglam } -- GHC-extension symbols
129 '{' { ITocurly } -- special symbols
140 VARID { ITvarid $$ } -- identifiers
142 VARSYM { ITvarsym $$ }
143 CONSYM { ITconsym $$ }
144 QVARID { ITqvarid $$ }
145 QCONID { ITqconid $$ }
146 QVARSYM { ITqvarsym $$ }
147 QCONSYM { ITqconsym $$ }
149 PRAGMA { ITpragma $$ }
152 STRING { ITstring $$ }
153 INTEGER { ITinteger $$ }
154 RATIONAL { ITrational $$ }
155 CLITLIT { ITlitlit $$ }
157 UNKNOWN { ITunknown $$ }
160 -- iface_stuff is the main production.
161 -- It recognises (a) a whole interface file
162 -- (b) a type (so that type sigs can be parsed lazily)
163 -- (c) the IdInfo part of a signature (same reason)
165 iface_stuff :: { IfaceStuff }
166 iface_stuff : iface { let (nm, iff) = $1 in PIface nm iff }
168 | id_info { PIdInfo $1 }
169 | '__R' rules { PRules $2 }
172 iface :: { (ModuleName, ParsedIface) }
173 iface : '__interface' mod_fs INTEGER orphans checkVersion 'where'
179 { ( $2 -- Module name
181 pi_mod = fromInteger $3, -- Module version
183 pi_exports = $7, -- Exports
184 pi_usages = $8, -- Usages
185 pi_insts = $9, -- Local instances
186 pi_decls = $10, -- Decls
187 pi_rules = $11 -- Rules
190 --------------------------------------------------------------------------
192 import_part :: { [ImportVersion OccName] }
194 | import_part import_decl { $2 : $1 }
196 import_decl :: { ImportVersion OccName }
197 import_decl : 'import' mod_fs INTEGER orphans whats_imported ';'
198 { (mkSysModuleFS $2, fromInteger $3, $4, $5) }
199 -- import Foo 3 :: a 1 b 3 c 7 ; means import a,b,c from Foo
200 -- import Foo 3 ; means import all of Foo
201 -- import Foo 3 ! :: ...stuff... ; the ! means that Foo contains orphans
203 orphans :: { WhetherHasOrphans }
207 whats_imported :: { WhatsImported OccName }
208 whats_imported : { Everything }
209 | '::' name_version_pairs { Specifically $2 }
211 name_version_pairs :: { [LocalVersion OccName] }
212 name_version_pairs : { [] }
213 | name_version_pair name_version_pairs { $1 : $2 }
215 name_version_pair :: { LocalVersion OccName }
216 name_version_pair : var_occ INTEGER { ($1, fromInteger $2) }
217 | tc_occ INTEGER { ($1, fromInteger $2) }
220 --------------------------------------------------------------------------
222 exports_part :: { [ExportItem] }
223 exports_part : { [] }
224 | exports_part '__export'
225 mod_fs entities ';' { (mkSysModuleFS $3, $4) : $1 }
227 entities :: { [RdrAvailInfo] }
229 | entity entities { $1 : $2 }
231 entity :: { RdrAvailInfo }
232 entity : tc_occ { AvailTC $1 [$1] }
233 | var_occ { Avail $1 }
234 | tc_occ stuff_inside { AvailTC $1 ($1:$2) }
235 | tc_occ '|' stuff_inside { AvailTC $1 $3 }
237 stuff_inside :: { [OccName] }
238 stuff_inside : '{' val_occs '}' { $2 }
240 val_occ :: { OccName }
244 val_occs :: { [OccName] }
246 | val_occ val_occs { $1 : $2 }
249 --------------------------------------------------------------------------
251 fixity :: { FixityDirection }
252 fixity : 'infixl' { InfixL }
253 | 'infixr' { InfixR }
257 mb_fix : {-nothing-} { 9 }
258 | INTEGER { (fromInteger $1) }
260 -----------------------------------------------------------------------------
262 csigs :: { [RdrNameSig] }
264 | 'where' '{' csigs1 '}' { $3 }
266 csigs1 :: { [RdrNameSig] }
267 csigs1 : csig { [$1] }
268 | csig ';' csigs1 { $1 : $3 }
270 csig :: { RdrNameSig }
271 csig : src_loc var_name '::' type { mkClassOpSig False $2 $4 $1 }
272 | src_loc var_name '=' '::' type { mkClassOpSig True $2 $5 $1 }
274 --------------------------------------------------------------------------
276 instance_decl_part :: { [RdrNameInstDecl] }
277 instance_decl_part : {- empty -} { [] }
278 | instance_decl_part inst_decl { $2 : $1 }
280 inst_decl :: { RdrNameInstDecl }
281 inst_decl : src_loc 'instance' type '=' var_name ';'
283 EmptyMonoBinds {- No bindings -}
284 [] {- No user pragmas -}
289 --------------------------------------------------------------------------
291 decls_part :: { [(Version, RdrNameHsDecl)] }
294 | decls_part version decl ';' { ($2,$3):$1 }
296 decl :: { RdrNameHsDecl }
297 decl : src_loc var_name '::' type maybe_idinfo
298 { SigD (IfaceSig $2 $4 ($5 $2) $1) }
299 | src_loc 'type' tc_name tv_bndrs '=' type
300 { TyClD (TySynonym $3 $4 $6 $1) }
301 | src_loc 'data' decl_context tc_name tv_bndrs constrs
302 { TyClD (TyData DataType $3 $4 $5 $6 Nothing noDataPragmas $1) }
303 | src_loc 'newtype' decl_context tc_name tv_bndrs newtype_constr
304 { TyClD (TyData NewType $3 $4 $5 $6 Nothing noDataPragmas $1) }
305 | src_loc 'class' decl_context tc_name tv_bndrs fds csigs
306 { TyClD (mkClassDecl $3 $4 $5 $6 $7 EmptyMonoBinds
308 | src_loc fixity mb_fix var_or_data_name
309 { FixD (FixitySig $4 (Fixity $3 $2) $1) }
311 maybe_idinfo :: { RdrName -> [HsIdInfo RdrName] }
312 maybe_idinfo : {- empty -} { \_ -> [] }
313 | src_loc PRAGMA { \x ->
315 PState{bol = 0#, atbol = 1#,
319 POk _ (PIdInfo id_info) -> id_info
321 pprPanic "IdInfo parse failed"
325 -----------------------------------------------------------------------------
327 rules_part :: { [RdrNameRuleDecl] }
328 rules_part : {- empty -} { [] }
329 | src_loc PRAGMA { case parseIface $2
330 PState{bol = 0#, atbol = 1#,
334 POk _ (PRules rules) -> rules
336 pprPanic "Rules parse failed" err
339 rules :: { [RdrNameRuleDecl] }
341 | rule ';' rules { $1:$3 }
343 rule :: { RdrNameRuleDecl }
344 rule : src_loc STRING rule_forall qvar_name
345 core_args '=' core_expr { IfaceRuleDecl $4 (UfRuleBody $2 $3 $5 $7) $1 }
347 rule_forall :: { [UfBinder RdrName] }
348 rule_forall : '__forall' '{' core_bndrs '}' { $3 }
350 -----------------------------------------------------------------------------
352 version :: { Version }
353 version : INTEGER { fromInteger $1 }
355 decl_context :: { RdrNameContext }
356 decl_context : { [] }
357 | '{' context_list1 '}' '=>' { $2 }
359 ----------------------------------------------------------------------------
361 constrs :: { [RdrNameConDecl] {- empty for handwritten abstract -} }
363 | '=' constrs1 { $2 }
365 constrs1 :: { [RdrNameConDecl] }
366 constrs1 : constr { [$1] }
367 | constr '|' constrs1 { $1 : $3 }
369 constr :: { RdrNameConDecl }
370 constr : src_loc ex_stuff data_name batypes { mkConDecl $3 $2 (VanillaCon $4) $1 }
371 | src_loc ex_stuff data_name '{' fields1 '}' { mkConDecl $3 $2 (RecCon $5) $1 }
372 -- We use "data_fs" so as to include ()
374 newtype_constr :: { [RdrNameConDecl] {- Empty if handwritten abstract -} }
375 newtype_constr : { [] }
376 | src_loc '=' ex_stuff data_name atype { [mkConDecl $4 $3 (NewCon $5 Nothing) $1] }
377 | src_loc '=' ex_stuff data_name '{' var_name '::' atype '}'
378 { [mkConDecl $4 $3 (NewCon $8 (Just $6)) $1] }
380 ex_stuff :: { ([HsTyVar RdrName], RdrNameContext) }
381 ex_stuff : { ([],[]) }
382 | '__forall' forall context '=>' { ($2,$3) }
384 batypes :: { [RdrNameBangType] }
386 | batype batypes { $1 : $2 }
388 batype :: { RdrNameBangType }
389 batype : atype { Unbanged $1 }
390 | '!' atype { Banged $2 }
391 | '!' '!' atype { Unpacked $3 }
393 fields1 :: { [([RdrName], RdrNameBangType)] }
394 fields1 : field { [$1] }
395 | field ',' fields1 { $1 : $3 }
397 field :: { ([RdrName], RdrNameBangType) }
398 field : var_names1 '::' type { ($1, Unbanged $3) }
399 | var_names1 '::' '!' type { ($1, Banged $4) }
400 | var_names1 '::' '!' '!' type { ($1, Unpacked $5) }
401 --------------------------------------------------------------------------
403 type :: { RdrNameHsType }
404 type : '__fuall' fuall '=>' type { mkHsUsForAllTy $2 $4 }
405 | '__forall' forall context '=>' type
406 { mkHsForAllTy (Just $2) $3 $5 }
407 | btype '->' type { MonoFunTy $1 $3 }
410 fuall :: { [RdrName] }
411 fuall : '[' uv_bndrs ']' { $2 }
413 forall :: { [HsTyVar RdrName] }
414 forall : '[' tv_bndrs ']' { $2 }
416 context :: { RdrNameContext }
418 | '{' context_list1 '}' { $2 }
420 context_list1 :: { RdrNameContext }
421 context_list1 : class { [$1] }
422 | class ',' context_list1 { $1 : $3 }
424 class :: { (RdrName, [RdrNameHsType]) }
425 class : qcls_name atypes { ($1, $2) }
427 types0 :: { [RdrNameHsType] {- Zero or more -} }
428 types0 : {- empty -} { [ ] }
432 types2 :: { [RdrNameHsType] {- Two or more -} }
433 types2 : type ',' type { [$1,$3] }
434 | type ',' types2 { $1 : $3 }
436 btype :: { RdrNameHsType }
438 | btype atype { MonoTyApp $1 $2 }
439 | '__u' usage atype { MonoUsgTy $2 $3 }
441 usage :: { MonoUsageAnn RdrName }
442 usage : '-' { MonoUsOnce }
444 | uv_name { MonoUsVar $1 }
446 atype :: { RdrNameHsType }
447 atype : qtc_name { MonoTyVar $1 }
448 | tv_name { MonoTyVar $1 }
449 | '(' types2 ')' { MonoTupleTy $2 True{-boxed-} }
450 | '(#' types0 '#)' { MonoTupleTy $2 False{-unboxed-} }
451 | '[' type ']' { MonoListTy $2 }
452 | '{' qcls_name atypes '}' { MonoDictTy $2 $3 }
453 | '(' type ')' { $2 }
455 -- This one is dealt with via qtc_name
456 -- | '(' ')' { MonoTupleTy [] True }
458 atypes :: { [RdrNameHsType] {- Zero or more -} }
460 | atype atypes { $1 : $2 }
461 ---------------------------------------------------------------------
462 mod_fs :: { EncodedFS }
465 mod_name :: { ModuleName }
466 : mod_fs { mkSysModuleFS $1 }
469 ---------------------------------------------------
470 var_fs :: { EncodedFS }
474 | 'as' { SLIT("as") }
475 | 'qualified' { SLIT("qualified") }
476 | 'hiding' { SLIT("hiding") }
477 | 'forall' { SLIT("forall") }
478 | 'foreign' { SLIT("foreign") }
479 | 'export' { SLIT("export") }
480 | 'label' { SLIT("label") }
481 | 'dynamic' { SLIT("dynamic") }
482 | 'unsafe' { SLIT("unsafe") }
484 qvar_fs :: { (EncodedFS, EncodedFS) }
488 var_occ :: { OccName }
489 : var_fs { mkSysOccFS varName $1 }
491 var_name :: { RdrName }
492 var_name : var_occ { mkRdrUnqual $1 }
494 qvar_name :: { RdrName }
495 qvar_name : var_name { $1 }
496 | qvar_fs { mkSysQual varName $1 }
498 var_names :: { [RdrName] }
500 | var_name var_names { $1 : $2 }
502 var_names1 :: { [RdrName] }
503 var_names1 : var_name var_names { $1 : $2 }
505 ---------------------------------------------------
506 -- For some bizarre reason,
507 -- (,,,) is dealt with by the parser
508 -- Foo.(,,,) is dealt with by the lexer
511 data_fs :: { EncodedFS }
515 qdata_fs :: { (EncodedFS, EncodedFS) }
519 data_occ :: { OccName }
520 : data_fs { mkSysOccFS dataName $1 }
522 data_name :: { RdrName }
523 : data_occ { mkRdrUnqual $1 }
525 qdata_name :: { RdrName }
526 qdata_name : data_name { $1 }
527 | qdata_fs { mkSysQual dataName $1 }
529 qdata_names :: { [RdrName] }
531 | qdata_name qdata_names { $1 : $2 }
533 var_or_data_name :: { RdrName }
537 ---------------------------------------------------
538 tc_fs :: { EncodedFS }
541 tc_occ :: { OccName }
542 : tc_fs { mkSysOccFS tcName $1 }
544 tc_name :: { RdrName }
545 : tc_occ { mkRdrUnqual $1 }
547 qtc_name :: { RdrName }
549 | qdata_fs { mkSysQual tcName $1 }
551 ---------------------------------------------------
552 cls_name :: { RdrName }
553 : data_fs { mkSysUnqual clsName $1 }
555 qcls_name :: { RdrName }
557 | qdata_fs { mkSysQual clsName $1 }
559 ---------------------------------------------------
560 uv_name :: { RdrName }
561 : VARID { mkSysUnqual uvName $1 }
563 uv_bndr :: { RdrName }
566 uv_bndrs :: { [RdrName] }
568 | uv_bndr uv_bndrs { $1 : $2 }
570 ---------------------------------------------------
571 tv_name :: { RdrName }
572 : VARID { mkSysUnqual tvName $1 }
573 | VARSYM { mkSysUnqual tvName $1 {- Allow t2 as a tyvar -} }
575 tv_bndr :: { HsTyVar RdrName }
576 : tv_name '::' akind { IfaceTyVar $1 $3 }
577 | tv_name { IfaceTyVar $1 boxedTypeKind }
579 tv_bndrs :: { [HsTyVar RdrName] }
581 | tv_bndr tv_bndrs { $1 : $2 }
583 ---------------------------------------------------
584 fds :: { [([RdrName], [RdrName])] }
586 | '|' fds1 { reverse $2 }
588 fds1 :: { [([RdrName], [RdrName])] }
589 : fds1 ',' fd { $3 : $1 }
592 fd :: { ([RdrName], [RdrName]) }
593 : varids0 '->' varids0 { (reverse $1, reverse $3) }
595 varids0 :: { [RdrName] }
597 | varids0 tv_name { $2 : $1 }
599 ---------------------------------------------------
602 | akind '->' kind { mkArrowKind $1 $3 }
605 : VARSYM { if $1 == SLIT("*") then
607 else if $1 == SLIT("?") then
609 else panic "ParseInterface: akind"
611 | '(' kind ')' { $2 }
613 --------------------------------------------------------------------------
615 id_info :: { [HsIdInfo RdrName] }
617 | id_info_item id_info { $1 : $2 }
619 id_info_item :: { HsIdInfo RdrName }
620 : '__A' INTEGER { HsArity (exactArity (fromInteger $2)) }
621 | '__U' inline_prag core_expr { HsUnfold $2 $3 }
622 | '__M' { HsCprInfo $1 }
623 | '__S' { HsStrictness (HsStrictnessInfo $1) }
624 | '__C' { HsNoCafRefs }
625 | '__P' qvar_name { HsWorker $2 }
627 inline_prag :: { InlinePragInfo }
628 : {- empty -} { NoInlinePragInfo }
629 | '[' INTEGER ']' { IMustNotBeINLINEd True (Just (fromInteger $2)) } -- INLINE n
630 | '[' '!' INTEGER ']' { IMustNotBeINLINEd False (Just (fromInteger $3)) } -- NOINLINE n
632 -------------------------------------------------------
633 core_expr :: { UfExpr RdrName }
634 core_expr : '\\' core_bndrs '->' core_expr { foldr UfLam $4 $2 }
635 | 'case' core_expr 'of' var_name
636 '{' core_alts '}' { UfCase $2 $4 $6 }
638 | 'let' '{' core_val_bndr '=' core_expr
639 '}' 'in' core_expr { UfLet (UfNonRec $3 $5) $8 }
640 | '__letrec' '{' rec_binds '}'
641 'in' core_expr { UfLet (UfRec $3) $6 }
643 | con_or_primop '{' core_args '}' { UfCon $1 $3 }
644 | '__litlit' STRING atype { UfCon (UfLitLitCon $2 $3) [] }
646 | '__inline_me' core_expr { UfNote UfInlineMe $2 }
647 | '__inline_call' core_expr { UfNote UfInlineCall $2 }
648 | '__coerce' atype core_expr { UfNote (UfCoerce $2) $3 }
649 | scc core_expr { UfNote (UfSCC $1) $2 }
652 fexpr :: { UfExpr RdrName }
653 fexpr : fexpr core_arg { UfApp $1 $2 }
656 core_arg :: { UfExpr RdrName }
657 : '@' atype { UfType $2 }
660 core_args :: { [UfExpr RdrName] }
662 | core_arg core_args { $1 : $2 }
664 core_aexpr :: { UfExpr RdrName } -- Atomic expressions
665 core_aexpr : qvar_name { UfVar $1 }
667 | qdata_name { UfVar $1 }
668 -- This one means that e.g. "True" will parse as
669 -- (UfVar True_Id) rather than (UfCon True_Con []).
670 -- No big deal; it'll be inlined in a jiffy. I tried
671 -- parsing it to (Con con []) directly, but got bitten
672 -- when a real constructor Id showed up in an interface
673 -- file. As usual, a hack bites you in the end.
674 -- If you want to get a UfCon, then use the
675 -- curly-bracket notation (True {}).
677 | core_lit { UfCon (UfLitCon $1) [] }
678 | '(' core_expr ')' { $2 }
679 | '(' comma_exprs2 ')' { UfTuple (mkTupConRdrName (length $2)) $2 }
680 | '(#' comma_exprs0 '#)' { UfTuple (mkUbxTupConRdrName (length $2)) $2 }
682 -- This one is dealt with by qdata_name: see above comments
683 -- | '(' ')' { UfTuple (mkTupConRdrName 0) [] }
685 comma_exprs0 :: { [UfExpr RdrName] } -- Zero or more
686 comma_exprs0 : {- empty -} { [ ] }
687 | core_expr { [ $1 ] }
688 | comma_exprs2 { $1 }
690 comma_exprs2 :: { [UfExpr RdrName] } -- Two or more
691 comma_exprs2 : core_expr ',' core_expr { [$1,$3] }
692 | core_expr ',' comma_exprs2 { $1 : $3 }
694 con_or_primop :: { UfCon RdrName }
695 con_or_primop : qdata_name { UfDataCon $1 }
696 | qvar_name { UfPrimOp $1 }
697 | '__ccall' ccall_string { let
698 (is_dyn, is_casm, may_gc) = $1
700 UfCCallOp $2 is_dyn is_casm may_gc
703 rec_binds :: { [(UfBinder RdrName, UfExpr RdrName)] }
705 | core_val_bndr '=' core_expr ';' rec_binds { ($1,$3) : $5 }
707 core_alts :: { [UfAlt RdrName] }
709 | core_alt ';' core_alts { $1 : $3 }
711 core_alt :: { UfAlt RdrName }
712 core_alt : core_pat '->' core_expr { (fst $1, snd $1, $3) }
714 core_pat :: { (UfCon RdrName, [RdrName]) }
715 core_pat : core_lit { (UfLitCon $1, []) }
716 | '__litlit' STRING atype { (UfLitLitCon $2 $3, []) }
717 | qdata_name core_pat_names { (UfDataCon $1, $2) }
718 | '(' comma_var_names1 ')' { (UfDataCon (mkTupConRdrName (length $2)), $2) }
719 | '(#' comma_var_names1 '#)' { (UfDataCon (mkUbxTupConRdrName (length $2)), $2) }
720 | '__DEFAULT' { (UfDefault, []) }
721 | '(' core_pat ')' { $2 }
723 core_pat_names :: { [RdrName] }
724 core_pat_names : { [] }
725 | core_pat_name core_pat_names { $1 : $2 }
727 -- Tyvar names and variable names live in different name spaces
728 -- so they need to be signalled separately. But we don't record
729 -- types or kinds in a pattern; we work that out from the type
730 -- of the case scrutinee
731 core_pat_name :: { RdrName }
732 core_pat_name : var_name { $1 }
735 comma_var_names1 :: { [RdrName] } -- One or more
736 comma_var_names1 : var_name { [$1] }
737 | var_name ',' comma_var_names1 { $1 : $3 }
739 core_lit :: { Literal }
740 core_lit : integer { mkMachInt_safe $1 }
741 | CHAR { MachChar $1 }
742 | STRING { MachStr $1 }
743 | '__string' STRING { NoRepStr $2 (panic "NoRepStr type") }
744 | rational { MachDouble $1 }
745 | '__float' rational { MachFloat $2 }
747 | '__integer' integer { NoRepInteger $2 (panic "NoRepInteger type")
748 -- The type checker will add the types
751 | '__rational' integer integer { NoRepRational ($2 % $3)
752 (panic "NoRepRational type")
753 -- The type checker will add the type
756 | '__addr' integer { MachAddr $2 }
758 integer :: { Integer }
760 | '-' INTEGER { (-$2) }
762 rational :: { Rational }
764 | '-' RATIONAL { (-$2) }
766 core_bndr :: { UfBinder RdrName }
767 core_bndr : core_val_bndr { $1 }
768 | core_tv_bndr { $1 }
770 core_bndrs :: { [UfBinder RdrName] }
772 | core_bndr core_bndrs { $1 : $2 }
774 core_val_bndr :: { UfBinder RdrName }
775 core_val_bndr : var_name '::' atype { UfValBinder $1 $3 }
777 core_tv_bndr :: { UfBinder RdrName }
778 core_tv_bndr : '@' tv_name '::' akind { UfTyBinder $2 $4 }
779 | '@' tv_name { UfTyBinder $2 boxedTypeKind }
781 ccall_string :: { FAST_STRING }
787 ------------------------------------------------------------------------
788 scc :: { CostCentre }
789 : '__sccC' '{' mod_name STRING '}' { AllCafsCC $3 $4 }
790 | '__scc' '{' cc_name mod_name STRING cc_dup cc_caf '}'
791 { NormalCC { cc_name = $3, cc_mod = $4, cc_grp = $5,
792 cc_is_dupd = $6, cc_is_caf = $7 } }
794 cc_name :: { EncodedFS }
798 cc_dup :: { IsDupdCC }
799 cc_dup : { OriginalCC }
802 cc_caf :: { IsCafCC }
806 -------------------------------------------------------------------
808 src_loc :: { SrcLoc }
809 src_loc : {% getSrcLocP }
811 checkVersion :: { () }
812 : {-empty-} {% checkVersion Nothing }
813 | INTEGER {% checkVersion (Just (fromInteger $1)) }
815 -------------------------------------------------------------------
820 happyError buf PState{ loc = loc } = PFailed (ifaceParseErr buf loc)
822 data IfaceStuff = PIface EncodedFS{-.hi module name-} ParsedIface
823 | PIdInfo [HsIdInfo RdrName]
824 | PType RdrNameHsType
825 | PRules [RdrNameRuleDecl]
827 mkConDecl name (ex_tvs, ex_ctxt) details loc = ConDecl name ex_tvs ex_ctxt details loc