diff options
Diffstat (limited to 'compiler/parser/Parser.y')
-rw-r--r-- | compiler/parser/Parser.y | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y index e6f639edb3..c2dae02afc 100644 --- a/compiler/parser/Parser.y +++ b/compiler/parser/Parser.y @@ -39,6 +39,7 @@ module Parser (parseModule, parseSignature, parseImport, parseStatement, parseBa import Control.Monad ( unless, liftM, when, (<=<) ) import GHC.Exts import Data.Char +import Data.Maybe ( maybeToList ) import Control.Monad ( mplus ) import Control.Applicative ((<$)) @@ -955,17 +956,22 @@ importdecls_semi | {- empty -} { [] } importdecl :: { LImportDecl GhcPs } - : 'import' maybe_src maybe_safe optqualified maybe_pkg modid maybeas maybeimpspec - {% ams (cL (comb4 $1 $6 (snd $7) $8) $ - ImportDecl { ideclExt = noExt - , ideclSourceSrc = snd $ fst $2 - , ideclName = $6, ideclPkgQual = snd $5 - , ideclSource = snd $2, ideclSafe = snd $3 - , ideclQualified = snd $4, ideclImplicit = False - , ideclAs = unLoc (snd $7) - , ideclHiding = unLoc $8 }) - ((mj AnnImport $1 : (fst $ fst $2) ++ fst $3 ++ fst $4 - ++ fst $5 ++ fst $7)) } + : 'import' maybe_src maybe_safe optqualified maybe_pkg modid optqualified maybeas maybeimpspec + {% do { + ; checkImportDecl $4 $7 + ; ams (cL (comb4 $1 $6 (snd $8) $9) $ + ImportDecl { ideclExt = noExt + , ideclSourceSrc = snd $ fst $2 + , ideclName = $6, ideclPkgQual = snd $5 + , ideclSource = snd $2, ideclSafe = snd $3 + , ideclQualified = importDeclQualifiedStyle $4 $7 + , ideclImplicit = False + , ideclAs = unLoc (snd $8) + , ideclHiding = unLoc $9 }) + ((mj AnnImport $1 : fst (fst $2) ++ fst $3 ++ fmap (mj AnnQualified) (maybeToList $4) + ++ fst $5 ++ fmap (mj AnnQualified) (maybeToList $7) ++ fst $8)) + } + } maybe_src :: { (([AddAnn],SourceText),IsBootInterface) } : '{-# SOURCE' '#-}' { (([mo $1,mc $2],getSOURCE_PRAGs $1) @@ -986,9 +992,9 @@ maybe_pkg :: { ([AddAnn],Maybe StringLiteral) } ; return ([mj AnnPackageName $1], Just (StringLiteral (getSTRINGs $1) pkgFS)) } } | {- empty -} { ([],Nothing) } -optqualified :: { ([AddAnn],Bool) } - : 'qualified' { ([mj AnnQualified $1],True) } - | {- empty -} { ([],False) } +optqualified :: { Maybe (Located Token) } + : 'qualified' { Just $1 } + | {- empty -} { Nothing } maybeas :: { ([AddAnn],Located (Maybe (Located ModuleName))) } : 'as' modid { ([mj AnnAs $1] |