@@ -109,13 +109,14 @@ moduleHeader = try (do noDocCommentHere "Modules cannot have documentation c
109 Import ::= 'import' Identifier_t ';'?;
109 Import ::= 'import' Identifier_t ';'?;
112−import_ :: IdrisParser (String, Maybe String, FC)
112+import_ :: IdrisParser (Bool, String, Maybe String, FC)
113import_ = do fc <- getFC
113import_ = do fc <- getFC
114 reserved "import"
114 reserved "import"
115+ reexport <- option False (do reserved "public"; return True)
115 id <- identifier
116 id <- identifier
116 newName <- optional (reserved "as" *> identifier)
117 newName <- optional (reserved "as" *> identifier)
117 option ';' (lchar ';')
118 option ';' (lchar ';')
118− return (toPath id, toPath <$> newName, fc)
119+ return (reexport, toPath id, toPath <$> newName, fc)
119 <?> "import statement"
120 <?> "import statement"
120 where toPath = foldl1' (</>) . Spl.splitOn "."
121 where toPath = foldl1' (</>) . Spl.splitOn "."
@@ -1132,14 +1133,14 @@ parseTactic :: IState -> String -> Result PTactic
1132parseTactic st = runparser (fullTactic defaultSyntax) st "(input)"
1133parseTactic st = runparser (fullTactic defaultSyntax) st "(input)"
1134-- | Parse module header and imports
1135-- | Parse module header and imports
1135−parseImports :: FilePath -> String -> Idris ([String], [(String, Maybe String, FC)], Maybe Delta)
1136+parseImports :: FilePath -> String -> Idris ([String], [(Bool, String, Maybe String, FC)], Maybe Delta)
1136parseImports fname input
1137parseImports fname input
1137 = do i <- getIState
1138 = do i <- getIState
1138 case parseString (runInnerParser (evalStateT imports i)) (Directed (UTF8.fromString fname) 0 0 0 0) input of
1139 case parseString (runInnerParser (evalStateT imports i)) (Directed (UTF8.fromString fname) 0 0 0 0) input of
1139 Failure err -> fail (show err)
1140 Failure err -> fail (show err)
1140 Success (x, i) -> do putIState i
1141 Success (x, i) -> do putIState i
1141 return x
1142 return x
1142− where imports :: IdrisParser (([String], [(String, Maybe String, FC)], Maybe Delta), IState)
1143+ where imports :: IdrisParser (([String], [(Bool, String, Maybe String, FC)], Maybe Delta), IState)
1143 imports = do whiteSpace
1144 imports = do whiteSpace
1144 mname <- moduleHeader
1145 mname <- moduleHeader
1145 ps <- many import_
1146 ps <- many import_
@@ -1219,7 +1220,7 @@ loadModule' f
1219 IDR fn -> loadSource False fn Nothing
1220 IDR fn -> loadSource False fn Nothing
1220 LIDR fn -> loadSource True fn Nothing
1221 LIDR fn -> loadSource True fn Nothing
1221 IBC fn src ->
1222 IBC fn src ->
1222− idrisCatch (loadIBC fn)
1223+ idrisCatch (loadIBC True fn)
1223 (\c -> do iLOG $ fn ++ " failed " ++ pshow i c
1224 (\c -> do iLOG $ fn ++ " failed " ++ pshow i c
1224 case src of
1225 case src of
1225 IDR sfn -> loadSource False sfn Nothing
1226 IDR sfn -> loadSource False sfn Nothing
@@ -1229,18 +1230,18 @@ loadModule' f
1231{- | Load idris code from file -}
1232{- | Load idris code from file -}
1232−loadFromIFile :: IFileType -> Maybe Int -> Idris ()
1233+loadFromIFile :: Bool -> IFileType -> Maybe Int -> Idris ()
1233−loadFromIFile i@(IBC fn src) maxline
1234+loadFromIFile reexp i@(IBC fn src) maxline
1234 = do iLOG $ "Skipping " ++ getSrcFile i
1235 = do iLOG $ "Skipping " ++ getSrcFile i
1235− idrisCatch (loadIBC fn)
1236+ idrisCatch (loadIBC reexp fn)
1236 (\err -> ierror $ LoadingFailed fn err)
1237 (\err -> ierror $ LoadingFailed fn err)
1238 getSrcFile (IDR fn) = fn
1239 getSrcFile (IDR fn) = fn
1239 getSrcFile (LIDR fn) = fn
1240 getSrcFile (LIDR fn) = fn
1240 getSrcFile (IBC f src) = getSrcFile src
1241 getSrcFile (IBC f src) = getSrcFile src
1242−loadFromIFile (IDR fn) maxline = loadSource' False fn maxline
1243+loadFromIFile _ (IDR fn) maxline = loadSource' False fn maxline
1243−loadFromIFile (LIDR fn) maxline = loadSource' True fn maxline
1244+loadFromIFile _ (LIDR fn) maxline = loadSource' True fn maxline
1245{-| Load idris source code and show error if something wrong happens -}
1246{-| Load idris source code and show error if something wrong happens -}
1246loadSource' :: Bool -> FilePath -> Maybe Int -> Idris ()
1247loadSource' :: Bool -> FilePath -> Maybe Int -> Idris ()
@@ -1262,22 +1263,23 @@ loadSource lidr f toline
1262 file <- if lidr then tclift $ unlit f file_in else return file_in
1263 file <- if lidr then tclift $ unlit f file_in else return file_in
1263 (mname, imports_in, pos) <- parseImports f file
1264 (mname, imports_in, pos) <- parseImports f file
1264 ai <- getAutoImports
1265 ai <- getAutoImports
1265− let imports = map (\n -> (n, Just n, emptyFC)) ai ++ imports_in
1266+ let imports = map (\n -> (True, n, Just n, emptyFC)) ai ++ imports_in
1266 ids <- allImportDirs
1267 ids <- allImportDirs
1267 ibcsd <- valIBCSubDir i
1268 ibcsd <- valIBCSubDir i
1268− mapM_ (\f -> do fp <- findImport ids ibcsd f
1270+ do fp <- findImport ids ibcsd f
1269 case fp of
1271 case fp of
1270 LIDR fn -> ifail $ "No ibc for " ++ f
1272 LIDR fn -> ifail $ "No ibc for " ++ f
1271 IDR fn -> ifail $ "No ibc for " ++ f
1273 IDR fn -> ifail $ "No ibc for " ++ f
1272− IBC fn src -> loadIBC fn)
1274+ IBC fn src -> loadIBC True fn)
1273− [fn | (fn, _, _) <- imports]
1275+ [(re, fn) | (re, fn, _, _) <- imports]
1274 reportParserWarnings
1276 reportParserWarnings
1276 -- process and check module aliases
1278 -- process and check module aliases
1277 let modAliases = M.fromList
1279 let modAliases = M.fromList
1278− [(prep alias, prep realName) | (realName, Just alias, fc) <- imports]
1280+ [(prep alias, prep realName) | (reexport, realName, Just alias, fc) <- imports]
1279 prep = map T.pack . reverse . Spl.splitOn "/"
1281 prep = map T.pack . reverse . Spl.splitOn "/"
1280− aliasNames = [(alias, fc) | (_, Just alias, fc) <- imports]
1282+ aliasNames = [(alias, fc) | (_, _, Just alias, fc) <- imports]
1281 histogram = groupBy ((==) `on` fst) . sortBy (comparing fst) $ aliasNames
1283 histogram = groupBy ((==) `on` fst) . sortBy (comparing fst) $ aliasNames
1282 case map head . filter ((/= 1) . length) $ histogram of
1284 case map head . filter ((/= 1) . length) $ histogram of
1283 [] -> logLvl 3 $ "Module aliases: " ++ show (M.toList modAliases)
1285 [] -> logLvl 3 $ "Module aliases: " ++ show (M.toList modAliases)
@@ -1289,7 +1291,7 @@ loadSource lidr f toline
1289 -- record package info in .ibc
1291 -- record package info in .ibc
1290 imps <- allImportDirs
1292 imps <- allImportDirs
1291 mapM_ addIBC (map IBCImportDir imps)
1293 mapM_ addIBC (map IBCImportDir imps)
1292− mapM_ (addIBC . IBCImport) [realName | (realName, alias, fc) <- imports]
1294+ mapM_ (addIBC . IBCImport) [(reexport, realName) | (reexport, realName, alias, fc) <- imports]
1293 let syntax = defaultSyntax{ syn_namespace = reverse mname,
1295 let syntax = defaultSyntax{ syn_namespace = reverse mname,
1294 maxline = toline }
1296 maxline = toline }
1295 ds' <- parseProg syntax f file pos
1297 ds' <- parseProg syntax f file pos