1 {- Notes about the syntax of interface files -*-haskell-*-
2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 interface "edison" M 4 6 2 ! 406 Module M, version 4, from package 'edison',
6 Fixities version 6, rules version 2
7 Interface syntax version 406
8 ! means M contains orphans
12 import Foo ; To compile M I used nothing from Foo, but it's
13 below me in the hierarchy
15 import Foo ! @ ; Ditto, but the ! means that Foo contains orphans
16 and the @ means that Foo is a boot interface
18 import Foo :: 3 ; To compile M I used everything from Foo, which has
21 import Foo :: 3 2 6 a 1 b 3 c 7 ; To compile M I used Foo. It had
25 and some specific things besides.
31 module ParseIface ( parseIface, parseType, parseRules, parseIdInfo ) where
33 #include "HsVersions.h"
35 import HsSyn -- quite a bit of stuff
36 import RdrHsSyn -- oodles of synonyms
37 import HsTypes ( mkHsForAllTy, mkHsTupCon )
39 import Literal ( Literal(..), mkMachInt, mkMachInt64, mkMachWord, mkMachWord64 )
40 import BasicTypes ( Fixity(..), FixityDirection(..), StrictnessMark(..),
41 NewOrData(..), Version, initialVersion, Boxity(..),
42 Activation(..), IPName(..)
44 import CostCentre ( CostCentre(..), IsCafCC(..), IsDupdCC(..) )
45 import Type ( Kind, mkArrowKind, liftedTypeKind, openTypeKind, usageTypeKind )
46 import ForeignCall ( ForeignCall(..), CCallConv(..), CCallSpec(..), CCallTarget(..) )
49 import RnMonad ( ParsedIface(..), IfaceDeprecs )
50 import HscTypes ( WhetherHasOrphans, IsBootInterface, GenAvailInfo(..),
51 ImportVersion, WhatsImported(..),
52 RdrAvailInfo, RdrExportItem )
54 import RdrName ( RdrName, mkRdrUnqual, mkIfaceOrig )
55 import TyCon ( DataConDetails(..) )
56 import Name ( OccName )
57 import OccName ( mkSysOccFS,
58 tcName, varName, dataName, clsName, tvName,
61 import Module ( ModuleName, PackageName, mkSysModuleNameFS )
62 import SrcLoc ( SrcLoc )
63 import CmdLineOpts ( opt_InPackage, opt_IgnoreIfacePragmas )
65 import Class ( DefMeth (..) )
68 import FastString ( tailFS )
71 %name parseIface iface
73 %name parseIdInfo id_info
74 %name parseRules rules_and_deprecs
77 %monad { P }{ thenP }{ returnP }
78 %lexer { lexer } { ITeof }
82 'case' { ITcase } -- Haskell keywords
91 'instance' { ITinstance }
93 'newtype' { ITnewtype }
95 'qualified' { ITqualified }
99 'forall' { ITforall } -- GHC extension keywords
100 'foreign' { ITforeign }
101 'export' { ITexport }
103 'dynamic' { ITdynamic }
104 'unsafe' { ITunsafe }
106 'stdcall' { ITstdcallconv }
107 'ccall' { ITccallconv }
109 '__interface' { ITinterface } -- interface keywords
110 '__export' { IT__export }
111 '__forall' { IT__forall }
112 '__letrec' { ITletrec }
113 '__coerce' { ITcoerce }
114 '__inline_me' { ITinlineMe }
115 '__inline_call'{ ITinlineCall }
116 '__DEFAULT' { ITdefaultbranch }
117 '__float' { ITfloat_lit }
118 '__word' { ITword_lit }
119 '__int64' { ITint64_lit }
120 '__word64' { ITword64_lit }
121 '__addr' { ITaddr_lit }
122 '__label' { ITlabel_lit }
123 '__litlit' { ITlit_lit }
124 '__ccall' { ITccall $$ }
126 '__sccC' { ITsccAllCafs }
131 '__P' { ITspecialise }
134 '__S' { ITstrict $$ }
136 '__D' { ITdeprecated }
150 '{' { ITocurly } -- special symbols
164 VARID { ITvarid $$ } -- identifiers
166 VARSYM { ITvarsym $$ }
167 QVARID { ITqvarid $$ }
168 QCONID { ITqconid $$ }
170 IPDUPVARID { ITdupipvarid $$ } -- GHC extension
171 IPSPLITVARID { ITsplitipvarid $$ } -- GHC extension
173 PRAGMA { ITpragma $$ }
176 STRING { ITstring $$ }
177 INTEGER { ITinteger $$ }
178 RATIONAL { ITrational $$ }
179 CLITLIT { ITlitlit $$ }
182 iface :: { ParsedIface }
183 iface : '__interface' package mod_name
185 orphans checkVersion 'where'
191 rules_and_deprecs_part
192 { let (rules,deprecs) = $14 () in
194 pi_mod = $3, -- Module name
195 pi_pkg = $2, -- Package name
196 pi_vers = $4, -- Module version
198 pi_exports = (fst $5, $9), -- Exports
199 pi_usages = $10, -- Usages
200 pi_fixity = $11, -- Fixies
201 pi_insts = $12, -- Local instances
202 pi_decls = $13, -- Decls
203 pi_rules = (snd $5,rules), -- Rules
204 pi_deprecs = deprecs -- Deprecations
207 -- Versions for exports and rules (optional)
208 sub_versions :: { (Version,Version) }
209 : '[' version version ']' { ($2,$3) }
210 | {- empty -} { (initialVersion, initialVersion) }
212 --------------------------------------------------------------------------
214 import_part :: { [ImportVersion OccName] }
216 | import_decl import_part { $1 : $2 }
218 import_decl :: { ImportVersion OccName }
219 import_decl : 'import' mod_name orphans is_boot whats_imported ';'
220 { ({-mkSysModuleNameFS-} $2, $3, $4, $5) }
222 orphans :: { WhetherHasOrphans }
226 is_boot :: { IsBootInterface }
230 whats_imported :: { WhatsImported OccName }
231 whats_imported : { NothingAtAll }
232 | '::' version { Everything $2 }
233 | '::' version version version name_version_pairs { Specifically $2 (Just $3) $5 $4 }
234 | '::' version version name_version_pairs { Specifically $2 Nothing $4 $3 }
236 name_version_pairs :: { [(OccName, Version)] }
237 name_version_pairs : { [] }
238 | name_version_pair name_version_pairs { $1 : $2 }
240 name_version_pair :: { (OccName, Version) }
241 name_version_pair : var_occ version { ($1, $2) }
242 | tc_occ version { ($1, $2) }
245 --------------------------------------------------------------------------
247 exports_part :: { [RdrExportItem] }
248 exports_part : { [] }
249 | '__export' mod_name entities ';'
250 exports_part { ({-mkSysModuleNameFS-} $2, $3) : $5 }
252 entities :: { [RdrAvailInfo] }
254 | entity entities { $1 : $2 }
256 entity :: { RdrAvailInfo }
257 entity : var_occ { Avail $1 }
258 | tc_occ { AvailTC $1 [$1] }
259 | tc_occ '|' stuff_inside { AvailTC $1 $3 }
260 | tc_occ stuff_inside { AvailTC $1 ($1:$2) }
261 -- Note that the "main name" comes at the beginning
263 stuff_inside :: { [OccName] }
264 stuff_inside : '{' val_occs '}' { $2 }
266 val_occ :: { OccName }
270 val_occs :: { [OccName] }
272 | val_occ val_occs { $1 : $2 }
275 --------------------------------------------------------------------------
277 fix_decl_part :: { [(RdrName,Fixity)] }
278 fix_decl_part : {- empty -} { [] }
279 | fix_decls ';' { $1 }
281 fix_decls :: { [(RdrName,Fixity)] }
283 | fix_decl fix_decls { $1 : $2 }
285 fix_decl :: { (RdrName,Fixity) }
286 fix_decl : fixity prec var_or_data_name { ($3, Fixity $2 $1) }
288 fixity :: { FixityDirection }
289 fixity : 'infixl' { InfixL }
290 | 'infixr' { InfixR }
294 prec : INTEGER { fromInteger $1 }
296 -----------------------------------------------------------------------------
298 csigs :: { [RdrNameSig] }
300 | 'where' '{' csigs1 '}' { $3 }
302 csigs1 :: { [RdrNameSig] }
304 | csig ';' csigs1 { $1 : $3 }
306 csig :: { RdrNameSig }
307 csig : src_loc qvar_name '::' type { ClassOpSig $2 NoDefMeth $4 $1 }
308 | src_loc qvar_name ';' '::' type { ClassOpSig $2 GenDefMeth $5 $1 }
309 | src_loc qvar_name '=' '::' type { mkClassOpSigDM $2 $5 $1 }
311 --------------------------------------------------------------------------
313 instance_decl_part :: { [RdrNameInstDecl] }
314 instance_decl_part : {- empty -} { [] }
315 | instance_decl_part inst_decl { $2 : $1 }
317 inst_decl :: { RdrNameInstDecl }
318 inst_decl : src_loc 'instance' type '=' qvar_name ';'
320 EmptyMonoBinds {- No bindings -}
321 [] {- No user pragmas -}
322 (Just $5) {- Dfun id -}
326 --------------------------------------------------------------------------
328 decls_part :: { [(Version, RdrNameTyClDecl)] }
331 | opt_version decl ';' decls_part { ($1,$2):$4 }
333 decl :: { RdrNameTyClDecl }
334 decl : src_loc qvar_name '::' type maybe_idinfo
335 { IfaceSig $2 $4 ($5 $2) $1 }
336 | src_loc 'type' qtc_name tv_bndrs '=' type
337 { TySynonym $3 $4 $6 $1 }
338 | src_loc 'foreign' 'type' qtc_name
339 { ForeignType $4 Nothing DNType $1 }
340 | src_loc 'data' tycl_hdr constrs
341 { mkTyData DataType $3 $4 Nothing $1 }
342 | src_loc 'newtype' tycl_hdr newtype_constr
343 { mkTyData NewType $3 (DataCons [$4]) Nothing $1 }
344 | src_loc 'class' tycl_hdr fds csigs
345 { mkClassDecl $3 $4 $5 Nothing $1 }
347 tycl_hdr :: { (RdrNameContext, RdrName, [RdrNameHsTyVar]) }
348 : context '=>' qtc_name tv_bndrs { ($1, $3, $4) }
349 | qtc_name tv_bndrs { ([], $1, $2) }
351 maybe_idinfo :: { RdrName -> [HsIdInfo RdrName] }
352 maybe_idinfo : {- empty -} { \_ -> [] }
353 | pragma { \x -> if opt_IgnoreIfacePragmas then []
355 Just (POk _ id_info) -> id_info
356 Just (PFailed err) -> pprPanic "IdInfo parse failed"
360 If a signature decl is being loaded, and opt_IgnoreIfacePragmas is on,
361 we toss away unfolding information.
363 Also, if the signature is loaded from a module we're importing from source,
364 we do the same. This is to avoid situations when compiling a pair of mutually
365 recursive modules, peering at unfolding info in the interface file of the other,
366 e.g., you compile A, it looks at B's interface file and may as a result change
367 its interface file. Hence, B is recompiled, maybe changing its interface file,
368 which will the unfolding info used in A to become invalid. Simple way out is to
369 just ignore unfolding info.
371 [Jan 99: I junked the second test above. If we're importing from an hi-boot
372 file there isn't going to *be* any pragma info. The above comment
373 dates from a time where we picked up a .hi file first if it existed.]
376 pragma :: { Maybe (ParseResult [HsIdInfo RdrName]) }
377 pragma : src_loc PRAGMA { let exts = ExtFlags {glasgowExtsEF = True,
380 Just (parseIdInfo $2 (mkPState $1 exts))
383 -----------------------------------------------------------------------------
385 -- This production is lifted so that it doesn't get eagerly parsed when we
386 -- use happy --strict.
387 rules_and_deprecs_part :: { () -> ([RdrNameRuleDecl], IfaceDeprecs) }
388 rules_and_deprecs_part
389 : {- empty -} { \_ -> ([], Nothing) }
390 | src_loc PRAGMA { \_ -> let exts = ExtFlags {glasgowExtsEF = True,
392 in case parseRules $2 (mkPState $1 exts) of
394 PFailed err -> pprPanic "Rules/Deprecations parse failed" err
397 rules_and_deprecs :: { ([RdrNameRuleDecl], IfaceDeprecs) }
398 rules_and_deprecs : rule_prag deprec_prag { ($1, $2) }
401 -----------------------------------------------------------------------------
403 rule_prag :: { [RdrNameRuleDecl] }
404 rule_prag : {- empty -} { [] }
407 rules :: { [RdrNameRuleDecl] }
409 | rule ';' rules { $1:$3 }
411 rule :: { RdrNameRuleDecl }
412 rule : src_loc STRING activation rule_forall qvar_name
413 core_args '=' core_expr { IfaceRule $2 $3 $4 $5 $6 $8 $1 }
415 activation :: { Activation }
416 activation : {- empty -} { AlwaysActive }
417 | '[' INTEGER ']' { ActiveAfter (fromInteger $2) }
418 | '[' '~' INTEGER ']' { ActiveBefore (fromInteger $3) }
420 rule_forall :: { [UfBinder RdrName] }
421 rule_forall : '__forall' '{' core_bndrs '}' { $3 }
423 -----------------------------------------------------------------------------
425 deprec_prag :: { IfaceDeprecs }
426 deprec_prag : {- empty -} { Nothing }
427 | '__D' deprecs { Just $2 }
429 deprecs :: { Either DeprecTxt [(RdrName,DeprecTxt)] }
430 deprecs : STRING { Left $1 }
431 | deprec_list { Right $1 }
433 deprec_list :: { [(RdrName,DeprecTxt)] }
434 deprec_list : deprec { [$1] }
435 | deprec ';' deprec_list { $1 : $3 }
437 deprec :: { (RdrName,DeprecTxt) }
438 deprec : deprec_name STRING { ($1, $2) }
440 deprec_name :: { RdrName }
444 -----------------------------------------------------------------------------
446 version :: { Version }
447 version : INTEGER { fromInteger $1 }
449 opt_version :: { Version }
450 opt_version : version { $1 }
451 | {- empty -} { initialVersion }
454 ----------------------------------------------------------------------------
456 constrs :: { DataConDetails RdrNameConDecl }
458 | '=' { DataCons [] }
459 | '=' constrs1 { DataCons $2 }
461 constrs1 :: { [RdrNameConDecl] }
462 constrs1 : constr { [$1] }
463 | constr '|' constrs1 { $1 : $3 }
465 constr :: { RdrNameConDecl }
466 constr : src_loc ex_stuff qdata_name batypes { mk_con_decl $3 $2 (VanillaCon $4) $1 }
467 | src_loc ex_stuff qdata_name '{' fields1 '}' { mk_con_decl $3 $2 (RecCon $5) $1 }
468 -- We use "data_fs" so as to include ()
470 newtype_constr :: { RdrNameConDecl }
471 newtype_constr : src_loc '=' ex_stuff qdata_name atype { mk_con_decl $4 $3 (VanillaCon [unbangedType $5]) $1 }
472 | src_loc '=' ex_stuff qdata_name '{' qvar_name '::' atype '}'
473 { mk_con_decl $4 $3 (RecCon [([$6], unbangedType $8)]) $1 }
475 ex_stuff :: { ([HsTyVarBndr RdrName], RdrNameContext) }
476 ex_stuff : { ([],[]) }
477 | '__forall' tv_bndrs opt_context '=>' { ($2,$3) }
479 batypes :: { [RdrNameBangType] }
481 | batype batypes { $1 : $2 }
483 batype :: { RdrNameBangType }
484 batype : tatype { unbangedType $1 }
485 | '!' tatype { BangType MarkedStrict $2 }
486 | '!' '!' tatype { BangType MarkedUnboxed $3 }
488 fields1 :: { [([RdrName], RdrNameBangType)] }
489 fields1 : field { [$1] }
490 | field ',' fields1 { $1 : $3 }
492 field :: { ([RdrName], RdrNameBangType) }
493 field : qvar_names1 '::' ttype { ($1, unbangedType $3) }
494 | qvar_names1 '::' '!' ttype { ($1, BangType MarkedStrict $4) }
495 | qvar_names1 '::' '!' '!' ttype { ($1, BangType MarkedUnboxed $5) }
497 --------------------------------------------------------------------------
499 type :: { RdrNameHsType }
500 type : '__forall' tv_bndrs
501 opt_context '=>' type { mkHsForAllTy (Just $2) $3 $5 }
502 | btype '->' type { HsFunTy $1 $3 }
505 opt_context :: { RdrNameContext }
509 context :: { RdrNameContext }
510 context : '(' context_list1 ')' { $2 }
511 | '{' context_list1 '}' { $2 } -- Backward compatibility
513 context_list1 :: { RdrNameContext }
514 context_list1 : class { [$1] }
515 | class ',' context_list1 { $1 : $3 }
517 class :: { HsPred RdrName }
518 class : qcls_name atypes { (HsClassP $1 $2) }
519 | ipvar_name '::' type { (HsIParam $1 $3) }
521 types0 :: { [RdrNameHsType] {- Zero or more -} }
522 types0 : {- empty -} { [ ] }
526 types2 :: { [RdrNameHsType] {- Two or more -} }
527 types2 : type ',' type { [$1,$3] }
528 | type ',' types2 { $1 : $3 }
530 btype :: { RdrNameHsType }
532 | btype atype { HsAppTy $1 $2 }
534 atype :: { RdrNameHsType }
535 atype : qtc_name { HsTyVar $1 }
536 | tv_name { HsTyVar $1 }
539 | '(' ')' { HsTupleTy (mkHsTupCon tcName Boxed []) [] }
540 | '(' types2 ')' { HsTupleTy (mkHsTupCon tcName Boxed $2) $2 }
541 | '(#' types0 '#)' { HsTupleTy (mkHsTupCon tcName Unboxed $2) $2 }
542 | '[' type ']' { HsListTy $2 }
543 | '[:' type ':]' { HsPArrTy $2 }
544 | '{' qcls_name atypes '}' { mkHsDictTy $2 $3 }
545 | '{' ipvar_name '::' type '}' { mkHsIParamTy $2 $4 }
546 | '(' type ')' { $2 }
548 atypes :: { [RdrNameHsType] {- Zero or more -} }
550 | atype atypes { $1 : $2 }
551 --------------------------------------------------------------------------
553 -- versions of type/btype/atype that cant begin with '!' (or '.')
554 -- for use where the kind is definitely known NOT to be '$'
556 ttype :: { RdrNameHsType }
557 ttype : '__forall' tv_bndrs
558 opt_context '=>' type { mkHsForAllTy (Just $2) $3 $5 }
559 | tbtype '->' type { HsFunTy $1 $3 }
562 tbtype :: { RdrNameHsType }
563 tbtype : tatype { $1 }
564 | tbtype atype { HsAppTy $1 $2 }
566 tatype :: { RdrNameHsType }
567 tatype : qtc_name { HsTyVar $1 }
568 | tv_name { HsTyVar $1 }
569 | '(' ')' { HsTupleTy (mkHsTupCon tcName Boxed []) [] }
570 | '(' types2 ')' { HsTupleTy (mkHsTupCon tcName Boxed $2) $2 }
571 | '(#' types0 '#)' { HsTupleTy (mkHsTupCon tcName Unboxed $2) $2 }
572 | '[' type ']' { HsListTy $2 }
573 | '[:' type ':]' { HsPArrTy $2 }
574 | '{' qcls_name atypes '}' { mkHsDictTy $2 $3 }
575 | '{' ipvar_name '::' type '}' { mkHsIParamTy $2 $4 }
576 | '(' type ')' { $2 }
577 ---------------------------------------------------------------------
579 package :: { PackageName }
581 | {- empty -} { opt_InPackage }
582 -- Useful for .hi-boot files,
583 -- which can omit the package Id
584 -- Module loops are always within a package
586 mod_name :: { ModuleName }
587 : CONID { mkSysModuleNameFS $1 }
590 ---------------------------------------------------
591 var_fs :: { EncodedFS }
593 | 'as' { FSLIT("as") }
594 | 'qualified' { FSLIT("qualified") }
595 | 'hiding' { FSLIT("hiding") }
596 | 'forall' { FSLIT("forall") }
597 | 'foreign' { FSLIT("foreign") }
598 | 'export' { FSLIT("export") }
599 | 'label' { FSLIT("label") }
600 | 'dynamic' { FSLIT("dynamic") }
601 | 'unsafe' { FSLIT("unsafe") }
602 | 'with' { FSLIT("with") }
603 | 'ccall' { FSLIT("ccall") }
604 | 'stdcall' { FSLIT("stdcall") }
606 var_occ :: { OccName }
607 : var_fs { mkSysOccFS varName $1 }
609 var_name :: { RdrName }
610 var_name : var_occ { mkRdrUnqual $1 }
612 qvar_name :: { RdrName }
613 qvar_name : var_name { $1 }
614 | QVARID { mkIfaceOrig varName $1 }
616 ipvar_name :: { IPName RdrName }
617 : IPDUPVARID { Dupable (mkRdrUnqual (mkSysOccFS varName $1)) }
618 | IPSPLITVARID { Linear (mkRdrUnqual (mkSysOccFS varName $1)) }
620 qvar_names1 :: { [RdrName] }
621 qvar_names1 : qvar_name { [$1] }
622 | qvar_name qvar_names1 { $1 : $2 }
624 ---------------------------------------------------
626 data_occ :: { OccName }
627 : CONID { mkSysOccFS dataName $1 }
629 qdata_name :: { RdrName }
630 : data_occ { mkRdrUnqual $1 }
631 | QCONID { mkIfaceOrig dataName $1 }
633 var_or_data_name :: { RdrName }
637 ---------------------------------------------------
638 tc_occ :: { OccName }
639 : CONID { mkSysOccFS tcName $1 }
641 qtc_name :: { RdrName }
642 : tc_occ { mkRdrUnqual $1 }
643 | QCONID { mkIfaceOrig tcName $1 }
645 ---------------------------------------------------
646 qcls_name :: { RdrName }
647 : CONID { mkRdrUnqual (mkSysOccFS clsName $1) }
648 | QCONID { mkIfaceOrig clsName $1 }
650 ---------------------------------------------------
651 tv_name :: { RdrName }
652 : var_fs { mkRdrUnqual (mkSysOccFS tvName $1) }
654 tv_bndr :: { HsTyVarBndr RdrName }
655 : tv_name '::' akind { IfaceTyVar $1 $3 }
656 | tv_name { IfaceTyVar $1 liftedTypeKind }
658 tv_bndrs :: { [HsTyVarBndr RdrName] }
660 | '[' tv_bndrs1 ']' { $2 } -- Backward compatibility
662 tv_bndrs1 :: { [HsTyVarBndr RdrName] }
664 | tv_bndr tv_bndrs1 { $1 : $2 }
666 ---------------------------------------------------
667 fds :: { [([RdrName], [RdrName])] }
669 | '|' fds1 { reverse $2 }
671 fds1 :: { [([RdrName], [RdrName])] }
672 : fds1 ',' fd { $3 : $1 }
675 fd :: { ([RdrName], [RdrName]) }
676 : varids0 '->' varids0 { (reverse $1, reverse $3) }
678 varids0 :: { [RdrName] }
680 | varids0 tv_name { $2 : $1 }
682 ---------------------------------------------------
685 | akind '->' kind { mkArrowKind $1 $3 }
688 : '*' { liftedTypeKind }
689 | VARSYM { if $1 == FSLIT("?") then
691 else if $1 == FSLIT("\36") then
692 usageTypeKind -- dollar
693 else panic "ParseInterface: akind"
695 | '(' kind ')' { $2 }
697 --------------------------------------------------------------------------
699 id_info :: { [HsIdInfo RdrName] }
700 : id_info_item { [$1] }
701 | id_info_item id_info { $1 : $2 }
703 id_info_item :: { HsIdInfo RdrName }
704 : '__A' INTEGER { HsArity (fromInteger $2) }
705 | '__U' activation core_expr { HsUnfold $2 $3 }
706 | '__S' { HsStrictness $1 }
707 | '__C' { HsNoCafRefs }
708 | '__P' qvar_name INTEGER { HsWorker $2 (fromInteger $3) }
710 -------------------------------------------------------
711 core_expr :: { UfExpr RdrName }
712 core_expr : '\\' core_bndrs '->' core_expr { foldr UfLam $4 $2 }
713 | 'case' core_expr 'of' var_name
714 '{' core_alts '}' { UfCase $2 $4 $6 }
716 | 'let' '{' core_val_bndr '=' core_expr
717 '}' 'in' core_expr { UfLet (UfNonRec $3 $5) $8 }
718 | '__letrec' '{' rec_binds '}'
719 'in' core_expr { UfLet (UfRec $3) $6 }
721 | '__litlit' STRING atype { UfLitLit $2 $3 }
725 fexpr :: { UfExpr RdrName }
726 fexpr : fexpr core_arg { UfApp $1 $2 }
727 | scc core_aexpr { UfNote (UfSCC $1) $2 }
728 | '__inline_me' core_aexpr { UfNote UfInlineMe $2 }
729 | '__inline_call' core_aexpr { UfNote UfInlineCall $2 }
730 | '__coerce' atype core_aexpr { UfNote (UfCoerce $2) $3 }
733 core_arg :: { UfExpr RdrName }
734 : '@' atype { UfType $2 }
737 core_args :: { [UfExpr RdrName] }
739 | core_arg core_args { $1 : $2 }
741 core_aexpr :: { UfExpr RdrName } -- Atomic expressions
742 core_aexpr : qvar_name { UfVar $1 }
743 | qdata_name { UfVar $1 }
745 | core_lit { UfLit $1 }
746 | '(' core_expr ')' { $2 }
748 | '(' ')' { UfTuple (mkHsTupCon dataName Boxed []) [] }
749 | '(' comma_exprs2 ')' { UfTuple (mkHsTupCon dataName Boxed $2) $2 }
750 | '(#' comma_exprs0 '#)' { UfTuple (mkHsTupCon dataName Unboxed $2) $2 }
752 | '{' '__ccall' ccall_string type '}'
754 (is_dyn, is_casm, may_gc) = $2
756 target | is_dyn = DynamicTarget
757 | is_casm = CasmTarget $3
758 | otherwise = StaticTarget $3
760 ccall = CCallSpec target CCallConv may_gc
762 UfFCall (CCall ccall) $4
766 comma_exprs0 :: { [UfExpr RdrName] } -- Zero or more
767 comma_exprs0 : {- empty -} { [ ] }
768 | core_expr { [ $1 ] }
769 | comma_exprs2 { $1 }
771 comma_exprs2 :: { [UfExpr RdrName] } -- Two or more
772 comma_exprs2 : core_expr ',' core_expr { [$1,$3] }
773 | core_expr ',' comma_exprs2 { $1 : $3 }
775 rec_binds :: { [(UfBinder RdrName, UfExpr RdrName)] }
777 | core_val_bndr '=' core_expr ';' rec_binds { ($1,$3) : $5 }
779 core_alts :: { [UfAlt RdrName] }
781 | core_alt ';' core_alts { $1 : $3 }
783 core_alt :: { UfAlt RdrName }
784 core_alt : core_pat '->' core_expr { (fst $1, snd $1, $3) }
786 core_pat :: { (UfConAlt RdrName, [RdrName]) }
787 core_pat : core_lit { (UfLitAlt $1, []) }
788 | '__litlit' STRING atype { (UfLitLitAlt $2 $3, []) }
789 | qdata_name core_pat_names { (UfDataAlt $1, $2) }
790 | '(' ')' { (UfTupleAlt (mkHsTupCon dataName Boxed []), []) }
791 | '(' comma_var_names1 ')' { (UfTupleAlt (mkHsTupCon dataName Boxed $2), $2) }
792 | '(#' comma_var_names1 '#)' { (UfTupleAlt (mkHsTupCon dataName Unboxed $2), $2) }
793 | '__DEFAULT' { (UfDefault, []) }
794 | '(' core_pat ')' { $2 }
796 core_pat_names :: { [RdrName] }
797 core_pat_names : { [] }
798 | core_pat_name core_pat_names { $1 : $2 }
800 -- Tyvar names and variable names live in different name spaces
801 -- so they need to be signalled separately. But we don't record
802 -- types or kinds in a pattern; we work that out from the type
803 -- of the case scrutinee
804 core_pat_name :: { RdrName }
805 core_pat_name : var_name { $1 }
808 comma_var_names1 :: { [RdrName] } -- One or more
809 comma_var_names1 : var_name { [$1] }
810 | var_name ',' comma_var_names1 { $1 : $3 }
812 core_lit :: { Literal }
813 core_lit : integer { mkMachInt $1 }
814 | CHAR { MachChar $1 }
815 | STRING { MachStr $1 }
816 | rational { MachDouble $1 }
817 | '__word' integer { mkMachWord $2 }
818 | '__word64' integer { mkMachWord64 $2 }
819 | '__int64' integer { mkMachInt64 $2 }
820 | '__float' rational { MachFloat $2 }
821 | '__addr' integer { MachAddr $2 }
822 | '__label' STRING { MachLabel $2 }
824 integer :: { Integer }
826 | '-' INTEGER { (-$2) }
828 rational :: { Rational }
830 | '-' RATIONAL { (-$2) }
832 core_bndr :: { UfBinder RdrName }
833 core_bndr : core_val_bndr { $1 }
834 | core_tv_bndr { $1 }
836 core_bndrs :: { [UfBinder RdrName] }
838 | core_bndr core_bndrs { $1 : $2 }
840 core_val_bndr :: { UfBinder RdrName }
841 core_val_bndr : var_name '::' atype { UfValBinder $1 $3 }
843 core_tv_bndr :: { UfBinder RdrName }
844 core_tv_bndr : '@' tv_name '::' akind { UfTyBinder $2 $4 }
845 | '@' tv_name { UfTyBinder $2 liftedTypeKind }
847 ccall_string :: { FAST_STRING }
853 ------------------------------------------------------------------------
854 scc :: { CostCentre }
855 : '__sccC' '{' mod_name '}' { AllCafsCC $3 }
856 | '__scc' '{' cc_name mod_name cc_dup cc_caf '}'
857 { NormalCC { cc_name = $3, cc_mod = $4,
858 cc_is_dupd = $5, cc_is_caf = $6 } }
860 cc_name :: { EncodedFS }
864 cc_dup :: { IsDupdCC }
865 cc_dup : { OriginalCC }
868 cc_caf :: { IsCafCC }
872 -------------------------------------------------------------------
874 src_loc :: { SrcLoc }
875 src_loc : {% getSrcLocP }
877 -- Check the project version: this makes sure
878 -- that the project version (e.g. 407) in the interface
879 -- file is the same as that for the compiler that's reading it
880 checkVersion :: { () }
881 : {-empty-} {% checkVersion Nothing }
882 | INTEGER {% checkVersion (Just (fromInteger $1)) }
884 -------------------------------------------------------------------
889 happyError buf PState{ loc = loc } = PFailed (ifaceParseErr buf loc)
891 mk_con_decl name (ex_tvs, ex_ctxt) details loc = mkConDecl name ex_tvs ex_ctxt details loc