{
-module ParseIface ( parseIface, IfaceStuff(..) ) where
+module ParseIface ( parseIface, parseType, parseRules, parseIdInfo ) where
#include "HsVersions.h"
)
import CostCentre ( CostCentre(..), IsCafCC(..), IsDupdCC(..) )
import CallConv ( cCallConv )
-import Type ( Kind, mkArrowKind, boxedTypeKind, openTypeKind, usageTypeKind )
+import Type ( Kind, mkArrowKind, liftedTypeKind, openTypeKind, usageTypeKind )
import IdInfo ( exactArity, InlinePragInfo(..) )
import PrimOp ( CCall(..), CCallTarget(..) )
import Lex
import RdrName ( RdrName, mkRdrUnqual, mkIfaceOrig )
import Name ( OccName )
import OccName ( mkSysOccFS,
- tcName, varName, ipName, dataName, clsName, tvName,
+ tcName, varName, dataName, clsName, tvName,
EncodedFS
)
import Module ( ModuleName, PackageName, mkSysModuleNameFS, mkModule )
import FastString ( tailFS )
}
-%name parseIface
+%name parseIface iface
+%name parseType type
+%name parseIdInfo id_info
+%name parseRules rules_and_deprecs
+
%tokentype { Token }
%monad { P }{ thenP }{ returnP }
%lexer { lexer } { ITeof }
UNKNOWN { ITunknown $$ }
%%
--- iface_stuff is the main production.
--- It recognises (a) a whole interface file
--- (b) a type (so that type sigs can be parsed lazily)
--- (c) the IdInfo part of a signature (same reason)
-
-iface_stuff :: { IfaceStuff }
-iface_stuff : iface { PIface $1 }
- | type { PType $1 }
- | id_info { PIdInfo $1 }
- | rules_and_deprecs { PRulesAndDeprecs $1 }
-
iface :: { ParsedIface }
iface : '__interface' package mod_name
version sub_versions
whats_imported : { NothingAtAll }
| '::' version { Everything $2 }
| '::' version version version name_version_pairs { Specifically $2 (Just $3) $5 $4 }
+ | '::' version version name_version_pairs { Specifically $2 Nothing $4 $3 }
name_version_pairs :: { [(OccName, Version)] }
name_version_pairs : { [] }
maybe_idinfo : {- empty -} { \_ -> [] }
| pragma { \x -> if opt_IgnoreIfacePragmas then []
else case $1 of
- POk _ (PIdInfo id_info) -> id_info
+ POk _ id_info -> id_info
PFailed err -> pprPanic "IdInfo parse failed"
(vcat [ppr x, err])
}
dates from a time where we picked up a .hi file first if it existed.]
-}
-pragma :: { ParseResult IfaceStuff }
-pragma : src_loc PRAGMA { parseIface $2 PState{ bol = 0#, atbol = 1#,
+pragma :: { ParseResult [HsIdInfo RdrName] }
+pragma : src_loc PRAGMA { parseIdInfo $2 PState{ bol = 0#, atbol = 1#,
+ context = [],
+ glasgow_exts = 1#,
+ loc = $1 }
+ }
+
+rules_prag :: { ParseResult ([RdrNameRuleDecl], IfaceDeprecs) }
+rules_prag : src_loc PRAGMA { parseRules $2 PState{ bol = 0#, atbol = 1#,
context = [],
glasgow_exts = 1#,
loc = $1 }
rules_and_deprecs_part :: { ([RdrNameRuleDecl], IfaceDeprecs) }
rules_and_deprecs_part : {- empty -} { ([], Nothing) }
- | pragma { case $1 of
- POk _ (PRulesAndDeprecs rds) -> rds
+ | rules_prag { case $1 of
+ POk _ rds -> rds
PFailed err -> pprPanic "Rules/Deprecations parse failed" err
}
| qvar_fs { mkIfaceOrig varName $1 }
ipvar_name :: { RdrName }
- : IPVARID { mkRdrUnqual (mkSysOccFS ipName (tailFS $1)) }
+ : IPVARID { mkRdrUnqual (mkSysOccFS varName (tailFS $1)) }
qvar_names1 :: { [RdrName] }
qvar_names1 : qvar_name { [$1] }
tv_bndr :: { HsTyVarBndr RdrName }
: tv_name '::' akind { IfaceTyVar $1 $3 }
- | tv_name { IfaceTyVar $1 boxedTypeKind }
+ | tv_name { IfaceTyVar $1 liftedTypeKind }
tv_bndrs :: { [HsTyVarBndr RdrName] }
: tv_bndrs1 { $1 }
akind :: { Kind }
: VARSYM { if $1 == SLIT("*") then
- boxedTypeKind
+ liftedTypeKind
else if $1 == SLIT("?") then
openTypeKind
else if $1 == SLIT("\36") then
core_tv_bndr :: { UfBinder RdrName }
core_tv_bndr : '@' tv_name '::' akind { UfTyBinder $2 $4 }
- | '@' tv_name { UfTyBinder $2 boxedTypeKind }
+ | '@' tv_name { UfTyBinder $2 liftedTypeKind }
ccall_string :: { FAST_STRING }
: STRING { $1 }
happyError :: P a
happyError buf PState{ loc = loc } = PFailed (ifaceParseErr buf loc)
-data IfaceStuff = PIface ParsedIface
- | PIdInfo [HsIdInfo RdrName]
- | PType RdrNameHsType
- | PRulesAndDeprecs ([RdrNameRuleDecl], IfaceDeprecs)
-
mk_con_decl name (ex_tvs, ex_ctxt) details loc = mkConDecl name ex_tvs ex_ctxt details loc
}