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 }
473 | 'as' { SLIT("as") }
474 | 'qualified' { SLIT("qualified") }
475 | 'hiding' { SLIT("hiding") }
476 | 'forall' { SLIT("forall") }
477 | 'foreign' { SLIT("foreign") }
478 | 'export' { SLIT("export") }
479 | 'label' { SLIT("label") }
480 | 'dynamic' { SLIT("dynamic") }
481 | 'unsafe' { SLIT("unsafe") }
483 qvar_fs :: { (EncodedFS, EncodedFS) }
487 var_occ :: { OccName }
488 : var_fs { mkSysOccFS varName $1 }
490 var_name :: { RdrName }
491 var_name : var_occ { mkRdrUnqual $1 }
493 qvar_name :: { RdrName }
494 qvar_name : var_name { $1 }
495 | qvar_fs { mkSysQual varName $1 }
497 var_names :: { [RdrName] }
499 | var_name var_names { $1 : $2 }
501 var_names1 :: { [RdrName] }
502 var_names1 : var_name var_names { $1 : $2 }
504 ---------------------------------------------------
505 -- For some bizarre reason,
506 -- (,,,) is dealt with by the parser
507 -- Foo.(,,,) is dealt with by the lexer
510 data_fs :: { EncodedFS }
514 qdata_fs :: { (EncodedFS, EncodedFS) }
518 data_occ :: { OccName }
519 : data_fs { mkSysOccFS dataName $1 }
521 data_name :: { RdrName }
522 : data_occ { mkRdrUnqual $1 }
524 qdata_name :: { RdrName }
525 qdata_name : data_name { $1 }
526 | qdata_fs { mkSysQual dataName $1 }
528 qdata_names :: { [RdrName] }
530 | qdata_name qdata_names { $1 : $2 }
532 var_or_data_name :: { RdrName }
536 ---------------------------------------------------
537 tc_fs :: { EncodedFS }
540 tc_occ :: { OccName }
541 : tc_fs { mkSysOccFS tcName $1 }
543 tc_name :: { RdrName }
544 : tc_occ { mkRdrUnqual $1 }
546 qtc_name :: { RdrName }
548 | qdata_fs { mkSysQual tcName $1 }
550 ---------------------------------------------------
551 cls_name :: { RdrName }
552 : data_fs { mkSysUnqual clsName $1 }
554 qcls_name :: { RdrName }
556 | qdata_fs { mkSysQual clsName $1 }
558 ---------------------------------------------------
559 uv_name :: { RdrName }
560 : VARID { mkSysUnqual uvName $1 }
562 uv_bndr :: { RdrName }
565 uv_bndrs :: { [RdrName] }
567 | uv_bndr uv_bndrs { $1 : $2 }
569 ---------------------------------------------------
570 tv_name :: { RdrName }
571 : VARID { mkSysUnqual tvName $1 }
572 | VARSYM { mkSysUnqual tvName $1 {- Allow t2 as a tyvar -} }
574 tv_bndr :: { HsTyVar RdrName }
575 : tv_name '::' akind { IfaceTyVar $1 $3 }
576 | tv_name { IfaceTyVar $1 boxedTypeKind }
578 tv_bndrs :: { [HsTyVar RdrName] }
580 | tv_bndr tv_bndrs { $1 : $2 }
582 ---------------------------------------------------
583 fds :: { [([RdrName], [RdrName])] }
585 | '|' fds1 { reverse $2 }
587 fds1 :: { [([RdrName], [RdrName])] }
588 : fds1 ',' fd { $3 : $1 }
591 fd :: { ([RdrName], [RdrName]) }
592 : varids0 '->' varids0 { (reverse $1, reverse $3) }
594 varids0 :: { [RdrName] }
596 | varids0 tv_name { $2 : $1 }
598 ---------------------------------------------------
601 | akind '->' kind { mkArrowKind $1 $3 }
604 : VARSYM { if $1 == SLIT("*") then
606 else if $1 == SLIT("?") then
608 else panic "ParseInterface: akind"
610 | '(' kind ')' { $2 }
612 --------------------------------------------------------------------------
614 id_info :: { [HsIdInfo RdrName] }
616 | id_info_item id_info { $1 : $2 }
618 id_info_item :: { HsIdInfo RdrName }
619 : '__A' INTEGER { HsArity (exactArity (fromInteger $2)) }
620 | '__U' inline_prag core_expr { HsUnfold $2 $3 }
621 | '__M' { HsCprInfo $1 }
622 | '__S' { HsStrictness (HsStrictnessInfo $1) }
623 | '__C' { HsNoCafRefs }
624 | '__P' qvar_name { HsWorker $2 }
626 inline_prag :: { InlinePragInfo }
627 : {- empty -} { NoInlinePragInfo }
628 | '[' INTEGER ']' { IMustNotBeINLINEd True (Just (fromInteger $2)) } -- INLINE n
629 | '[' '!' INTEGER ']' { IMustNotBeINLINEd False (Just (fromInteger $3)) } -- NOINLINE n
631 -------------------------------------------------------
632 core_expr :: { UfExpr RdrName }
633 core_expr : '\\' core_bndrs '->' core_expr { foldr UfLam $4 $2 }
634 | 'case' core_expr 'of' var_name
635 '{' core_alts '}' { UfCase $2 $4 $6 }
637 | 'let' '{' core_val_bndr '=' core_expr
638 '}' 'in' core_expr { UfLet (UfNonRec $3 $5) $8 }
639 | '__letrec' '{' rec_binds '}'
640 'in' core_expr { UfLet (UfRec $3) $6 }
642 | con_or_primop '{' core_args '}' { UfCon $1 $3 }
643 | '__litlit' STRING atype { UfCon (UfLitLitCon $2 $3) [] }
645 | '__inline_me' core_expr { UfNote UfInlineMe $2 }
646 | '__inline_call' core_expr { UfNote UfInlineCall $2 }
647 | '__coerce' atype core_expr { UfNote (UfCoerce $2) $3 }
648 | scc core_expr { UfNote (UfSCC $1) $2 }
651 fexpr :: { UfExpr RdrName }
652 fexpr : fexpr core_arg { UfApp $1 $2 }
655 core_arg :: { UfExpr RdrName }
656 : '@' atype { UfType $2 }
659 core_args :: { [UfExpr RdrName] }
661 | core_arg core_args { $1 : $2 }
663 core_aexpr :: { UfExpr RdrName } -- Atomic expressions
664 core_aexpr : qvar_name { UfVar $1 }
666 | qdata_name { UfVar $1 }
667 -- This one means that e.g. "True" will parse as
668 -- (UfVar True_Id) rather than (UfCon True_Con []).
669 -- No big deal; it'll be inlined in a jiffy. I tried
670 -- parsing it to (Con con []) directly, but got bitten
671 -- when a real constructor Id showed up in an interface
672 -- file. As usual, a hack bites you in the end.
673 -- If you want to get a UfCon, then use the
674 -- curly-bracket notation (True {}).
676 | core_lit { UfCon (UfLitCon $1) [] }
677 | '(' core_expr ')' { $2 }
678 | '(' comma_exprs2 ')' { UfTuple (mkTupConRdrName (length $2)) $2 }
679 | '(#' comma_exprs0 '#)' { UfTuple (mkUbxTupConRdrName (length $2)) $2 }
681 -- This one is dealt with by qdata_name: see above comments
682 -- | '(' ')' { UfTuple (mkTupConRdrName 0) [] }
684 comma_exprs0 :: { [UfExpr RdrName] } -- Zero or more
685 comma_exprs0 : {- empty -} { [ ] }
686 | core_expr { [ $1 ] }
687 | comma_exprs2 { $1 }
689 comma_exprs2 :: { [UfExpr RdrName] } -- Two or more
690 comma_exprs2 : core_expr ',' core_expr { [$1,$3] }
691 | core_expr ',' comma_exprs2 { $1 : $3 }
693 con_or_primop :: { UfCon RdrName }
694 con_or_primop : qdata_name { UfDataCon $1 }
695 | qvar_name { UfPrimOp $1 }
696 | '__ccall' ccall_string { let
697 (is_dyn, is_casm, may_gc) = $1
699 UfCCallOp $2 is_dyn is_casm may_gc
702 rec_binds :: { [(UfBinder RdrName, UfExpr RdrName)] }
704 | core_val_bndr '=' core_expr ';' rec_binds { ($1,$3) : $5 }
706 core_alts :: { [UfAlt RdrName] }
708 | core_alt ';' core_alts { $1 : $3 }
710 core_alt :: { UfAlt RdrName }
711 core_alt : core_pat '->' core_expr { (fst $1, snd $1, $3) }
713 core_pat :: { (UfCon RdrName, [RdrName]) }
714 core_pat : core_lit { (UfLitCon $1, []) }
715 | '__litlit' STRING atype { (UfLitLitCon $2 $3, []) }
716 | qdata_name core_pat_names { (UfDataCon $1, $2) }
717 | '(' comma_var_names1 ')' { (UfDataCon (mkTupConRdrName (length $2)), $2) }
718 | '(#' comma_var_names1 '#)' { (UfDataCon (mkUbxTupConRdrName (length $2)), $2) }
719 | '__DEFAULT' { (UfDefault, []) }
720 | '(' core_pat ')' { $2 }
722 core_pat_names :: { [RdrName] }
723 core_pat_names : { [] }
724 | core_pat_name core_pat_names { $1 : $2 }
726 -- Tyvar names and variable names live in different name spaces
727 -- so they need to be signalled separately. But we don't record
728 -- types or kinds in a pattern; we work that out from the type
729 -- of the case scrutinee
730 core_pat_name :: { RdrName }
731 core_pat_name : var_name { $1 }
734 comma_var_names1 :: { [RdrName] } -- One or more
735 comma_var_names1 : var_name { [$1] }
736 | var_name ',' comma_var_names1 { $1 : $3 }
738 core_lit :: { Literal }
739 core_lit : integer { mkMachInt_safe $1 }
740 | CHAR { MachChar $1 }
741 | STRING { MachStr $1 }
742 | '__string' STRING { NoRepStr $2 (panic "NoRepStr type") }
743 | rational { MachDouble $1 }
744 | '__float' rational { MachFloat $2 }
746 | '__integer' integer { NoRepInteger $2 (panic "NoRepInteger type")
747 -- The type checker will add the types
750 | '__rational' integer integer { NoRepRational ($2 % $3)
751 (panic "NoRepRational type")
752 -- The type checker will add the type
755 | '__addr' integer { MachAddr $2 }
757 integer :: { Integer }
759 | '-' INTEGER { (-$2) }
761 rational :: { Rational }
763 | '-' RATIONAL { (-$2) }
765 core_bndr :: { UfBinder RdrName }
766 core_bndr : core_val_bndr { $1 }
767 | core_tv_bndr { $1 }
769 core_bndrs :: { [UfBinder RdrName] }
771 | core_bndr core_bndrs { $1 : $2 }
773 core_val_bndr :: { UfBinder RdrName }
774 core_val_bndr : var_name '::' atype { UfValBinder $1 $3 }
776 core_tv_bndr :: { UfBinder RdrName }
777 core_tv_bndr : '@' tv_name '::' akind { UfTyBinder $2 $4 }
778 | '@' tv_name { UfTyBinder $2 boxedTypeKind }
780 ccall_string :: { FAST_STRING }
786 ------------------------------------------------------------------------
787 scc :: { CostCentre }
788 : '__sccC' '{' mod_name STRING '}' { AllCafsCC $3 $4 }
789 | '__scc' '{' cc_name mod_name STRING cc_dup cc_caf '}'
790 { NormalCC { cc_name = $3, cc_mod = $4, cc_grp = $5,
791 cc_is_dupd = $6, cc_is_caf = $7 } }
793 cc_name :: { EncodedFS }
797 cc_dup :: { IsDupdCC }
798 cc_dup : { OriginalCC }
801 cc_caf :: { IsCafCC }
805 -------------------------------------------------------------------
807 src_loc :: { SrcLoc }
808 src_loc : {% getSrcLocP }
810 checkVersion :: { () }
811 : {-empty-} {% checkVersion Nothing }
812 | INTEGER {% checkVersion (Just (fromInteger $1)) }
814 -------------------------------------------------------------------
819 happyError buf PState{ loc = loc } = PFailed (ifaceParseErr buf loc)
821 data IfaceStuff = PIface EncodedFS{-.hi module name-} ParsedIface
822 | PIdInfo [HsIdInfo RdrName]
823 | PType RdrNameHsType
824 | PRules [RdrNameRuleDecl]
826 mkConDecl name (ex_tvs, ex_ctxt) details loc = ConDecl name ex_tvs ex_ctxt details loc