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 }
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 IPVARID { ITipvarid $$ } -- GHC extension
151 PRAGMA { ITpragma $$ }
154 STRING { ITstring $$ }
155 INTEGER { ITinteger $$ }
156 RATIONAL { ITrational $$ }
157 CLITLIT { ITlitlit $$ }
159 UNKNOWN { ITunknown $$ }
162 -- iface_stuff is the main production.
163 -- It recognises (a) a whole interface file
164 -- (b) a type (so that type sigs can be parsed lazily)
165 -- (c) the IdInfo part of a signature (same reason)
167 iface_stuff :: { IfaceStuff }
168 iface_stuff : iface { let (nm, iff) = $1 in PIface nm iff }
170 | id_info { PIdInfo $1 }
171 | '__R' rules { PRules $2 }
174 iface :: { (ModuleName, ParsedIface) }
175 iface : '__interface' mod_fs INTEGER orphans checkVersion 'where'
181 { ( $2 -- Module name
183 pi_mod = fromInteger $3, -- Module version
185 pi_exports = $7, -- Exports
186 pi_usages = $8, -- Usages
187 pi_insts = $9, -- Local instances
188 pi_decls = $10, -- Decls
189 pi_rules = $11 -- Rules
192 --------------------------------------------------------------------------
194 import_part :: { [ImportVersion OccName] }
196 | import_part import_decl { $2 : $1 }
198 import_decl :: { ImportVersion OccName }
199 import_decl : 'import' mod_fs INTEGER orphans whats_imported ';'
200 { (mkSysModuleFS $2, fromInteger $3, $4, $5) }
201 -- import Foo 3 :: a 1 b 3 c 7 ; means import a,b,c from Foo
202 -- import Foo 3 ; means import all of Foo
203 -- import Foo 3 ! :: ...stuff... ; the ! means that Foo contains orphans
205 orphans :: { WhetherHasOrphans }
209 whats_imported :: { WhatsImported OccName }
210 whats_imported : { Everything }
211 | '::' name_version_pairs { Specifically $2 }
213 name_version_pairs :: { [LocalVersion OccName] }
214 name_version_pairs : { [] }
215 | name_version_pair name_version_pairs { $1 : $2 }
217 name_version_pair :: { LocalVersion OccName }
218 name_version_pair : var_occ INTEGER { ($1, fromInteger $2) }
219 | tc_occ INTEGER { ($1, fromInteger $2) }
222 --------------------------------------------------------------------------
224 exports_part :: { [ExportItem] }
225 exports_part : { [] }
226 | exports_part '__export'
227 mod_fs entities ';' { (mkSysModuleFS $3, $4) : $1 }
229 entities :: { [RdrAvailInfo] }
231 | entity entities { $1 : $2 }
233 entity :: { RdrAvailInfo }
234 entity : tc_occ { AvailTC $1 [$1] }
235 | var_occ { Avail $1 }
236 | tc_occ stuff_inside { AvailTC $1 ($1:$2) }
237 | tc_occ '|' stuff_inside { AvailTC $1 $3 }
239 stuff_inside :: { [OccName] }
240 stuff_inside : '{' val_occs '}' { $2 }
242 val_occ :: { OccName }
246 val_occs :: { [OccName] }
248 | val_occ val_occs { $1 : $2 }
251 --------------------------------------------------------------------------
253 fixity :: { FixityDirection }
254 fixity : 'infixl' { InfixL }
255 | 'infixr' { InfixR }
259 mb_fix : {-nothing-} { 9 }
260 | INTEGER { (fromInteger $1) }
262 -----------------------------------------------------------------------------
264 csigs :: { [RdrNameSig] }
266 | 'where' '{' csigs1 '}' { $3 }
268 csigs1 :: { [RdrNameSig] }
269 csigs1 : csig { [$1] }
270 | csig ';' csigs1 { $1 : $3 }
272 csig :: { RdrNameSig }
273 csig : src_loc var_name '::' type { mkClassOpSig False $2 $4 $1 }
274 | src_loc var_name '=' '::' type { mkClassOpSig True $2 $5 $1 }
276 --------------------------------------------------------------------------
278 instance_decl_part :: { [RdrNameInstDecl] }
279 instance_decl_part : {- empty -} { [] }
280 | instance_decl_part inst_decl { $2 : $1 }
282 inst_decl :: { RdrNameInstDecl }
283 inst_decl : src_loc 'instance' type '=' var_name ';'
285 EmptyMonoBinds {- No bindings -}
286 [] {- No user pragmas -}
291 --------------------------------------------------------------------------
293 decls_part :: { [(Version, RdrNameHsDecl)] }
296 | decls_part version decl ';' { ($2,$3):$1 }
298 decl :: { RdrNameHsDecl }
299 decl : src_loc var_name '::' type maybe_idinfo
300 { SigD (IfaceSig $2 $4 ($5 $2) $1) }
301 | src_loc 'type' tc_name tv_bndrs '=' type
302 { TyClD (TySynonym $3 $4 $6 $1) }
303 | src_loc 'data' decl_context tc_name tv_bndrs constrs
304 { TyClD (TyData DataType $3 $4 $5 $6 Nothing noDataPragmas $1) }
305 | src_loc 'newtype' decl_context tc_name tv_bndrs newtype_constr
306 { TyClD (TyData NewType $3 $4 $5 $6 Nothing noDataPragmas $1) }
307 | src_loc 'class' decl_context tc_name tv_bndrs fds csigs
308 { TyClD (mkClassDecl $3 $4 $5 $6 $7 EmptyMonoBinds
310 | src_loc fixity mb_fix var_or_data_name
311 { FixD (FixitySig $4 (Fixity $3 $2) $1) }
313 maybe_idinfo :: { RdrName -> [HsIdInfo RdrName] }
314 maybe_idinfo : {- empty -} { \_ -> [] }
315 | src_loc PRAGMA { \x ->
317 PState{bol = 0#, atbol = 1#,
321 POk _ (PIdInfo id_info) -> id_info
323 pprPanic "IdInfo parse failed"
327 -----------------------------------------------------------------------------
329 rules_part :: { [RdrNameRuleDecl] }
330 rules_part : {- empty -} { [] }
331 | src_loc PRAGMA { case parseIface $2
332 PState{bol = 0#, atbol = 1#,
336 POk _ (PRules rules) -> rules
338 pprPanic "Rules parse failed" err
341 rules :: { [RdrNameRuleDecl] }
343 | rule ';' rules { $1:$3 }
345 rule :: { RdrNameRuleDecl }
346 rule : src_loc STRING rule_forall qvar_name
347 core_args '=' core_expr { IfaceRuleDecl $4 (UfRuleBody $2 $3 $5 $7) $1 }
349 rule_forall :: { [UfBinder RdrName] }
350 rule_forall : '__forall' '{' core_bndrs '}' { $3 }
352 -----------------------------------------------------------------------------
354 version :: { Version }
355 version : INTEGER { fromInteger $1 }
357 decl_context :: { RdrNameContext }
358 decl_context : { [] }
359 | '{' context_list1 '}' '=>' { $2 }
361 ----------------------------------------------------------------------------
363 constrs :: { [RdrNameConDecl] {- empty for handwritten abstract -} }
365 | '=' constrs1 { $2 }
367 constrs1 :: { [RdrNameConDecl] }
368 constrs1 : constr { [$1] }
369 | constr '|' constrs1 { $1 : $3 }
371 constr :: { RdrNameConDecl }
372 constr : src_loc ex_stuff data_name batypes { mkConDecl $3 $2 (VanillaCon $4) $1 }
373 | src_loc ex_stuff data_name '{' fields1 '}' { mkConDecl $3 $2 (RecCon $5) $1 }
374 -- We use "data_fs" so as to include ()
376 newtype_constr :: { [RdrNameConDecl] {- Empty if handwritten abstract -} }
377 newtype_constr : { [] }
378 | src_loc '=' ex_stuff data_name atype { [mkConDecl $4 $3 (NewCon $5 Nothing) $1] }
379 | src_loc '=' ex_stuff data_name '{' var_name '::' atype '}'
380 { [mkConDecl $4 $3 (NewCon $8 (Just $6)) $1] }
382 ex_stuff :: { ([HsTyVar RdrName], RdrNameContext) }
383 ex_stuff : { ([],[]) }
384 | '__forall' forall context '=>' { ($2,$3) }
386 batypes :: { [RdrNameBangType] }
388 | batype batypes { $1 : $2 }
390 batype :: { RdrNameBangType }
391 batype : atype { Unbanged $1 }
392 | '!' atype { Banged $2 }
393 | '!' '!' atype { Unpacked $3 }
395 fields1 :: { [([RdrName], RdrNameBangType)] }
396 fields1 : field { [$1] }
397 | field ',' fields1 { $1 : $3 }
399 field :: { ([RdrName], RdrNameBangType) }
400 field : var_names1 '::' type { ($1, Unbanged $3) }
401 | var_names1 '::' '!' type { ($1, Banged $4) }
402 | var_names1 '::' '!' '!' type { ($1, Unpacked $5) }
403 --------------------------------------------------------------------------
405 type :: { RdrNameHsType }
406 type : '__fuall' fuall '=>' type { mkHsUsForAllTy $2 $4 }
407 | '__forall' forall context '=>' type
408 { mkHsForAllTy (Just $2) $3 $5 }
409 | btype '->' type { MonoFunTy $1 $3 }
412 fuall :: { [RdrName] }
413 fuall : '[' uv_bndrs ']' { $2 }
415 forall :: { [HsTyVar RdrName] }
416 forall : '[' tv_bndrs ']' { $2 }
418 context :: { RdrNameContext }
420 | '{' context_list1 '}' { $2 }
422 context_list1 :: { RdrNameContext }
423 context_list1 : class { [$1] }
424 | class ',' context_list1 { $1 : $3 }
426 class :: { HsPred RdrName }
427 class : qcls_name atypes { (HsPClass $1 $2) }
428 | IPVARID '::' type { (HsPIParam (mkSysUnqual ipName $1) $3) }
430 types0 :: { [RdrNameHsType] {- Zero or more -} }
431 types0 : {- empty -} { [ ] }
435 types2 :: { [RdrNameHsType] {- Two or more -} }
436 types2 : type ',' type { [$1,$3] }
437 | type ',' types2 { $1 : $3 }
439 btype :: { RdrNameHsType }
441 | btype atype { MonoTyApp $1 $2 }
442 | '__u' usage atype { MonoUsgTy $2 $3 }
444 usage :: { MonoUsageAnn RdrName }
445 usage : '-' { MonoUsOnce }
447 | uv_name { MonoUsVar $1 }
449 atype :: { RdrNameHsType }
450 atype : qtc_name { MonoTyVar $1 }
451 | tv_name { MonoTyVar $1 }
452 | '(' types2 ')' { MonoTupleTy $2 True{-boxed-} }
453 | '(#' types0 '#)' { MonoTupleTy $2 False{-unboxed-} }
454 | '[' type ']' { MonoListTy $2 }
455 | '{' qcls_name atypes '}' { MonoDictTy $2 $3 }
456 | '{' IPVARID '::' type '}' { MonoIParamTy (mkSysUnqual ipName $2) $4 }
457 | '(' type ')' { $2 }
459 -- This one is dealt with via qtc_name
460 -- | '(' ')' { MonoTupleTy [] True }
462 atypes :: { [RdrNameHsType] {- Zero or more -} }
464 | atype atypes { $1 : $2 }
465 ---------------------------------------------------------------------
466 mod_fs :: { EncodedFS }
469 mod_name :: { ModuleName }
470 : mod_fs { mkSysModuleFS $1 }
473 ---------------------------------------------------
474 var_fs :: { EncodedFS }
477 | 'as' { SLIT("as") }
478 | 'qualified' { SLIT("qualified") }
479 | 'hiding' { SLIT("hiding") }
480 | 'forall' { SLIT("forall") }
481 | 'foreign' { SLIT("foreign") }
482 | 'export' { SLIT("export") }
483 | 'label' { SLIT("label") }
484 | 'dynamic' { SLIT("dynamic") }
485 | 'unsafe' { SLIT("unsafe") }
487 qvar_fs :: { (EncodedFS, EncodedFS) }
491 var_occ :: { OccName }
492 : var_fs { mkSysOccFS varName $1 }
494 var_name :: { RdrName }
495 var_name : var_occ { mkRdrUnqual $1 }
497 qvar_name :: { RdrName }
498 qvar_name : var_name { $1 }
499 | qvar_fs { mkSysQual varName $1 }
501 var_names :: { [RdrName] }
503 | var_name var_names { $1 : $2 }
505 var_names1 :: { [RdrName] }
506 var_names1 : var_name var_names { $1 : $2 }
508 ---------------------------------------------------
509 -- For some bizarre reason,
510 -- (,,,) is dealt with by the parser
511 -- Foo.(,,,) is dealt with by the lexer
514 data_fs :: { EncodedFS }
518 qdata_fs :: { (EncodedFS, EncodedFS) }
522 data_occ :: { OccName }
523 : data_fs { mkSysOccFS dataName $1 }
525 data_name :: { RdrName }
526 : data_occ { mkRdrUnqual $1 }
528 qdata_name :: { RdrName }
529 qdata_name : data_name { $1 }
530 | qdata_fs { mkSysQual dataName $1 }
532 qdata_names :: { [RdrName] }
534 | qdata_name qdata_names { $1 : $2 }
536 var_or_data_name :: { RdrName }
540 ---------------------------------------------------
541 tc_fs :: { EncodedFS }
544 tc_occ :: { OccName }
545 : tc_fs { mkSysOccFS tcName $1 }
547 tc_name :: { RdrName }
548 : tc_occ { mkRdrUnqual $1 }
550 qtc_name :: { RdrName }
552 | qdata_fs { mkSysQual tcName $1 }
554 ---------------------------------------------------
555 cls_name :: { RdrName }
556 : data_fs { mkSysUnqual clsName $1 }
558 qcls_name :: { RdrName }
560 | qdata_fs { mkSysQual clsName $1 }
562 ---------------------------------------------------
563 uv_name :: { RdrName }
564 : VARID { mkSysUnqual uvName $1 }
566 uv_bndr :: { RdrName }
569 uv_bndrs :: { [RdrName] }
571 | uv_bndr uv_bndrs { $1 : $2 }
573 ---------------------------------------------------
574 tv_name :: { RdrName }
575 : VARID { mkSysUnqual tvName $1 }
576 | VARSYM { mkSysUnqual tvName $1 {- Allow t2 as a tyvar -} }
578 tv_bndr :: { HsTyVar RdrName }
579 : tv_name '::' akind { IfaceTyVar $1 $3 }
580 | tv_name { IfaceTyVar $1 boxedTypeKind }
582 tv_bndrs :: { [HsTyVar RdrName] }
584 | tv_bndr tv_bndrs { $1 : $2 }
586 ---------------------------------------------------
587 fds :: { [([RdrName], [RdrName])] }
589 | '|' fds1 { reverse $2 }
591 fds1 :: { [([RdrName], [RdrName])] }
592 : fds1 ',' fd { $3 : $1 }
595 fd :: { ([RdrName], [RdrName]) }
596 : varids0 '->' varids0 { (reverse $1, reverse $3) }
598 varids0 :: { [RdrName] }
600 | varids0 tv_name { $2 : $1 }
602 ---------------------------------------------------
605 | akind '->' kind { mkArrowKind $1 $3 }
608 : VARSYM { if $1 == SLIT("*") then
610 else if $1 == SLIT("?") then
612 else panic "ParseInterface: akind"
614 | '(' kind ')' { $2 }
616 --------------------------------------------------------------------------
618 id_info :: { [HsIdInfo RdrName] }
620 | id_info_item id_info { $1 : $2 }
622 id_info_item :: { HsIdInfo RdrName }
623 : '__A' INTEGER { HsArity (exactArity (fromInteger $2)) }
624 | '__U' inline_prag core_expr { HsUnfold $2 $3 }
625 | '__M' { HsCprInfo $1 }
626 | '__S' { HsStrictness (HsStrictnessInfo $1) }
627 | '__C' { HsNoCafRefs }
628 | '__P' qvar_name { HsWorker $2 }
630 inline_prag :: { InlinePragInfo }
631 : {- empty -} { NoInlinePragInfo }
632 | '[' INTEGER ']' { IMustNotBeINLINEd True (Just (fromInteger $2)) } -- INLINE n
633 | '[' '!' INTEGER ']' { IMustNotBeINLINEd False (Just (fromInteger $3)) } -- NOINLINE n
635 -------------------------------------------------------
636 core_expr :: { UfExpr RdrName }
637 core_expr : '\\' core_bndrs '->' core_expr { foldr UfLam $4 $2 }
638 | 'case' core_expr 'of' var_name
639 '{' core_alts '}' { UfCase $2 $4 $6 }
641 | 'let' '{' core_val_bndr '=' core_expr
642 '}' 'in' core_expr { UfLet (UfNonRec $3 $5) $8 }
643 | '__letrec' '{' rec_binds '}'
644 'in' core_expr { UfLet (UfRec $3) $6 }
646 | con_or_primop '{' core_args '}' { UfCon $1 $3 }
647 | '__litlit' STRING atype { UfCon (UfLitLitCon $2 $3) [] }
649 | '__inline_me' core_expr { UfNote UfInlineMe $2 }
650 | '__inline_call' core_expr { UfNote UfInlineCall $2 }
651 | '__coerce' atype core_expr { UfNote (UfCoerce $2) $3 }
652 | scc core_expr { UfNote (UfSCC $1) $2 }
655 fexpr :: { UfExpr RdrName }
656 fexpr : fexpr core_arg { UfApp $1 $2 }
659 core_arg :: { UfExpr RdrName }
660 : '@' atype { UfType $2 }
663 core_args :: { [UfExpr RdrName] }
665 | core_arg core_args { $1 : $2 }
667 core_aexpr :: { UfExpr RdrName } -- Atomic expressions
668 core_aexpr : qvar_name { UfVar $1 }
670 | qdata_name { UfVar $1 }
671 -- This one means that e.g. "True" will parse as
672 -- (UfVar True_Id) rather than (UfCon True_Con []).
673 -- No big deal; it'll be inlined in a jiffy. I tried
674 -- parsing it to (Con con []) directly, but got bitten
675 -- when a real constructor Id showed up in an interface
676 -- file. As usual, a hack bites you in the end.
677 -- If you want to get a UfCon, then use the
678 -- curly-bracket notation (True {}).
680 | core_lit { UfCon (UfLitCon $1) [] }
681 | '(' core_expr ')' { $2 }
682 | '(' comma_exprs2 ')' { UfTuple (mkTupConRdrName (length $2)) $2 }
683 | '(#' comma_exprs0 '#)' { UfTuple (mkUbxTupConRdrName (length $2)) $2 }
685 -- This one is dealt with by qdata_name: see above comments
686 -- | '(' ')' { UfTuple (mkTupConRdrName 0) [] }
688 comma_exprs0 :: { [UfExpr RdrName] } -- Zero or more
689 comma_exprs0 : {- empty -} { [ ] }
690 | core_expr { [ $1 ] }
691 | comma_exprs2 { $1 }
693 comma_exprs2 :: { [UfExpr RdrName] } -- Two or more
694 comma_exprs2 : core_expr ',' core_expr { [$1,$3] }
695 | core_expr ',' comma_exprs2 { $1 : $3 }
697 con_or_primop :: { UfCon RdrName }
698 con_or_primop : qdata_name { UfDataCon $1 }
699 | qvar_name { UfPrimOp $1 }
700 | '__ccall' ccall_string { let
701 (is_dyn, is_casm, may_gc) = $1
703 UfCCallOp $2 is_dyn is_casm may_gc
706 rec_binds :: { [(UfBinder RdrName, UfExpr RdrName)] }
708 | core_val_bndr '=' core_expr ';' rec_binds { ($1,$3) : $5 }
710 core_alts :: { [UfAlt RdrName] }
712 | core_alt ';' core_alts { $1 : $3 }
714 core_alt :: { UfAlt RdrName }
715 core_alt : core_pat '->' core_expr { (fst $1, snd $1, $3) }
717 core_pat :: { (UfCon RdrName, [RdrName]) }
718 core_pat : core_lit { (UfLitCon $1, []) }
719 | '__litlit' STRING atype { (UfLitLitCon $2 $3, []) }
720 | qdata_name core_pat_names { (UfDataCon $1, $2) }
721 | '(' comma_var_names1 ')' { (UfDataCon (mkTupConRdrName (length $2)), $2) }
722 | '(#' comma_var_names1 '#)' { (UfDataCon (mkUbxTupConRdrName (length $2)), $2) }
723 | '__DEFAULT' { (UfDefault, []) }
724 | '(' core_pat ')' { $2 }
726 core_pat_names :: { [RdrName] }
727 core_pat_names : { [] }
728 | core_pat_name core_pat_names { $1 : $2 }
730 -- Tyvar names and variable names live in different name spaces
731 -- so they need to be signalled separately. But we don't record
732 -- types or kinds in a pattern; we work that out from the type
733 -- of the case scrutinee
734 core_pat_name :: { RdrName }
735 core_pat_name : var_name { $1 }
738 comma_var_names1 :: { [RdrName] } -- One or more
739 comma_var_names1 : var_name { [$1] }
740 | var_name ',' comma_var_names1 { $1 : $3 }
742 core_lit :: { Literal }
743 core_lit : integer { mkMachInt_safe $1 }
744 | CHAR { MachChar $1 }
745 | STRING { MachStr $1 }
746 | '__string' STRING { NoRepStr $2 (panic "NoRepStr type") }
747 | rational { MachDouble $1 }
748 | '__float' rational { MachFloat $2 }
750 | '__integer' integer { NoRepInteger $2 (panic "NoRepInteger type")
751 -- The type checker will add the types
754 | '__rational' integer integer { NoRepRational ($2 % $3)
755 (panic "NoRepRational type")
756 -- The type checker will add the type
759 | '__addr' integer { MachAddr $2 }
761 integer :: { Integer }
763 | '-' INTEGER { (-$2) }
765 rational :: { Rational }
767 | '-' RATIONAL { (-$2) }
769 core_bndr :: { UfBinder RdrName }
770 core_bndr : core_val_bndr { $1 }
771 | core_tv_bndr { $1 }
773 core_bndrs :: { [UfBinder RdrName] }
775 | core_bndr core_bndrs { $1 : $2 }
777 core_val_bndr :: { UfBinder RdrName }
778 core_val_bndr : var_name '::' atype { UfValBinder $1 $3 }
780 core_tv_bndr :: { UfBinder RdrName }
781 core_tv_bndr : '@' tv_name '::' akind { UfTyBinder $2 $4 }
782 | '@' tv_name { UfTyBinder $2 boxedTypeKind }
784 ccall_string :: { FAST_STRING }
790 ------------------------------------------------------------------------
791 scc :: { CostCentre }
792 : '__sccC' '{' mod_name STRING '}' { AllCafsCC $3 $4 }
793 | '__scc' '{' cc_name mod_name STRING cc_dup cc_caf '}'
794 { NormalCC { cc_name = $3, cc_mod = $4, cc_grp = $5,
795 cc_is_dupd = $6, cc_is_caf = $7 } }
797 cc_name :: { EncodedFS }
801 cc_dup :: { IsDupdCC }
802 cc_dup : { OriginalCC }
805 cc_caf :: { IsCafCC }
809 -------------------------------------------------------------------
811 src_loc :: { SrcLoc }
812 src_loc : {% getSrcLocP }
814 checkVersion :: { () }
815 : {-empty-} {% checkVersion Nothing }
816 | INTEGER {% checkVersion (Just (fromInteger $1)) }
818 -------------------------------------------------------------------
823 happyError buf PState{ loc = loc } = PFailed (ifaceParseErr buf loc)
825 data IfaceStuff = PIface EncodedFS{-.hi module name-} ParsedIface
826 | PIdInfo [HsIdInfo RdrName]
827 | PType RdrNameHsType
828 | PRules [RdrNameRuleDecl]
830 mkConDecl name (ex_tvs, ex_ctxt) details loc = ConDecl name ex_tvs ex_ctxt details loc